From: Aki Tuomi Date: Thu, 20 Aug 2020 05:39:26 +0000 (+0300) Subject: global: Fix negation with constants to match target type X-Git-Tag: 2.3.13~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4cca6a5c6ac142d741c256a399e97918a2d3bb5;p=thirdparty%2Fdovecot%2Fcore.git global: Fix negation with constants to match target type --- diff --git a/src/doveadm/doveadm-dump-log.c b/src/doveadm/doveadm-dump-log.c index 28f92d67aa..fcfbfd8f80 100644 --- a/src/doveadm/doveadm-dump-log.c +++ b/src/doveadm/doveadm-dump-log.c @@ -351,7 +351,7 @@ static void log_record_print(const struct mail_transaction_header *hdr, size_t record_size; end = CONST_PTR_OFFSET(data, size); - record_size = (sizeof(*rec) + prev_intro.record_size + 3) & ~3; + record_size = (sizeof(*rec) + prev_intro.record_size + 3) & ~3U; while (rec < end) { printf(" - uid=%u: ", rec->uid); if (prev_intro.record_size <= (char*)end - (char *)(rec+1)) diff --git a/src/lib-index/mail-cache-transaction.c b/src/lib-index/mail-cache-transaction.c index 76e948a327..ce1fdb673d 100644 --- a/src/lib-index/mail-cache-transaction.c +++ b/src/lib-index/mail-cache-transaction.c @@ -802,7 +802,7 @@ void mail_cache_add(struct mail_cache_transaction_ctx *ctx, uint32_t seq, i_assert(fixed_size == UINT_MAX || fixed_size == data_size); data_size32 = (uint32_t)data_size; - full_size = sizeof(field_idx) + ((data_size + 3) & ~3); + full_size = sizeof(field_idx) + ((data_size + 3) & ~3U); if (fixed_size == UINT_MAX) full_size += sizeof(data_size32); diff --git a/src/lib-index/mail-index-private.h b/src/lib-index/mail-index-private.h index 860c8c35ed..d1be1a4d67 100644 --- a/src/lib-index/mail-index-private.h +++ b/src/lib-index/mail-index-private.h @@ -48,7 +48,7 @@ typedef int mail_index_expunge_handler_t(struct mail_index_sync_map_ctx *ctx, typedef void mail_index_sync_lost_handler_t(struct mail_index *index); #define MAIL_INDEX_HEADER_SIZE_ALIGN(size) \ - (((size) + 7) & ~7) + (((size) + 7) & ~7U) struct mail_index_ext { const char *name; diff --git a/src/lib-index/mail-index-sync-update.c b/src/lib-index/mail-index-sync-update.c index b85b8a8f5e..007cfb4bb6 100644 --- a/src/lib-index/mail-index-sync-update.c +++ b/src/lib-index/mail-index-sync-update.c @@ -725,7 +725,7 @@ mail_index_sync_record_real(struct mail_index_sync_map_ctx *ctx, } /* the record is padded to 32bits in the transaction log */ - record_size = (sizeof(*rec) + ctx->cur_ext_record_size + 3) & ~3; + record_size = (sizeof(*rec) + ctx->cur_ext_record_size + 3) & ~3U; for (i = 0; i < hdr->size; i += record_size) { rec = CONST_PTR_OFFSET(data, i); diff --git a/src/lib-index/mail-index-util.c b/src/lib-index/mail-index-util.c index 066d30b974..2b27ae1e70 100644 --- a/src/lib-index/mail-index-util.c +++ b/src/lib-index/mail-index-util.c @@ -95,7 +95,7 @@ bool mail_index_seq_array_lookup(const ARRAY_TYPE(seq_array) *array, void mail_index_seq_array_alloc(ARRAY_TYPE(seq_array) *array, size_t record_size) { - size_t aligned_record_size = (record_size + 3) & ~3; + size_t aligned_record_size = (record_size + 3) & ~3U; i_assert(!array_is_created(array)); @@ -112,7 +112,7 @@ bool mail_index_seq_array_add(ARRAY_TYPE(seq_array) *array, uint32_t seq, unsigned int idx, aligned_record_size; /* records need to be 32bit aligned */ - aligned_record_size = (record_size + 3) & ~3; + aligned_record_size = (record_size + 3) & ~3U; if (!array_is_created(array)) mail_index_seq_array_alloc(array, record_size); diff --git a/src/lib-storage/index/index-mail.h b/src/lib-storage/index/index-mail.h index 8b54b285c1..3919ca9ab2 100644 --- a/src/lib-storage/index/index-mail.h +++ b/src/lib-storage/index/index-mail.h @@ -149,7 +149,7 @@ struct index_mail { #define HEADER_MATCH_FLAG_FOUND 1 #define HEADER_MATCH_SKIP_COUNT 2 #define HEADER_MATCH_USABLE(mail, num) \ - ((num & ~1) == (mail)->header_match_value) + ((num & ~1U) == (mail)->header_match_value) ARRAY(uint8_t) header_match; ARRAY(unsigned int) header_match_lines; uint8_t header_match_value; diff --git a/src/lib-storage/index/mbox/mbox-lock.c b/src/lib-storage/index/mbox/mbox-lock.c index 9f13bdaaa3..cebff48701 100644 --- a/src/lib-storage/index/mbox/mbox-lock.c +++ b/src/lib-storage/index/mbox/mbox-lock.c @@ -843,7 +843,7 @@ int mbox_unlock(struct mbox_mailbox *mbox, unsigned int lock_id) bool fcntl_locked; int i; - i_assert(mbox->mbox_lock_id == (lock_id & ~1)); + i_assert(mbox->mbox_lock_id == (lock_id & ~1U)); if ((lock_id & 1) != 0) { /* dropping exclusive lock */ diff --git a/src/lib-storage/list/mailbox-list-index-notify.c b/src/lib-storage/list/mailbox-list-index-notify.c index 1bf7a5c3c9..35ee04e04f 100644 --- a/src/lib-storage/list/mailbox-list-index-notify.c +++ b/src/lib-storage/list/mailbox-list-index-notify.c @@ -402,7 +402,7 @@ mailbox_list_index_notify_read_next(struct mailbox_list_notify_index *inotify) /* the record is padded to 32bits in the transaction log */ ext = array_idx(&inotify->view->index->extensions, inotify->cur_ext_id); - record_size = (sizeof(*rec) + ext->record_size + 3) & ~3; + record_size = (sizeof(*rec) + ext->record_size + 3) & ~3U; for (i = 0; i < hdr->size; i += record_size) { rec = CONST_PTR_OFFSET(data, i); diff --git a/src/lib/hash.c b/src/lib/hash.c index 967921ca80..4b1e6a000c 100644 --- a/src/lib/hash.c +++ b/src/lib/hash.c @@ -576,7 +576,7 @@ unsigned int strfastcase_hash(const char *p) unsigned int g, h = 0; while (*s != '\0') { - h = (h << 4) + ((*s) & ~0x20); + h = (h << 4) + ((*s) & ~0x20U); if ((g = h & 0xf0000000UL) != 0) { h = h ^ (g >> 24); h = h ^ g; diff --git a/src/lib/md4.c b/src/lib/md4.c index 9a7c24127a..e23b35d3fa 100644 --- a/src/lib/md4.c +++ b/src/lib/md4.c @@ -201,7 +201,7 @@ void md4_update(struct md4_context *ctx, const void *data, size_t size) } if (size >= 64) { - data = body(ctx, data, size & ~(unsigned long)0x3f); + data = body(ctx, data, size & ~0x3fUL); size &= 0x3f; } diff --git a/src/lib/md5.c b/src/lib/md5.c index ae83860cea..bd41340843 100644 --- a/src/lib/md5.c +++ b/src/lib/md5.c @@ -215,7 +215,7 @@ md5_update(struct md5_context *ctx, const void *data, size_t size) } if (size >= 64) { - data = body(ctx, data, size & ~(unsigned long)0x3f); + data = body(ctx, data, size & ~0x3fUL); size &= 0x3f; } diff --git a/src/lib/test-bits.c b/src/lib/test-bits.c index e80a0d5d48..8379c0673d 100644 --- a/src/lib/test-bits.c +++ b/src/lib/test-bits.c @@ -195,7 +195,7 @@ static void test_bit_tests(void) test_begin("HAS_..._BITS() macro tests"); test_assert(HAS_NO_BITS(1,0)); - test_assert(HAS_NO_BITS(2,~2)); + test_assert(HAS_NO_BITS(2,~2U)); test_assert(!HAS_NO_BITS(2,2)); /* OUCH - this vacuously true expression fails. However, if you are @@ -204,11 +204,11 @@ static void test_bit_tests(void) /* test_assert(HAS_ANY_BITS(6,0)); */ test_assert(HAS_ANY_BITS(3,1)); test_assert(HAS_ANY_BITS(2,3)); - test_assert(!HAS_ANY_BITS(7,~(7|128))); + test_assert(!HAS_ANY_BITS(7,~(7U|128U))); test_assert(HAS_ALL_BITS(0,0)); test_assert(HAS_ALL_BITS(30,14)); - test_assert(!HAS_ALL_BITS(~1,~0)); + test_assert(!HAS_ALL_BITS(~1U,~0U)); /* Trap double-evaluation */ unsigned int v=10,b=2; diff --git a/src/plugins/fts-squat/squat-uidlist.c b/src/plugins/fts-squat/squat-uidlist.c index e380d8fa81..5e1502efab 100644 --- a/src/plugins/fts-squat/squat-uidlist.c +++ b/src/plugins/fts-squat/squat-uidlist.c @@ -18,10 +18,10 @@ #define UIDLIST_LIST_SIZE 31 #define UIDLIST_BLOCK_LIST_COUNT 100 -#define UID_LIST_MASK_RANGE 0x80000000 +#define UID_LIST_MASK_RANGE 0x80000000U /* set = points to uidlist index number, unset = points to uidlist offset */ -#define UID_LIST_POINTER_MASK_LIST_IDX 0x80000000 +#define UID_LIST_POINTER_MASK_LIST_IDX 0x80000000U #define UIDLIST_PACKED_FLAG_BITMASK 1 #define UIDLIST_PACKED_FLAG_BEGINS_WITH_POINTER 2