Merge pull request #3926 from OlegHahm/some-scan-build-warnings

clean up: Some scan build warnings
This commit is contained in:
Oleg Hahm 2015-09-22 11:43:20 +02:00
commit a0957b11d6
6 changed files with 17 additions and 13 deletions

View File

@ -108,10 +108,6 @@ int base64_encode(unsigned char *data_in, size_t data_in_size, \
/* The last character is not finished yet */ /* The last character is not finished yet */
njump++; njump++;
if (njump == 4) {
nNum = (tmpval >> (2 * njump));
}
nNum = nLst << (8 - 2 * njump); nNum = nLst << (8 - 2 * njump);
base64_out[iterate_base64_buffer++] = getsymbol(nNum); base64_out[iterate_base64_buffer++] = getsymbol(nNum);

View File

@ -35,7 +35,7 @@ bloom_t *bloom_new(size_t size, size_t num_hashes, ...)
} }
/* Allocate Bloom array */ /* Allocate Bloom array */
if (!(bloom->a = calloc(ROUND(size), sizeof(char)))) { if (!(bloom->a = calloc(ROUND(size), sizeof(uint8_t)))) {
free(bloom); free(bloom);
return NULL; return NULL;
} }

View File

@ -40,7 +40,7 @@ int ccm_compute_cbc_mac(cipher_t* cipher, uint8_t iv[16],
uint8_t offset, block_size, mac_enc[16] = {0}; uint8_t offset, block_size, mac_enc[16] = {0};
block_size = cipher_get_block_size(cipher); block_size = cipher_get_block_size(cipher);
memcpy(mac, iv, 16); memmove(mac, iv, 16);
offset = 0; offset = 0;
do { do {
uint8_t block_size_input = (length - offset > block_size) ? uint8_t block_size_input = (length - offset > block_size) ?

View File

@ -103,17 +103,18 @@ int stdimpl_strcmp(const char *s1, const char *s2)
if (s1 == s2) { if (s1 == s2) {
return 0; return 0;
} }
else if (s1 && !s2) { else if (s1 == NULL) {
return -1;
}
else if (s2 == NULL) {
return +1; return +1;
} }
else if (!s1 && s2) { else {
return -1; char c1, c2;
} else {
char c1,c2;
do { do {
c1 = *s1++; c1 = *s1++;
c2 = *s2++; c2 = *s2++;
} while (c1 && c2 && (c1==c2)); } while ((c1 == c2) && (c1 != '\0'));
return c1 - c2; return c1 - c2;
} }
} }

View File

@ -104,6 +104,8 @@ ssize_t ubjson_get_i32(ubjson_cookie_t *restrict cookie, ssize_t content, int32_
case UBJSON_INT32_INT32: case UBJSON_INT32_INT32:
*dest = (int32_t) byteorder_ntohl(value.i32); *dest = (int32_t) byteorder_ntohl(value.i32);
break; break;
default:
return -1;
} }
} }
return result; return result;
@ -134,7 +136,9 @@ static ubjson_read_callback_result_t _ubjson_read_length(ubjson_cookie_t *restri
if (type == UBJSON_TYPE_INT32) { if (type == UBJSON_TYPE_INT32) {
int32_t len32; int32_t len32;
read = ubjson_get_i32(cookie, content, &len32); read = ubjson_get_i32(cookie, content, &len32);
len64 = len32; if (read > 0) {
len64 = len32;
}
} }
else if (type == UBJSON_TYPE_INT64) { else if (type == UBJSON_TYPE_INT64) {
read = ubjson_get_i64(cookie, content, &len64); read = ubjson_get_i64(cookie, content, &len64);

View File

@ -351,6 +351,7 @@ static void test_array(void)
TEST_ASSERT_EQUAL_INT(1, i); TEST_ASSERT_EQUAL_INT(1, i);
offset += cbor_deserialize_int(&stream, offset, &i); offset += cbor_deserialize_int(&stream, offset, &i);
TEST_ASSERT_EQUAL_INT(2, i); TEST_ASSERT_EQUAL_INT(2, i);
TEST_ASSERT_EQUAL_INT(sizeof(data), offset);
} }
cbor_clear(&stream); cbor_clear(&stream);
@ -374,6 +375,7 @@ static void test_array(void)
char buffer[1024]; char buffer[1024];
offset += cbor_deserialize_byte_string(&stream, offset, buffer, sizeof(buffer)); offset += cbor_deserialize_byte_string(&stream, offset, buffer, sizeof(buffer));
TEST_ASSERT_EQUAL_STRING("a", &(buffer[0])); TEST_ASSERT_EQUAL_STRING("a", &(buffer[0]));
TEST_ASSERT_EQUAL_INT(sizeof(data), offset);
} }
} }
@ -442,6 +444,7 @@ static void test_map(void)
TEST_ASSERT_EQUAL_INT(2, key); TEST_ASSERT_EQUAL_INT(2, key);
offset += cbor_deserialize_byte_string(&stream, offset, value, sizeof(value)); offset += cbor_deserialize_byte_string(&stream, offset, value, sizeof(value));
TEST_ASSERT_EQUAL_STRING("2", &(value[0])); TEST_ASSERT_EQUAL_STRING("2", &(value[0]));
TEST_ASSERT_EQUAL_INT(sizeof(data), offset);
} }
} }