diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-09-04 10:44:42 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-09-04 11:08:29 -0600 |
commit | 4ed60c09ee40f22f99afd59f3ff94866b7aa0cc4 (patch) | |
tree | df5d7df445df552374ea62771c9ec2e3c6c511aa /src/selftest | |
parent | 93b6e83e4faa8de6247e0e46d5060ec543befef8 (diff) |
global: prefer sizeof(*pointer) when possible
Suggested-by: Sultan Alsawaf <sultanxda@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/selftest')
-rw-r--r-- | src/selftest/allowedips.h | 12 | ||||
-rw-r--r-- | src/selftest/ratelimiter.h | 4 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/selftest/allowedips.h b/src/selftest/allowedips.h index 28461d7..6b47fc8 100644 --- a/src/selftest/allowedips.h +++ b/src/selftest/allowedips.h @@ -176,8 +176,7 @@ static __init int horrible_allowedips_insert_v4(struct horrible_allowedips *table, struct in_addr *ip, uint8_t cidr, void *value) { - struct horrible_allowedips_node *node = - kzalloc(sizeof(struct horrible_allowedips_node), GFP_KERNEL); + struct horrible_allowedips_node *node = kzalloc(sizeof(*node), GFP_KERNEL); if (!node) return -ENOMEM; @@ -193,8 +192,7 @@ static __init int horrible_allowedips_insert_v6(struct horrible_allowedips *table, struct in6_addr *ip, uint8_t cidr, void *value) { - struct horrible_allowedips_node *node = - kzalloc(sizeof(struct horrible_allowedips_node), GFP_KERNEL); + struct horrible_allowedips_node *node = kzalloc(sizeof(*node), GFP_KERNEL); if (!node) return -ENOMEM; @@ -256,13 +254,13 @@ static __init bool randomized_test(void) allowedips_init(&t); horrible_allowedips_init(&h); - peers = kcalloc(NUM_PEERS, sizeof(struct wireguard_peer *), GFP_KERNEL); + peers = kcalloc(NUM_PEERS, sizeof(*peers), GFP_KERNEL); if (!peers) { pr_info("allowedips random self-test: out of memory\n"); goto free; } for (i = 0; i < NUM_PEERS; ++i) { - peers[i] = kzalloc(sizeof(struct wireguard_peer), GFP_KERNEL); + peers[i] = kzalloc(sizeof(*peers[i]), GFP_KERNEL); if (!peers[i]) { pr_info("allowedips random self-test: out of memory\n"); goto free; @@ -456,7 +454,7 @@ static __init int walk_callback(void *ctx, const u8 *ip, u8 cidr, int family) } #define init_peer(name) do { \ - name = kzalloc(sizeof(struct wireguard_peer), GFP_KERNEL); \ + name = kzalloc(sizeof(*name), GFP_KERNEL); \ if (!name) { \ pr_info("allowedips self-test: out of memory\n"); \ goto free; \ diff --git a/src/selftest/ratelimiter.h b/src/selftest/ratelimiter.h index a71ddb1..1f2b697 100644 --- a/src/selftest/ratelimiter.h +++ b/src/selftest/ratelimiter.h @@ -62,7 +62,7 @@ bool __init ratelimiter_selftest(void) if (!skb4) goto err_nofree; skb4->protocol = htons(ETH_P_IP); - hdr4 = (struct iphdr *)skb_put(skb4, sizeof(struct iphdr)); + hdr4 = (struct iphdr *)skb_put(skb4, sizeof(*hdr4)); hdr4->saddr = htonl(8182); skb_reset_network_header(skb4); ++test; @@ -74,7 +74,7 @@ bool __init ratelimiter_selftest(void) goto err_nofree; } skb6->protocol = htons(ETH_P_IPV6); - hdr6 = (struct ipv6hdr *)skb_put(skb6, sizeof(struct ipv6hdr)); + hdr6 = (struct ipv6hdr *)skb_put(skb6, sizeof(*hdr6)); hdr6->saddr.in6_u.u6_addr32[0] = htonl(1212); hdr6->saddr.in6_u.u6_addr32[1] = htonl(289188); skb_reset_network_header(skb6); |