Skip to content

Commit

Permalink
global: More fixes to mismatched bool vs int handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Jun 5, 2016
1 parent d9a7e95 commit 4cc0466
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/auth/mech-skey.c
Expand Up @@ -132,7 +132,7 @@ mech_skey_auth_phase2(struct auth_request *auth_request,
} else {
const char *words = t_strndup(data, data_size);

ret = otp_parse_response(words, hash, 0);
ret = otp_parse_response(words, hash, FALSE);
if (ret < 0) {
auth_request_log_error(&request->auth_request, AUTH_SUBSYS_MECH,
"invalid response");
Expand Down
8 changes: 4 additions & 4 deletions src/lib-imap/test-imap-utf7.c
Expand Up @@ -96,7 +96,7 @@ static void test_imap_utf7_non_utf16(void)
csrc[4] = mb64[(i&3) << 4];
csrc[5] = '-';
csrc[6] = '\0';
test_assert_idx(imap_utf7_is_valid(csrc+2) == 0, i);
test_assert_idx(!imap_utf7_is_valid(csrc+2), i);
}
for (i = 0; i <= 255; ++i) {
/* Invalid, U+00E4 followed by a single octet */
Expand All @@ -105,7 +105,7 @@ static void test_imap_utf7_non_utf16(void)
csrc[2] = mb64[((0x00 & 0x03) << 4) | (0xe4 >> 4)];
csrc[3] = mb64[((0xe4 & 0x0f) << 2) | ( i >> 6)];
csrc[4] = mb64[ i & 0x3f ];
test_assert_idx(imap_utf7_is_valid(csrc) == 0, i);
test_assert_idx(!imap_utf7_is_valid(csrc), i);
}
test_end();
}
Expand All @@ -124,7 +124,7 @@ static void test_imap_utf7_bad_ascii(void)
i = 0x7f;
csrc[0] = i;
csrc[1] = '\0';
test_assert_idx(imap_utf7_is_valid(csrc) == 0, i);
test_assert_idx(!imap_utf7_is_valid(csrc), i);
str_truncate(dest, 0);
test_assert_idx(imap_utf7_to_utf8(csrc, dest) < 0, i);
}
Expand All @@ -148,7 +148,7 @@ static void test_imap_utf7_unnecessary(void)
csrc[3] = mb64[(( i & 0x0f) << 2) | 0 ];
csrc[4] = '-';
csrc[5] = '\0';
test_assert_idx(imap_utf7_is_valid(csrc) == 0, i);
test_assert_idx(!imap_utf7_is_valid(csrc), i);
str_truncate(dest, 0);
test_assert_idx(imap_utf7_to_utf8(csrc, dest) < 0, i);

Expand Down
4 changes: 2 additions & 2 deletions src/lib-ntlm/ntlm-encrypt.c
Expand Up @@ -53,7 +53,7 @@ void lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE])
void ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE])
{
size_t len;
void *wpwd = t_unicode_str(passwd, 0, &len);
void *wpwd = t_unicode_str(passwd, FALSE, &len);

md4_get_digest(wpwd, len, hash);

Expand All @@ -64,7 +64,7 @@ static void
hmac_md5_ucs2le_string_ucase(struct hmac_context *ctx, const char *str)
{
size_t len;
unsigned char *wstr = t_unicode_str(str, 1, &len);
unsigned char *wstr = t_unicode_str(str, TRUE, &len);

hmac_update(ctx, wstr, len);
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib-storage/index/mbox/mbox-sync.c
Expand Up @@ -436,7 +436,7 @@ static void mbox_sync_update_index(struct mbox_sync_mail_context *mail_ctx,
MODIFY_REPLACE, mbox_flags);
mbox_sync_update_index_keywords(mail_ctx);

if (sync_ctx->mbox->mbox_save_md5 != 0) {
if (sync_ctx->mbox->mbox_save_md5) {
mail_index_update_ext(sync_ctx->t, sync_ctx->idx_seq,
sync_ctx->mbox->md5hdr_ext_idx,
mail_ctx->hdr_md5_sum, NULL);
Expand Down Expand Up @@ -466,7 +466,7 @@ static void mbox_sync_update_index(struct mbox_sync_mail_context *mail_ctx,
mbox_sync_update_index_keywords(mail_ctx);

/* see if we need to update md5 sum. */
if (sync_ctx->mbox->mbox_save_md5 != 0)
if (sync_ctx->mbox->mbox_save_md5)
mbox_sync_update_md5_if_changed(mail_ctx);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib-storage/test-mailbox-get.c
Expand Up @@ -122,8 +122,8 @@ static void test_mailbox_get_expunges(void)

t_array_init(&expunges, 32);
modseq = 98ULL << 32;
test_assert(mailbox_get_expunges(box, modseq, &uids_filter,
&expunges) == 0);
test_assert(!mailbox_get_expunges(box, modseq, &uids_filter,
&expunges));

exp = array_get(&expunges, &count);
test_assert(count == 5);
Expand Down
30 changes: 15 additions & 15 deletions src/lib/test-array.c
Expand Up @@ -195,10 +195,10 @@ static void test_array_cmp(void)
array_append(&arr2, &elems[i], 1);
}
array_append(&arr1, elems, NELEMS);
test_assert(array_cmp(&arr1, &arr2) == 1);
test_assert(array_equal_fn(&arr1, &arr2, test_compare_ushort) == 1);
test_assert(array_cmp(&arr1, &arr2) == TRUE);
test_assert(array_equal_fn(&arr1, &arr2, test_compare_ushort) == TRUE);
fuzz = 0;
test_assert(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == 1);
test_assert(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == TRUE);

for (i = 0; i < 256; i++) {
unsigned int j = rand() % NELEMS;
Expand All @@ -212,22 +212,22 @@ static void test_array_cmp(void)
fuzz = (int)tmp - (int)repl;
if (fuzz < 0)
fuzz = -fuzz;
test_assert_idx(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == 1, i);
test_assert_idx(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == TRUE, i);
if (fuzz > 0) {
fuzz--;
test_assert_idx(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == 0, i);
test_assert_idx(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == FALSE, i);
}
array_idx_set(&arr2, j, &tmp);
test_assert_idx(array_cmp(&arr1, &arr2) == TRUE, i);
test_assert_idx(array_equal_fn(&arr1, &arr2, test_compare_ushort) == 1, i);
test_assert_idx(array_equal_fn(&arr1, &arr2, test_compare_ushort) == TRUE, i);
fuzz = 0;
test_assert_idx(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == 1, i);
test_assert_idx(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == TRUE, i);
}
elems[NELEMS] = 0;
array_append(&arr2, &elems[NELEMS], 1);
test_assert(array_cmp(&arr1, &arr2) == 0);
test_assert(array_equal_fn(&arr1, &arr2, test_compare_ushort) == 0);
test_assert_idx(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == 0, i);
test_assert(array_cmp(&arr1, &arr2) == FALSE);
test_assert(array_equal_fn(&arr1, &arr2, test_compare_ushort) == FALSE);
test_assert_idx(array_equal_fn_ctx(&arr1, &arr2, test_compare_ushort_fuzz, &fuzz) == FALSE, i);

test_end();
}
Expand All @@ -251,8 +251,8 @@ static void test_array_cmp_str(void)
array_append(&arr2, &elemstrs[i], 1);
}
array_append(&arr1, elemstrs, NELEMS);
test_assert(array_cmp(&arr1, &arr2) == 1); /* pointers shared, so identical */
test_assert(array_equal_fn(&arr1, &arr2, test_compare_string) == 1); /* therefore value same */
test_assert(array_cmp(&arr1, &arr2) == TRUE); /* pointers shared, so identical */
test_assert(array_equal_fn(&arr1, &arr2, test_compare_string) == TRUE); /* therefore value same */
for (i = 0; i < 2560; i++) {
unsigned int j = rand() % NELEMS;
const char *const *ostr_p = array_idx(&arr2, j);
Expand All @@ -267,14 +267,14 @@ static void test_array_cmp_str(void)
if(rc == olen)
buf[rc+1] = '\0';
array_idx_set(&arr2, j, &bufp);
test_assert(array_cmp(&arr1, &arr2) == 0); /* pointers now differ */
test_assert(array_cmp(&arr1, &arr2) == FALSE); /* pointers now differ */
test_assert_idx(array_equal_fn(&arr1, &arr2, test_compare_string)
== (strcmp(ostr, buf) == 0), i); /* sometimes still the same */
test_assert_idx(array_equal_fn(&arr1, &arr2, test_compare_string)
== (ochar == buf[rc]), i); /* ditto */
array_idx_set(&arr2, j, &ostr);
test_assert(array_cmp(&arr1, &arr2) == 1); /* pointers now same again */
test_assert_idx(array_equal_fn(&arr1, &arr2, test_compare_string) == 1, i); /* duh! */
test_assert(array_cmp(&arr1, &arr2) == TRUE); /* pointers now same again */
test_assert_idx(array_equal_fn(&arr1, &arr2, test_compare_string) == TRUE, i); /* duh! */
}
/* length differences being detected are tested in other tests */
test_end();
Expand Down

0 comments on commit 4cc0466

Please sign in to comment.