From b2eaec6671ff7ff44bb2f93881ad30e6d6ba0d24 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 9 Nov 2015 15:40:47 +0100 Subject: [PATCH] csum: Remove unused parameter from calc_csum() The `ccsum' parameter to calc_csum() is never used and is set to 0 by all callers. There's no reason to keep it, so remove it. Signed-off-by: Tobias Klauser --- csum.h | 3 +-- proto_icmpv4.c | 2 +- proto_ipv4.c | 2 +- trafgen.c | 2 +- trafgen_parser.y | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/csum.h b/csum.h index 0d92c3062..6047c6f57 100644 --- a/csum.h +++ b/csum.h @@ -19,8 +19,7 @@ static inline unsigned short csum(unsigned short *buf, int nwords) return ~sum; } -static inline uint16_t calc_csum(void *addr, size_t len, - int ccsum __maybe_unused) +static inline uint16_t calc_csum(void *addr, size_t len) { return csum(addr, len >> 1); } diff --git a/proto_icmpv4.c b/proto_icmpv4.c index 55dd1b703..e6ebd433b 100644 --- a/proto_icmpv4.c +++ b/proto_icmpv4.c @@ -39,7 +39,7 @@ static void icmp(struct pkt_buff *pkt) if (icmp == NULL) return; - csum = calc_csum(icmp, pkt_len(pkt) + sizeof(*icmp), 0); + csum = calc_csum(icmp, pkt_len(pkt) + sizeof(*icmp)); tprintf(" [ ICMP "); tprintf("Type (%u), ", icmp->type); diff --git a/proto_ipv4.c b/proto_ipv4.c index cefc6ba6c..9b9e915d5 100644 --- a/proto_ipv4.c +++ b/proto_ipv4.c @@ -48,7 +48,7 @@ static void ipv4(struct pkt_buff *pkt) frag_off = ntohs(ip->h_frag_off); h_tot_len = ntohs(ip->h_tot_len); - csum = calc_csum(ip, ip->h_ihl * 4, 0); + csum = calc_csum(ip, ip->h_ihl * 4); inet_ntop(AF_INET, &ip->h_saddr, src_ip, sizeof(src_ip)); inet_ntop(AF_INET, &ip->h_daddr, dst_ip, sizeof(dst_ip)); diff --git a/trafgen.c b/trafgen.c index 0ee74ec3c..ba2393c31 100644 --- a/trafgen.c +++ b/trafgen.c @@ -333,7 +333,7 @@ static void apply_csum16(int id) switch (csum->which) { case CSUM_IP: sum = calc_csum(packets[id].payload + csum->from, - csum->to - csum->from + 1, 0); + csum->to - csum->from + 1); break; case CSUM_UDP: sum = p4_csum((void *) packets[id].payload + csum->from, diff --git a/trafgen_parser.y b/trafgen_parser.y index 1718f3d5d..21c3454e5 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -190,7 +190,7 @@ static void __set_csum16_static(size_t from, size_t to, enum csum which __maybe_ uint16_t sum; uint8_t *psum; - sum = htons(calc_csum(pkt->payload + from, to - from, 0)); + sum = htons(calc_csum(pkt->payload + from, to - from)); psum = (uint8_t *) ∑ set_byte(psum[0]);