From: shemminger Date: Tue, 5 Jul 2005 22:37:15 +0000 (+0000) Subject: Cleanup GCC4 warnings about signedness. X-Git-Tag: ss-050808~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f332d169246447bd5e258ac03d5ee840a70adb1e;p=thirdparty%2Fiproute2.git Cleanup GCC4 warnings about signedness. --- diff --git a/include/rt_names.h b/include/rt_names.h index 249231e8d..2d9ef1019 100644 --- a/include/rt_names.h +++ b/include/rt_names.h @@ -21,7 +21,7 @@ int inet_proto_a2n(char *buf); const char * ll_type_n2a(int type, char *buf, int len); const char *ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen); -int ll_addr_a2n(unsigned char *lladdr, int len, char *arg); +int ll_addr_a2n(char *lladdr, int len, char *arg); const char * ll_proto_n2a(unsigned short id, char *buf, int len); int ll_proto_a2n(unsigned short *id, char *buf); diff --git a/include/utils.h b/include/utils.h index 1e3dc2850..a78ae03a4 100644 --- a/include/utils.h +++ b/include/utils.h @@ -86,8 +86,8 @@ extern int get_s16(__s16 *val, const char *arg, int base); extern int get_u8(__u8 *val, const char *arg, int base); extern int get_s8(__s8 *val, const char *arg, int base); -extern __u8* hexstring_n2a(const __u8 *str, int len, __u8 *buf, int blen); -extern __u8* hexstring_a2n(const __u8 *str, __u8 *buf, int blen); +extern char* hexstring_n2a(const __u8 *str, int len, char *buf, int blen); +extern __u8* hexstring_a2n(const char *str, __u8 *buf, int blen); extern const char *format_host(int af, int len, const void *addr, char *buf, int buflen); diff --git a/ip/ipaddress.c b/ip/ipaddress.c index e8405f794..8e90c7018 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -524,7 +524,7 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush) if (filter.family == AF_UNSPEC) filter.family = filter.pfx.family; } else if (strcmp(*argv, "scope") == 0) { - int scope = 0; + unsigned scope = 0; NEXT_ARG(); filter.scopemask = -1; if (rtnl_rtscope_a2n(&scope, *argv)) { @@ -801,7 +801,7 @@ int ipaddr_modify(int cmd, int argc, char **argv) addattr_l(&req.n, sizeof(req), IFA_ANYCAST, &addr.data, addr.bytelen); any_len = addr.bytelen; } else if (strcmp(*argv, "scope") == 0) { - int scope = 0; + unsigned scope = 0; NEXT_ARG(); if (rtnl_rtscope_a2n(&scope, *argv)) invarg(*argv, "invalid scope value."); diff --git a/ip/iplink.c b/ip/iplink.c index 520280ed8..77b1eeaef 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -178,7 +178,7 @@ static int get_address(const char *dev, int *htype) { struct ifreq ifr; struct sockaddr_ll me; - int alen; + socklen_t alen; int s; s = socket(PF_PACKET, SOCK_DGRAM, 0); diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c index 1cdab0b0a..e6bd62541 100644 --- a/ip/ipmaddr.c +++ b/ip/ipmaddr.c @@ -298,7 +298,8 @@ int multiaddr_modify(int cmd, int argc, char **argv) usage(); if (ifr.ifr_hwaddr.sa_data[0]) duparg("address", *argv); - if (ll_addr_a2n(ifr.ifr_hwaddr.sa_data, 14, *argv) < 0) { + if (ll_addr_a2n(ifr.ifr_hwaddr.sa_data, + 14, *argv) < 0) { fprintf(stderr, "Error: \"%s\" is not a legal ll address.\n", *argv); exit(1); } diff --git a/ip/iproute.c b/ip/iproute.c index 510117837..26298424d 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -726,7 +726,7 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv) invarg("\"metric\" value is invalid\n", *argv); addattr32(&req.n, sizeof(req), RTA_PRIORITY, metric); } else if (strcmp(*argv, "scope") == 0) { - int scope = 0; + __u32 scope = 0; NEXT_ARG(); if (rtnl_rtscope_a2n(&scope, *argv)) invarg("invalid \"scope\" value\n", *argv); @@ -831,14 +831,14 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv) nhs_ok = 1; break; } else if (matches(*argv, "protocol") == 0) { - int prot; + __u32 prot; NEXT_ARG(); if (rtnl_rtprot_a2n(&prot, *argv)) invarg("\"protocol\" value is invalid\n", *argv); req.r.rtm_protocol = prot; proto_ok =1; } else if (matches(*argv, "table") == 0) { - int tid; + __u32 tid; NEXT_ARG(); if (rtnl_rttable_a2n(&tid, *argv)) invarg("\"table\" value is invalid\n", *argv); @@ -1012,7 +1012,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) while (argc > 0) { if (matches(*argv, "table") == 0) { - int tid; + __u32 tid; NEXT_ARG(); if (rtnl_rttable_a2n(&tid, *argv)) { if (strcmp(*argv, "all") == 0) { @@ -1038,7 +1038,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) filter.tos = tos; filter.tosmask = -1; } else if (matches(*argv, "protocol") == 0) { - int prot = 0; + __u32 prot = 0; NEXT_ARG(); filter.protocolmask = -1; if (rtnl_rtprot_a2n(&prot, *argv)) { @@ -1049,7 +1049,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) } filter.protocol = prot; } else if (matches(*argv, "scope") == 0) { - int scope = 0; + __u32 scope = 0; NEXT_ARG(); filter.scopemask = -1; if (rtnl_rtscope_a2n(&scope, *argv)) { diff --git a/ip/iprule.c b/ip/iprule.c index 764edc87c..0ad0d3657 100644 --- a/ip/iprule.c +++ b/ip/iprule.c @@ -256,7 +256,7 @@ static int iprule_modify(int cmd, int argc, char **argv) addattr32(&req.n, sizeof(req), RTA_FLOW, realm); } else if (matches(*argv, "table") == 0 || strcmp(*argv, "lookup") == 0) { - int tid; + __u32 tid; NEXT_ARG(); if (rtnl_rttable_a2n(&tid, *argv)) invarg("invalid table ID\n", *argv); diff --git a/lib/libnetlink.c b/lib/libnetlink.c index 6ec2509af..f7e89059a 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -32,7 +32,7 @@ void rtnl_close(struct rtnl_handle *rth) int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, int protocol) { - int addr_len; + socklen_t addr_len; int sndbuf = 32768; int rcvbuf = 32768; diff --git a/lib/ll_addr.c b/lib/ll_addr.c index ea3d66092..581487dfa 100644 --- a/lib/ll_addr.c +++ b/lib/ll_addr.c @@ -53,7 +53,8 @@ const char *ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int return buf; } -int ll_addr_a2n(unsigned char *lladdr, int len, char *arg) +/*NB: lladdr is char * (rather than u8 *) because sa_data is char * (1003.1g) */ +int ll_addr_a2n(char *lladdr, int len, char *arg) { if (strchr(arg, '.')) { inet_prefix pfx; diff --git a/lib/utils.c b/lib/utils.c index 5954502f5..7d336eb7e 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -240,7 +240,7 @@ int get_prefix_1(inet_prefix *dst, char *arg, int family) dst->bitlen = 32; } if (slash) { - if (get_integer(&plen, slash+1, 0) || plen > dst->bitlen) { + if (get_unsigned(&plen, slash+1, 0) || plen > dst->bitlen) { err = -1; goto done; } @@ -504,9 +504,9 @@ const char *format_host(int af, int len, const void *addr, } -__u8* hexstring_n2a(const __u8 *str, int len, __u8 *buf, int blen) +char *hexstring_n2a(const __u8 *str, int len, char *buf, int blen) { - __u8 *ptr = buf; + char *ptr = buf; int i; for (i=0; iiface)) { if (!IS_NEG(dbdat.data)) { - __u8 b1[18]; + char b1[18]; printf("%-8d %-15s %s\n", key->iface, inet_ntoa(*(struct in_addr*)&key->addr), diff --git a/tc/m_ematch.c b/tc/m_ematch.c index d02733cb5..37ef04597 100644 --- a/tc/m_ematch.c +++ b/tc/m_ematch.c @@ -120,6 +120,7 @@ static int lookup_map_id(char *kind, int *dst, const char *file) } err = -ENOENT; + *dst = 0; out: fclose(fd); return err; diff --git a/tc/m_ematch.h b/tc/m_ematch.h index 72437caad..67db7519f 100644 --- a/tc/m_ematch.h +++ b/tc/m_ematch.h @@ -10,7 +10,7 @@ struct bstr { - unsigned char *data; + char *data; unsigned int len; int quoted; struct bstr *next; @@ -53,7 +53,7 @@ static inline int bstrcmp(struct bstr *b, const char *text) int d = b->len - len; if (d == 0) - return strncmp((char *) b->data, text, len); + return strncmp(b->data, text, len); return d; } @@ -77,7 +77,7 @@ static inline unsigned long bstrtoul(struct bstr *b) static inline void bstr_print(FILE *fd, struct bstr *b, int ascii) { int i; - char *s = (char *) b->data; + char *s = b->data; if (ascii) for (i = 0; i < b->len; i++) diff --git a/tc/m_pedit.c b/tc/m_pedit.c index 5031c62ef..acfa58198 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -238,9 +238,11 @@ parse_val(int *argc_p, char ***argv_p, __u32 * val, int type) return -1; if (TINT == type) - return get_integer(val, *argv, 0); + return get_integer((int *) val, *argv, 0); + if (TU32 == type) return get_u32(val, *argv, 0); + if (TIPV4 == type) { inet_prefix addr; if (get_prefix_1(&addr, *argv, AF_INET)) { diff --git a/tc/q_cbq.c b/tc/q_cbq.c index 40c02284e..a456eda96 100644 --- a/tc/q_cbq.c +++ b/tc/q_cbq.c @@ -70,7 +70,7 @@ static int cbq_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl } } else if (strcmp(*argv, "ewma") == 0) { NEXT_ARG(); - if (get_unsigned(&ewma_log, *argv, 0)) { + if (get_integer(&ewma_log, *argv, 0)) { explain1("ewma"); return -1; } @@ -236,7 +236,7 @@ static int cbq_parse_class_opt(struct qdisc_util *qu, int argc, char **argv, str lss.change |= TCF_CBQ_LSS_FLAGS; } else if (strcmp(*argv, "ewma") == 0) { NEXT_ARG(); - if (get_u32(&ewma_log, *argv, 0)) { + if (get_integer(&ewma_log, *argv, 0)) { explain1("ewma"); return -1; } diff --git a/tc/tc.c b/tc/tc.c index 31e9fa306..f122143c5 100644 --- a/tc/tc.c +++ b/tc/tc.c @@ -244,7 +244,7 @@ static size_t getcmdline(char **linep, size_t *lenp, FILE *in) while ((cp = strstr(*linep, "\\\n")) != NULL) { char *line1 = NULL; - ssize_t len1 = 0; + size_t len1 = 0; size_t cc1; if ((cc1 = getline(&line1, &len1, in)) < 0) {