gcc-9.x warning fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
aaa0709e7b
commit
4a0eb0370c
@ -297,7 +297,8 @@ static void writeLongname(int fd, int type, const char *name, int dir)
|
||||
header.typeflag = type;
|
||||
strcpy(header.name, "././@LongLink");
|
||||
/* This sets mode/uid/gid/mtime to "00...00<NUL>" strings */
|
||||
memset(header.mode, '0', sizeof(struct prefilled));
|
||||
memset((char*)&header + offsetof(struct tar_header_t, mode), /* make gcc-9.x happy */
|
||||
'0', sizeof(struct prefilled));
|
||||
header.mode [sizeof(header.mode ) - 1] = '\0';
|
||||
header.uid [sizeof(header.uid ) - 1] = '\0';
|
||||
header.gid [sizeof(header.gid ) - 1] = '\0';
|
||||
|
@ -818,7 +818,7 @@ ssize_t recv_from_to(int fd, void *buf, size_t len, int flags,
|
||||
struct sockaddr *to,
|
||||
socklen_t sa_size) FAST_FUNC;
|
||||
|
||||
uint16_t inet_cksum(uint16_t *addr, int len) FAST_FUNC;
|
||||
uint16_t inet_cksum(const void *addr, int len) FAST_FUNC;
|
||||
int parse_pasv_epsv(char *buf) FAST_FUNC;
|
||||
|
||||
/* 0 if argv[0] is NULL: */
|
||||
|
@ -6,8 +6,10 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
uint16_t FAST_FUNC inet_cksum(uint16_t *addr, int nleft)
|
||||
uint16_t FAST_FUNC inet_cksum(const void *ptr, int nleft)
|
||||
{
|
||||
const uint16_t *addr = ptr;
|
||||
|
||||
/*
|
||||
* Our algorithm is simple, using a 32 bit accumulator,
|
||||
* we add sequential 16 bit words to it, and at the end, fold
|
||||
|
@ -217,7 +217,7 @@ static void ping4(len_and_sockaddr *lsa)
|
||||
/*memset(pkt, 0, sizeof(G.packet)); already is */
|
||||
pkt->icmp_type = ICMP_ECHO;
|
||||
pkt->icmp_id = G.myid;
|
||||
pkt->icmp_cksum = inet_cksum((uint16_t *) pkt, sizeof(G.packet));
|
||||
pkt->icmp_cksum = inet_cksum(pkt, sizeof(G.packet));
|
||||
|
||||
xsendto(pingsock, G.packet, DEFDATALEN + ICMP_MINLEN, &lsa->u.sa, lsa->len);
|
||||
|
||||
@ -529,7 +529,7 @@ static void sendping4(int junk UNUSED_PARAM)
|
||||
/* No hton: we'll read it back on the same machine */
|
||||
*(uint32_t*)&pkt->icmp_dun = G.cur_us = monotonic_us();
|
||||
|
||||
pkt->icmp_cksum = inet_cksum((uint16_t *) pkt, datalen + ICMP_MINLEN);
|
||||
pkt->icmp_cksum = inet_cksum(pkt, datalen + ICMP_MINLEN);
|
||||
|
||||
sendping_tail(sendping4, ICMP_MINLEN);
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ send_probe(int seq, int ttl)
|
||||
/* Always calculate checksum for icmp packets */
|
||||
outicmp->icmp_cksum = 0;
|
||||
outicmp->icmp_cksum = inet_cksum(
|
||||
(uint16_t *)outicmp,
|
||||
outicmp,
|
||||
((char*)outip + packlen) - (char*)outicmp
|
||||
);
|
||||
if (outicmp->icmp_cksum == 0)
|
||||
|
@ -947,7 +947,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac
|
||||
// packet.ip.tot_len = packet.udp.len; /* yes, this is needed */
|
||||
// check = packet.udp.check;
|
||||
// packet.udp.check = 0;
|
||||
// if (check && check != inet_cksum((uint16_t *)&packet, bytes)) {
|
||||
// if (check && check != inet_cksum(&packet, bytes)) {
|
||||
// log1("packet with bad UDP checksum received, ignoring");
|
||||
// return -2;
|
||||
// }
|
||||
|
@ -103,7 +103,7 @@ int FAST_FUNC d6_send_raw_packet(
|
||||
*/
|
||||
packet.ip6.ip6_hlim = IPPROTO_UDP;
|
||||
packet.udp.check = inet_cksum(
|
||||
(uint16_t *)&packet + 2,
|
||||
(uint8_t *)&packet + 4,
|
||||
offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size
|
||||
);
|
||||
/* fix 'hop limit' and 'next header' after UDP checksumming */
|
||||
|
@ -935,7 +935,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
|
||||
/* verify IP checksum */
|
||||
check = packet.ip.check;
|
||||
packet.ip.check = 0;
|
||||
if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) {
|
||||
if (check != inet_cksum(&packet.ip, sizeof(packet.ip))) {
|
||||
log1s("bad IP header checksum, ignoring");
|
||||
return -2;
|
||||
}
|
||||
@ -960,7 +960,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
|
||||
packet.ip.tot_len = packet.udp.len; /* yes, this is needed */
|
||||
check = packet.udp.check;
|
||||
packet.udp.check = 0;
|
||||
if (check && check != inet_cksum((uint16_t *)&packet, bytes)) {
|
||||
if (check && check != inet_cksum(&packet, bytes)) {
|
||||
log1s("packet with bad UDP checksum received, ignoring");
|
||||
return -2;
|
||||
}
|
||||
|
@ -164,14 +164,14 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
|
||||
packet.udp.len = htons(UDP_DHCP_SIZE - padding);
|
||||
/* for UDP checksumming, ip.len is set to UDP packet len */
|
||||
packet.ip.tot_len = packet.udp.len;
|
||||
packet.udp.check = inet_cksum((uint16_t *)&packet,
|
||||
packet.udp.check = inet_cksum(&packet,
|
||||
IP_UDP_DHCP_SIZE - padding);
|
||||
/* but for sending, it is set to IP packet len */
|
||||
packet.ip.tot_len = htons(IP_UDP_DHCP_SIZE - padding);
|
||||
packet.ip.ihl = sizeof(packet.ip) >> 2;
|
||||
packet.ip.version = IPVERSION;
|
||||
packet.ip.ttl = IPDEFTTL;
|
||||
packet.ip.check = inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip));
|
||||
packet.ip.check = inet_cksum(&packet.ip, sizeof(packet.ip));
|
||||
|
||||
udhcp_dump_packet(dhcp_pkt);
|
||||
result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0,
|
||||
|
Loading…
Reference in New Issue
Block a user