diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-10-01 03:07:22 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-10-01 03:07:22 +0200 |
commit | 4a0eb0370c4df8ee01973b50bb460560532b79f1 (patch) | |
tree | ce2324f97b05ae50355961d47dea6cd003a4fc05 | |
parent | aaa0709e7b39d0dc22ac92443a86c84eaff58679 (diff) | |
download | busybox-w32-4a0eb0370c4df8ee01973b50bb460560532b79f1.tar.gz busybox-w32-4a0eb0370c4df8ee01973b50bb460560532b79f1.tar.bz2 busybox-w32-4a0eb0370c4df8ee01973b50bb460560532b79f1.zip |
gcc-9.x warning fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/tar.c | 3 | ||||
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/inet_cksum.c | 4 | ||||
-rw-r--r-- | networking/ping.c | 4 | ||||
-rw-r--r-- | networking/traceroute.c | 2 | ||||
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 2 | ||||
-rw-r--r-- | networking/udhcp/d6_packet.c | 2 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 4 | ||||
-rw-r--r-- | networking/udhcp/packet.c | 4 |
9 files changed, 15 insertions, 12 deletions
diff --git a/archival/tar.c b/archival/tar.c index 4ab38db29..4f2564813 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -297,7 +297,8 @@ static void writeLongname(int fd, int type, const char *name, int dir) | |||
297 | header.typeflag = type; | 297 | header.typeflag = type; |
298 | strcpy(header.name, "././@LongLink"); | 298 | strcpy(header.name, "././@LongLink"); |
299 | /* This sets mode/uid/gid/mtime to "00...00<NUL>" strings */ | 299 | /* This sets mode/uid/gid/mtime to "00...00<NUL>" strings */ |
300 | memset(header.mode, '0', sizeof(struct prefilled)); | 300 | memset((char*)&header + offsetof(struct tar_header_t, mode), /* make gcc-9.x happy */ |
301 | '0', sizeof(struct prefilled)); | ||
301 | header.mode [sizeof(header.mode ) - 1] = '\0'; | 302 | header.mode [sizeof(header.mode ) - 1] = '\0'; |
302 | header.uid [sizeof(header.uid ) - 1] = '\0'; | 303 | header.uid [sizeof(header.uid ) - 1] = '\0'; |
303 | header.gid [sizeof(header.gid ) - 1] = '\0'; | 304 | header.gid [sizeof(header.gid ) - 1] = '\0'; |
diff --git a/include/libbb.h b/include/libbb.h index df7e45404..3e23b5bbd 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -818,7 +818,7 @@ ssize_t recv_from_to(int fd, void *buf, size_t len, int flags, | |||
818 | struct sockaddr *to, | 818 | struct sockaddr *to, |
819 | socklen_t sa_size) FAST_FUNC; | 819 | socklen_t sa_size) FAST_FUNC; |
820 | 820 | ||
821 | uint16_t inet_cksum(uint16_t *addr, int len) FAST_FUNC; | 821 | uint16_t inet_cksum(const void *addr, int len) FAST_FUNC; |
822 | int parse_pasv_epsv(char *buf) FAST_FUNC; | 822 | int parse_pasv_epsv(char *buf) FAST_FUNC; |
823 | 823 | ||
824 | /* 0 if argv[0] is NULL: */ | 824 | /* 0 if argv[0] is NULL: */ |
diff --git a/libbb/inet_cksum.c b/libbb/inet_cksum.c index 3d5dc3adf..fee8648f3 100644 --- a/libbb/inet_cksum.c +++ b/libbb/inet_cksum.c | |||
@@ -6,8 +6,10 @@ | |||
6 | 6 | ||
7 | #include "libbb.h" | 7 | #include "libbb.h" |
8 | 8 | ||
9 | uint16_t FAST_FUNC inet_cksum(uint16_t *addr, int nleft) | 9 | uint16_t FAST_FUNC inet_cksum(const void *ptr, int nleft) |
10 | { | 10 | { |
11 | const uint16_t *addr = ptr; | ||
12 | |||
11 | /* | 13 | /* |
12 | * Our algorithm is simple, using a 32 bit accumulator, | 14 | * Our algorithm is simple, using a 32 bit accumulator, |
13 | * we add sequential 16 bit words to it, and at the end, fold | 15 | * we add sequential 16 bit words to it, and at the end, fold |
diff --git a/networking/ping.c b/networking/ping.c index 47b6ab1b2..5f7e5b9b5 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -217,7 +217,7 @@ static void ping4(len_and_sockaddr *lsa) | |||
217 | /*memset(pkt, 0, sizeof(G.packet)); already is */ | 217 | /*memset(pkt, 0, sizeof(G.packet)); already is */ |
218 | pkt->icmp_type = ICMP_ECHO; | 218 | pkt->icmp_type = ICMP_ECHO; |
219 | pkt->icmp_id = G.myid; | 219 | pkt->icmp_id = G.myid; |
220 | pkt->icmp_cksum = inet_cksum((uint16_t *) pkt, sizeof(G.packet)); | 220 | pkt->icmp_cksum = inet_cksum(pkt, sizeof(G.packet)); |
221 | 221 | ||
222 | xsendto(pingsock, G.packet, DEFDATALEN + ICMP_MINLEN, &lsa->u.sa, lsa->len); | 222 | xsendto(pingsock, G.packet, DEFDATALEN + ICMP_MINLEN, &lsa->u.sa, lsa->len); |
223 | 223 | ||
@@ -529,7 +529,7 @@ static void sendping4(int junk UNUSED_PARAM) | |||
529 | /* No hton: we'll read it back on the same machine */ | 529 | /* No hton: we'll read it back on the same machine */ |
530 | *(uint32_t*)&pkt->icmp_dun = G.cur_us = monotonic_us(); | 530 | *(uint32_t*)&pkt->icmp_dun = G.cur_us = monotonic_us(); |
531 | 531 | ||
532 | pkt->icmp_cksum = inet_cksum((uint16_t *) pkt, datalen + ICMP_MINLEN); | 532 | pkt->icmp_cksum = inet_cksum(pkt, datalen + ICMP_MINLEN); |
533 | 533 | ||
534 | sendping_tail(sendping4, ICMP_MINLEN); | 534 | sendping_tail(sendping4, ICMP_MINLEN); |
535 | } | 535 | } |
diff --git a/networking/traceroute.c b/networking/traceroute.c index 5068f654b..1c4dc3e4a 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -468,7 +468,7 @@ send_probe(int seq, int ttl) | |||
468 | /* Always calculate checksum for icmp packets */ | 468 | /* Always calculate checksum for icmp packets */ |
469 | outicmp->icmp_cksum = 0; | 469 | outicmp->icmp_cksum = 0; |
470 | outicmp->icmp_cksum = inet_cksum( | 470 | outicmp->icmp_cksum = inet_cksum( |
471 | (uint16_t *)outicmp, | 471 | outicmp, |
472 | ((char*)outip + packlen) - (char*)outicmp | 472 | ((char*)outip + packlen) - (char*)outicmp |
473 | ); | 473 | ); |
474 | if (outicmp->icmp_cksum == 0) | 474 | if (outicmp->icmp_cksum == 0) |
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index fc2d672b7..ac8af91d3 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -947,7 +947,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac | |||
947 | // packet.ip.tot_len = packet.udp.len; /* yes, this is needed */ | 947 | // packet.ip.tot_len = packet.udp.len; /* yes, this is needed */ |
948 | // check = packet.udp.check; | 948 | // check = packet.udp.check; |
949 | // packet.udp.check = 0; | 949 | // packet.udp.check = 0; |
950 | // if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { | 950 | // if (check && check != inet_cksum(&packet, bytes)) { |
951 | // log1("packet with bad UDP checksum received, ignoring"); | 951 | // log1("packet with bad UDP checksum received, ignoring"); |
952 | // return -2; | 952 | // return -2; |
953 | // } | 953 | // } |
diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c index 446497e15..167a813e3 100644 --- a/networking/udhcp/d6_packet.c +++ b/networking/udhcp/d6_packet.c | |||
@@ -103,7 +103,7 @@ int FAST_FUNC d6_send_raw_packet( | |||
103 | */ | 103 | */ |
104 | packet.ip6.ip6_hlim = IPPROTO_UDP; | 104 | packet.ip6.ip6_hlim = IPPROTO_UDP; |
105 | packet.udp.check = inet_cksum( | 105 | packet.udp.check = inet_cksum( |
106 | (uint16_t *)&packet + 2, | 106 | (uint8_t *)&packet + 4, |
107 | offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size | 107 | offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size |
108 | ); | 108 | ); |
109 | /* fix 'hop limit' and 'next header' after UDP checksumming */ | 109 | /* fix 'hop limit' and 'next header' after UDP checksumming */ |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index e13eb3f9f..66aa38c20 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -935,7 +935,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd) | |||
935 | /* verify IP checksum */ | 935 | /* verify IP checksum */ |
936 | check = packet.ip.check; | 936 | check = packet.ip.check; |
937 | packet.ip.check = 0; | 937 | packet.ip.check = 0; |
938 | if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) { | 938 | if (check != inet_cksum(&packet.ip, sizeof(packet.ip))) { |
939 | log1s("bad IP header checksum, ignoring"); | 939 | log1s("bad IP header checksum, ignoring"); |
940 | return -2; | 940 | return -2; |
941 | } | 941 | } |
@@ -960,7 +960,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd) | |||
960 | packet.ip.tot_len = packet.udp.len; /* yes, this is needed */ | 960 | packet.ip.tot_len = packet.udp.len; /* yes, this is needed */ |
961 | check = packet.udp.check; | 961 | check = packet.udp.check; |
962 | packet.udp.check = 0; | 962 | packet.udp.check = 0; |
963 | if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { | 963 | if (check && check != inet_cksum(&packet, bytes)) { |
964 | log1s("packet with bad UDP checksum received, ignoring"); | 964 | log1s("packet with bad UDP checksum received, ignoring"); |
965 | return -2; | 965 | return -2; |
966 | } | 966 | } |
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 6d4375237..51374646d 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c | |||
@@ -164,14 +164,14 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, | |||
164 | packet.udp.len = htons(UDP_DHCP_SIZE - padding); | 164 | packet.udp.len = htons(UDP_DHCP_SIZE - padding); |
165 | /* for UDP checksumming, ip.len is set to UDP packet len */ | 165 | /* for UDP checksumming, ip.len is set to UDP packet len */ |
166 | packet.ip.tot_len = packet.udp.len; | 166 | packet.ip.tot_len = packet.udp.len; |
167 | packet.udp.check = inet_cksum((uint16_t *)&packet, | 167 | packet.udp.check = inet_cksum(&packet, |
168 | IP_UDP_DHCP_SIZE - padding); | 168 | IP_UDP_DHCP_SIZE - padding); |
169 | /* but for sending, it is set to IP packet len */ | 169 | /* but for sending, it is set to IP packet len */ |
170 | packet.ip.tot_len = htons(IP_UDP_DHCP_SIZE - padding); | 170 | packet.ip.tot_len = htons(IP_UDP_DHCP_SIZE - padding); |
171 | packet.ip.ihl = sizeof(packet.ip) >> 2; | 171 | packet.ip.ihl = sizeof(packet.ip) >> 2; |
172 | packet.ip.version = IPVERSION; | 172 | packet.ip.version = IPVERSION; |
173 | packet.ip.ttl = IPDEFTTL; | 173 | packet.ip.ttl = IPDEFTTL; |
174 | packet.ip.check = inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip)); | 174 | packet.ip.check = inet_cksum(&packet.ip, sizeof(packet.ip)); |
175 | 175 | ||
176 | udhcp_dump_packet(dhcp_pkt); | 176 | udhcp_dump_packet(dhcp_pkt); |
177 | result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0, | 177 | result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0, |