diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-03 06:18:45 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-03 06:20:48 +0200 |
commit | 452dc76c606d47dc248f846f1202d708a7245f5e (patch) | |
tree | eb5fa1399b2a75f1681cdf0d5555e5babfe0088b | |
parent | 9a93bd7a398acd6f693f6a8332fc0dc6e410a2e5 (diff) |
global: satisfy bitshift pedantry
Suggested-by: Sultan Alsawaf <sultanxda@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | src/crypto/chacha20poly1305.c | 14 | ||||
-rw-r--r-- | src/hashtables.h | 4 | ||||
-rw-r--r-- | src/messages.h | 2 | ||||
-rw-r--r-- | src/ratelimiter.c | 2 | ||||
-rw-r--r-- | src/routingtable.c | 2 | ||||
-rw-r--r-- | src/tests/qemu/init.c | 2 | ||||
-rw-r--r-- | src/uapi/wireguard.h | 6 |
7 files changed, 16 insertions, 16 deletions
diff --git a/src/crypto/chacha20poly1305.c b/src/crypto/chacha20poly1305.c index 9e74784..7227617 100644 --- a/src/crypto/chacha20poly1305.c +++ b/src/crypto/chacha20poly1305.c @@ -459,7 +459,7 @@ static void poly1305_simd_mult(u32 *a, const u32 *b) memset(m, 0, sizeof(m)); /* The poly1305 block function adds a hi-bit to the accumulator which * we don't need for key multiplication; compensate for it. */ - a[4] -= 1 << 24; + a[4] -= 1U << 24; poly1305_asm_block_sse2(a, m, b, 1); } @@ -523,7 +523,7 @@ static void poly1305_update(struct poly1305_ctx *ctx, const u8 *src, unsigned in poly1305_simd_blocks(ctx, ctx->buf, POLY1305_BLOCK_SIZE); else #endif - poly1305_generic_blocks(ctx, ctx->buf, POLY1305_BLOCK_SIZE, 1 << 24); + poly1305_generic_blocks(ctx, ctx->buf, POLY1305_BLOCK_SIZE, 1U << 24); ctx->buflen = 0; } } @@ -534,7 +534,7 @@ static void poly1305_update(struct poly1305_ctx *ctx, const u8 *src, unsigned in bytes = poly1305_simd_blocks(ctx, src, srclen); else #endif - bytes = poly1305_generic_blocks(ctx, src, srclen, 1 << 24); + bytes = poly1305_generic_blocks(ctx, src, srclen, 1U << 24); src += srclen - bytes; srclen = bytes; } @@ -574,10 +574,10 @@ static void poly1305_finish(struct poly1305_ctx *ctx, u8 *dst) /* compute h + -p */ g0 = h0 + 5; - g1 = h1 + (g0 >> 26); g0 &= 0x3ffffff; - g2 = h2 + (g1 >> 26); g1 &= 0x3ffffff; - g3 = h3 + (g2 >> 26); g2 &= 0x3ffffff; - g4 = h4 + (g3 >> 26) - (1 << 26); g3 &= 0x3ffffff; + g1 = h1 + (g0 >> 26); g0 &= 0x3ffffff; + g2 = h2 + (g1 >> 26); g1 &= 0x3ffffff; + g3 = h3 + (g2 >> 26); g2 &= 0x3ffffff; + g4 = h4 + (g3 >> 26) - (1U << 26); g3 &= 0x3ffffff; /* select h if h < p, or h + -p if h >= p */ mask = (g4 >> ((sizeof(u32) * 8) - 1)) - 1; diff --git a/src/hashtables.h b/src/hashtables.h index 2a178a0..e12bfd6 100644 --- a/src/hashtables.h +++ b/src/hashtables.h @@ -30,8 +30,8 @@ struct index_hashtable { }; enum index_hashtable_type { - INDEX_HASHTABLE_HANDSHAKE = (1 << 0), - INDEX_HASHTABLE_KEYPAIR = (1 << 1) + INDEX_HASHTABLE_HANDSHAKE = 1U << 0, + INDEX_HASHTABLE_KEYPAIR = 1U << 1 }; struct index_hashtable_entry { diff --git a/src/messages.h b/src/messages.h index acf248c..19488a6 100644 --- a/src/messages.h +++ b/src/messages.h @@ -46,7 +46,7 @@ enum limits { REKEY_AFTER_TIME = 120 * HZ, REJECT_AFTER_TIME = 180 * HZ, INITIATIONS_PER_SECOND = HZ / 50, - MAX_PEERS_PER_DEVICE = 1 << 20, + MAX_PEERS_PER_DEVICE = 1U << 20, KEEPALIVE_TIMEOUT = 10 * HZ, MAX_TIMER_HANDSHAKES = (90 * HZ) / REKEY_TIMEOUT, MAX_QUEUED_INCOMING_HANDSHAKES = 4096, /* TODO: replace this with DQL */ diff --git a/src/ratelimiter.c b/src/ratelimiter.c index c4281e1..0afcdac 100644 --- a/src/ratelimiter.c +++ b/src/ratelimiter.c @@ -150,7 +150,7 @@ int ratelimiter_init(void) * but what it shares in common is that it uses a massive hashtable. So, * we borrow their wisdom about good table sizes on different systems * dependent on RAM. This calculation here comes from there. */ - table_size = (totalram_pages > (1 << 30) / PAGE_SIZE) ? 8192 : max_t(unsigned long, 16, roundup_pow_of_two((totalram_pages << PAGE_SHIFT) / (1 << 14) / sizeof(struct hlist_head))); + table_size = (totalram_pages > (1U << 30) / PAGE_SIZE) ? 8192 : max_t(unsigned long, 16, roundup_pow_of_two((totalram_pages << PAGE_SHIFT) / (1U << 14) / sizeof(struct hlist_head))); max_entries = table_size * 8; table_v4 = kvzalloc(table_size * sizeof(struct hlist_head), GFP_KERNEL); diff --git a/src/routingtable.c b/src/routingtable.c index c4e343f..6fdad8a 100644 --- a/src/routingtable.c +++ b/src/routingtable.c @@ -14,7 +14,7 @@ struct routing_table_node { static inline void copy_and_assign_cidr(struct routing_table_node *node, const u8 *src, u8 cidr) { memcpy(node->bits, src, (cidr + 7) / 8); - node->bits[(cidr + 7) / 8 - 1] &= 0xff << ((8 - (cidr % 8)) % 8); + node->bits[(cidr + 7) / 8 - 1] &= 0xffU << ((8 - (cidr % 8)) % 8); node->cidr = cidr; node->bit_at_a = cidr / 8; node->bit_at_b = 7 - (cidr % 8); diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c index 130fd0e..3d0c9de 100644 --- a/src/tests/qemu/init.c +++ b/src/tests/qemu/init.c @@ -26,7 +26,7 @@ __attribute__((noreturn)) static void poweroff(void) fflush(stderr); #if defined(__x86_64__) || defined(__i386__) ioperm(0x604, 2, 1); - outw(1 << 13, 0x604); + outw(1U << 13, 0x604); #else reboot(RB_POWER_OFF); #endif diff --git a/src/uapi/wireguard.h b/src/uapi/wireguard.h index 9c260be..5274c44 100644 --- a/src/uapi/wireguard.h +++ b/src/uapi/wireguard.h @@ -152,7 +152,7 @@ enum wg_cmd { #define WG_CMD_MAX (__WG_CMD_MAX - 1) enum wgdevice_flag { - WGDEVICE_F_REPLACE_PEERS = (1 << 0) + WGDEVICE_F_REPLACE_PEERS = 1U << 0 }; enum wgdevice_attribute { WGDEVICE_A_UNSPEC, @@ -169,8 +169,8 @@ enum wgdevice_attribute { #define WGDEVICE_A_MAX (__WGDEVICE_A_LAST - 1) enum wgpeer_flag { - WGPEER_F_REMOVE_ME = (1 << 0), - WGPEER_F_REPLACE_ALLOWEDIPS = (1 << 1) + WGPEER_F_REMOVE_ME = 1U << 0, + WGPEER_F_REPLACE_ALLOWEDIPS = 1U << 1 }; enum wgpeer_attribute { WGPEER_A_UNSPEC, |