]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
Cleanup GCC4 warnings about signedness.
authorshemminger <shemminger>
Tue, 5 Jul 2005 22:37:15 +0000 (22:37 +0000)
committershemminger <shemminger>
Tue, 5 Jul 2005 22:37:15 +0000 (22:37 +0000)
16 files changed:
include/rt_names.h
include/utils.h
ip/ipaddress.c
ip/iplink.c
ip/ipmaddr.c
ip/iproute.c
ip/iprule.c
lib/libnetlink.c
lib/ll_addr.c
lib/utils.c
misc/arpd.c
tc/m_ematch.c
tc/m_ematch.h
tc/m_pedit.c
tc/q_cbq.c
tc/tc.c

index 249231e8dce0a8c0ed955b92e7d9ff0fbde2f243..2d9ef1019c5cd917ab4a0e145c0eea1602257aa1 100644 (file)
@@ -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);
index 1e3dc28504f04b210914ebc8b974c6d187687e1a..a78ae03a464962488dca56cd013545f2253e647d 100644 (file)
@@ -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);
index e8405f794cdbe22d766874e4a26c33ed5c2e9c9b..8e90c7018e9478a5daf64376dc451a98364c769f 100644 (file)
@@ -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.");
index 520280ed8aafb8aec1dae8ee31fcc54202801329..77b1eeaef75a76984d8ed38a1b1609ef19c788d1 100644 (file)
@@ -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);
index 1cdab0b0a12f20ddc7e0cd0d0015d5014a52c10e..e6bd62541fe94115cd759b042c8b7c75577cd018 100644 (file)
@@ -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);
                        }
index 510117837a5b0a6088a7d72a2674c83b1cc33602..26298424d52a364fd5a2e6242268d8b14a3b25a8 100644 (file)
@@ -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)) {
index 764edc87c97e8d7e6acb1c9f8a7d63b6d6817198..0ad0d3657df936ae347062f7a7446955d0c902d7 100644 (file)
@@ -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);
index 6ec2509afbeb598a7617a897c1362721f7adb0e8..f7e89059ad2cc780554bc8053ceb0a0501c83d98 100644 (file)
@@ -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;
 
index ea3d66092824373621d0b8551cfb3b7929930bdb..581487dfaff0f3e620ea0eed036431a4d6aa70cb 100644 (file)
@@ -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;
index 5954502f5005f16ce50594e9040bfb1d9db97d64..7d336eb7e0b7cca72dcab1b092b0c83f4bc5fb07 100644 (file)
@@ -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; i<len; i++) {
@@ -523,7 +523,7 @@ __u8* hexstring_n2a(const __u8 *str, int len, __u8 *buf, int blen)
        return buf;
 }
 
-__u8* hexstring_a2n(const __u8 *str, __u8 *buf, int blen)
+__u8* hexstring_a2n(const char *str, __u8 *buf, int blen)
 {
        int cnt = 0;
 
index 85b2a1cc1ede38053304e64c03ee92fdabb3a739..4fd226ec85c748a2b82be2ee2c1787a03df63f26 100644 (file)
@@ -180,7 +180,7 @@ int send_probe(int ifindex, __u32 addr)
 {
        struct ifreq ifr;
        struct sockaddr_in dst;
-       int len;
+       socklen_t len;
        unsigned char buf[256];
        struct arphdr *ah = (struct arphdr*)buf;
        unsigned char *p = (unsigned char *)(ah+1);
@@ -228,8 +228,7 @@ int send_probe(int ifindex, __u32 addr)
        memcpy(p, &addr, 4);
        p+=4;
 
-       len = sendto(pset[0].fd, buf, p-buf, 0, (struct sockaddr*)&sll, sizeof(sll));
-       if (len < 0)
+       if (sendto(pset[0].fd, buf, p-buf, 0, (struct sockaddr*)&sll, sizeof(sll)) < 0)
                return -1;
        stats.probes_sent++;
        return 0;
@@ -480,13 +479,14 @@ void get_arp_pkt(void)
 {
        unsigned char buf[1024];
        struct sockaddr_ll sll;
-       int sll_len = sizeof(sll);
+       socklen_t sll_len = sizeof(sll);
        struct arphdr *a = (struct arphdr*)buf;
        struct dbkey key;
        DBT dbkey, dbdat;
        int n;
 
-       n = recvfrom(pset[0].fd, buf, sizeof(buf), MSG_DONTWAIT, (struct sockaddr*)&sll, &sll_len);
+       n = recvfrom(pset[0].fd, buf, sizeof(buf), MSG_DONTWAIT, 
+                    (struct sockaddr*)&sll, &sll_len);
        if (n < 0) {
                if (errno != EINTR && errno != EAGAIN)
                        syslog(LOG_ERR, "recvfrom: %m");
@@ -708,6 +708,7 @@ int main(int argc, char **argv)
                                fprintf(stderr, "Invalid IP address: \"%s\"\n", ipbuf);
                                goto do_abort;
                        }
+
                        dbdat.data = hexstring_a2n(macbuf, b1, 6);
                        if (dbdat.data == NULL)
                                goto do_abort;
@@ -730,7 +731,7 @@ int main(int argc, char **argv)
                        struct dbkey *key = dbkey.data; 
                        if (handle_if(key->iface)) {
                                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),
index d02733cb522aaf93606c26eca570f15bbac9a87b..37ef0459763d35b2007c82285a64100dfaca80ad 100644 (file)
@@ -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;
index 72437caad25143cbe9e41d0903813d68dd00695d..67db7519f32805c9622fbef9b405458b903b9355 100644 (file)
@@ -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++)
index 5031c62ef32083d2bfa8447e2ee5206ec72176ae..acfa581980712af0d112ebb62ea1b8db4203d39d 100644 (file)
@@ -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)) {
index 40c02284e5838f194d29c134579ee5811cdb84f0..a456eda968cde13c18711d3d5955ae1515705ab5 100644 (file)
@@ -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 31e9fa3062356034850a483bf724fb4f99b2957d..f122143c5a81047d90a388d8014329dc0e54d0bf 100644 (file)
--- 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) {