]> err.no Git - linux-2.6/commitdiff
[NET]: sparse warning fixes
authorStephen Hemminger <shemminger@linux-foundation.org>
Tue, 9 Oct 2007 08:59:42 +0000 (01:59 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:54:48 +0000 (16:54 -0700)
Fix a bunch of sparse warnings. Mostly about 0 used as
NULL pointer, and shadowed variable declarations.
One notable case was that hash size should have been unsigned.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
19 files changed:
include/net/inet_hashtables.h
include/net/sock.h
net/appletalk/aarp.c
net/atm/signaling.c
net/core/dev.c
net/core/pktgen.c
net/core/scm.c
net/ipv4/igmp.c
net/ipv4/inet_lro.c
net/ipv4/ip_sockglue.c
net/ipv4/proc.c
net/ipv4/route.c
net/ipv4/tcp_input.c
net/ipv6/anycast.c
net/ipv6/ipv6_sockglue.c
net/ipv6/mcast.c
net/ipv6/ndisc.c
net/sched/cls_u32.c
net/socket.c

index d27ee8c0da3f2cc5ac84f29a642118734eade381..8228b57eb18f544aebec20063b18c91ab5d1e323 100644 (file)
@@ -107,7 +107,7 @@ struct inet_hashinfo {
         */
        struct inet_bind_hashbucket     *bhash;
 
-       int                             bhash_size;
+       unsigned int                    bhash_size;
        unsigned int                    ehash_size;
 
        /* All sockets in TCP_LISTEN state will be in here.  This is the only
index 74e1f7d90d731104def058d74196d37f4761a33e..453c79d0915ba00ca8b33ff160ba64cb7c58a521 100644 (file)
@@ -485,17 +485,17 @@ static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb)
        skb->next = NULL;
 }
 
-#define sk_wait_event(__sk, __timeo, __condition)              \
-({     int rc;                                                 \
-       release_sock(__sk);                                     \
-       rc = __condition;                                       \
-       if (!rc) {                                              \
-               *(__timeo) = schedule_timeout(*(__timeo));      \
-       }                                                       \
-       lock_sock(__sk);                                        \
-       rc = __condition;                                       \
-       rc;                                                     \
-})
+#define sk_wait_event(__sk, __timeo, __condition)                      \
+       ({      int __rc;                                               \
+               release_sock(__sk);                                     \
+               __rc = __condition;                                     \
+               if (!__rc) {                                            \
+                       *(__timeo) = schedule_timeout(*(__timeo));      \
+               }                                                       \
+               lock_sock(__sk);                                        \
+               __rc = __condition;                                     \
+               __rc;                                                   \
+       })
 
 extern int sk_stream_wait_connect(struct sock *sk, long *timeo_p);
 extern int sk_stream_wait_memory(struct sock *sk, long *timeo_p);
index 92cd74973c97796e440ceefb93a1042fcefa7e76..6c5c6dc098ec3c34814202979d84ec4dcc951376 100644 (file)
@@ -822,8 +822,6 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
                                 * address. So as a precaution flush any
                                 * entries we have for this address.
                                 */
-                               struct aarp_entry *a;
-
                                a = __aarp_find_entry(resolved[sa.s_node %
                                                          (AARP_HASH_SIZE - 1)],
                                                      skb->dev, &sa);
index bced78b77f12c371ebe69b158fe760a9af03178c..22992140052290a92ef783a0ed6bbb9b5eafd861 100644 (file)
@@ -230,7 +230,7 @@ static void sigd_close(struct atm_vcc *vcc)
                struct hlist_head *head = &vcc_hash[i];
 
                sk_for_each(s, node, head) {
-                       struct atm_vcc *vcc = atm_sk(s);
+                       vcc = atm_sk(s);
 
                        purge_vcc(vcc);
                }
index d99864662582d20e33fa569a4126d3eb5ec31a1d..13a1bc5d3bfdf3ea0b4443d6997d66a542dd70e4 100644 (file)
@@ -780,7 +780,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
        int i = 0;
        const char *p;
        const int max_netdevices = 8*PAGE_SIZE;
-       long *inuse;
+       unsigned long *inuse;
        struct net_device *d;
 
        p = strnchr(name, IFNAMSIZ-1, '%');
@@ -794,7 +794,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
                        return -EINVAL;
 
                /* Use one page as a bit array of possible slots */
-               inuse = (long *) get_zeroed_page(GFP_ATOMIC);
+               inuse = (unsigned long *) get_zeroed_page(GFP_ATOMIC);
                if (!inuse)
                        return -ENOMEM;
 
index f07bd590f8f9f8c3b59027a1b811271f28227790..2100c734b102c9bde14ef3e86a362621996f37b9 100644 (file)
@@ -1563,15 +1563,17 @@ static ssize_t pktgen_if_write(struct file *file,
        }
 
        if (!strcmp(name, "mpls")) {
-               unsigned n, offset;
+               unsigned n, cnt;
+
                len = get_labels(&user_buffer[i], pkt_dev);
-               if (len < 0) { return len; }
+               if (len < 0)
+                       return len;
                i += len;
-               offset = sprintf(pg_result, "OK: mpls=");
+               cnt = sprintf(pg_result, "OK: mpls=");
                for (n = 0; n < pkt_dev->nr_labels; n++)
-                       offset += sprintf(pg_result + offset,
-                                         "%08x%s", ntohl(pkt_dev->labels[n]),
-                                         n == pkt_dev->nr_labels-1 ? "" : ",");
+                       cnt += sprintf(pg_result + cnt,
+                                      "%08x%s", ntohl(pkt_dev->labels[n]),
+                                      n == pkt_dev->nr_labels-1 ? "" : ",");
 
                if (pkt_dev->nr_labels && pkt_dev->vlan_id != 0xffff) {
                        pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */
@@ -2731,6 +2733,7 @@ static unsigned int scan_ip6(const char *s, char ip[16])
        unsigned int prefixlen = 0;
        unsigned int suffixlen = 0;
        __be32 tmp;
+       char *pos;
 
        for (i = 0; i < 16; i++)
                ip[i] = 0;
@@ -2745,12 +2748,9 @@ static unsigned int scan_ip6(const char *s, char ip[16])
                        }
                        s++;
                }
-               {
-                       char *tmp;
-                       u = simple_strtoul(s, &tmp, 16);
-                       i = tmp - s;
-               }
 
+               u = simple_strtoul(s, &pos, 16);
+               i = pos - s;
                if (!i)
                        return 0;
                if (prefixlen == 12 && s[i] == '.') {
@@ -2778,11 +2778,9 @@ static unsigned int scan_ip6(const char *s, char ip[16])
                        len++;
                } else if (suffixlen != 0)
                        break;
-               {
-                       char *tmp;
-                       u = simple_strtol(s, &tmp, 16);
-                       i = tmp - s;
-               }
+
+               u = simple_strtol(s, &pos, 16);
+               i = pos - s;
                if (!i) {
                        if (*s)
                                len--;
index 44c4ec2c8769b1a922d69a6f0e5882bc6f58f001..530bee8d9ed90448ee2b406b897ada19ec11d28c 100644 (file)
@@ -167,7 +167,8 @@ error:
 
 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
 {
-       struct cmsghdr __user *cm = (struct cmsghdr __user *)msg->msg_control;
+       struct cmsghdr __user *cm
+               = (__force struct cmsghdr __user *)msg->msg_control;
        struct cmsghdr cmhdr;
        int cmlen = CMSG_LEN(len);
        int err;
@@ -202,7 +203,8 @@ out:
 
 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
 {
-       struct cmsghdr __user *cm = (struct cmsghdr __user*)msg->msg_control;
+       struct cmsghdr __user *cm
+               = (__force struct cmsghdr __user*)msg->msg_control;
 
        int fdmax = 0;
        int fdnum = scm->fp->count;
@@ -222,7 +224,8 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
        if (fdnum < fdmax)
                fdmax = fdnum;
 
-       for (i=0, cmfptr=(int __user *)CMSG_DATA(cm); i<fdmax; i++, cmfptr++)
+       for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
+            i++, cmfptr++)
        {
                int new_fd;
                err = security_file_receive(fp[i]);
index ad500a43b3592aa76562e822f8a3b80d40176fc3..2b6e59c4c0d058acbc791111f11ba2d48d98476f 100644 (file)
@@ -1695,8 +1695,8 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
                        (void) ip_mc_del1_src(pmc, sfmode, &psfsrc[i]);
        } else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) {
 #ifdef CONFIG_IP_MULTICAST
-               struct in_device *in_dev = pmc->interface;
                struct ip_sf_list *psf;
+               in_dev = pmc->interface;
 #endif
 
                /* filter mode change */
@@ -1799,7 +1799,7 @@ static int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml,
 {
        int err;
 
-       if (iml->sflist == 0) {
+       if (iml->sflist == NULL) {
                /* any-source empty exclude case */
                return ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
                        iml->sfmode, 0, NULL, 0);
@@ -2167,7 +2167,6 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
                return -EFAULT;
        }
        for (i=0; i<copycount; i++) {
-               struct sockaddr_in *psin;
                struct sockaddr_storage ss;
 
                psin = (struct sockaddr_in *)&ss;
index 20bc593bb9631a44680845ec9600c078be68d516..4545b64e28151f76e2a7f301f87bc0c322a1829b 100644 (file)
@@ -482,7 +482,7 @@ static struct sk_buff *__lro_proc_segment(struct net_lro_mgr *lro_mgr,
 
                lro_init_desc(lro_desc, skb, iph, tcph, 0, NULL);
                LRO_INC_STATS(lro_mgr, aggregated);
-               return 0;
+               return NULL;
        }
 
        if (lro_desc->tcp_next_seq != ntohl(tcph->seq))
index b2b3053dfef75ebb214e7f2b111cc3b6eb54631a..f51f20e487c8c74ec078781790d35e7302ba6cb3 100644 (file)
@@ -659,7 +659,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                        break;
                }
                msf = kmalloc(optlen, GFP_KERNEL);
-               if (msf == 0) {
+               if (!msf) {
                        err = -ENOBUFS;
                        break;
                }
@@ -816,7 +816,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                        break;
                }
                gsf = kmalloc(optlen,GFP_KERNEL);
-               if (gsf == 0) {
+               if (!gsf) {
                        err = -ENOBUFS;
                        break;
                }
@@ -836,7 +836,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
                }
                msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
                msf = kmalloc(msize,GFP_KERNEL);
-               if (msf == 0) {
+               if (!msf) {
                        err = -ENOBUFS;
                        goto mc_msf_out;
                }
index 9dee70e1cf0d2a7de20f9fc4ff1d9214488ba7ae..e5b05b0391010956b914099ee01166c915c8d7df 100644 (file)
@@ -144,7 +144,7 @@ static struct {
        { "TimestampReps", ICMP_TIMESTAMPREPLY },
        { "AddrMasks", ICMP_ADDRESS },
        { "AddrMaskReps", ICMP_ADDRESSREPLY },
-       { 0, 0 }
+       { NULL, 0 }
 };
 
 
index 2a9b363e820cb0cebc85b892a7acda076ae8c1cc..307e1f1107ca846230742289121e5d73709b10b9 100644 (file)
@@ -246,7 +246,7 @@ static spinlock_t   *rt_hash_locks;
 
 static struct rt_hash_bucket   *rt_hash_table;
 static unsigned                        rt_hash_mask;
-static int                     rt_hash_log;
+static unsigned int            rt_hash_log;
 static unsigned int            rt_hash_rnd;
 
 static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);
@@ -593,7 +593,7 @@ static void rt_check_expire(struct work_struct *work)
                i = (i + 1) & rt_hash_mask;
                rthp = &rt_hash_table[i].chain;
 
-               if (*rthp == 0)
+               if (*rthp == NULL)
                        continue;
                spin_lock_bh(rt_hash_lock_addr(i));
                while ((rth = *rthp) != NULL) {
index 4268cd13ff9a2b3f0d3429ab229df978111f1b39..e8c39488cf58d7c87bf8045694f59202a4e036b1 100644 (file)
@@ -2704,7 +2704,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p)
        BUG_TRAP((int)tp->lost_out >= 0);
        BUG_TRAP((int)tp->retrans_out >= 0);
        if (!tp->packets_out && tcp_is_sack(tp)) {
-               const struct inet_connection_sock *icsk = inet_csk(sk);
+               icsk = inet_csk(sk);
                if (tp->lost_out) {
                        printk(KERN_DEBUG "Leak l=%u %d\n",
                               tp->lost_out, icsk->icsk_ca_state);
index d407992c1481b27248a3e1c31f7d8d35c72b8edb..5810852c558a7d48d44a4a74b04f0779a466e3a1 100644 (file)
@@ -414,7 +414,7 @@ static int ipv6_chk_acast_dev(struct net_device *dev, struct in6_addr *addr)
                                break;
                read_unlock_bh(&idev->lock);
                in6_dev_put(idev);
-               return aca != 0;
+               return aca != NULL;
        }
        return 0;
 }
index eb330a44bacdf48d3fd03b720d4d33347bd3b016..532425db11fea7729952ac239dfebbf3d9bf3b08 100644 (file)
@@ -663,7 +663,7 @@ done:
                        break;
                }
                gsf = kmalloc(optlen,GFP_KERNEL);
-               if (gsf == 0) {
+               if (!gsf) {
                        retv = -ENOBUFS;
                        break;
                }
index 8668ab3af32e9c613c14bfb6fea16a0adb6b4fee..cc8d4e2a9531268526c33f5989791696ec487288 100644 (file)
@@ -1407,7 +1407,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
        /* we assume size > sizeof(ra) here */
        skb = sock_alloc_send_skb(sk, size + LL_RESERVED_SPACE(dev), 1, &err);
 
-       if (skb == 0)
+       if (!skb)
                return NULL;
 
        skb_reserve(skb, LL_RESERVED_SPACE(dev));
@@ -2144,7 +2144,7 @@ static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
        /* callers have the socket lock and a write lock on ipv6_sk_mc_lock,
         * so no other readers or writers of iml or its sflist
         */
-       if (iml->sflist == 0) {
+       if (!iml->sflist) {
                /* any-source empty exclude case */
                return ip6_mc_del_src(idev, &iml->addr, iml->sfmode, 0, NULL, 0);
        }
index b761dbed8cec132f0436be2ee7def72f34a7c6fe..d4acd283111bab6cd32bc7a3653d28f89d64f669 100644 (file)
@@ -256,7 +256,7 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
                        break;
                case ND_OPT_PREFIX_INFO:
                        ndopts->nd_opts_pi_end = nd_opt;
-                       if (ndopts->nd_opt_array[nd_opt->nd_opt_type] == 0)
+                       if (!ndopts->nd_opt_array[nd_opt->nd_opt_type])
                                ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
                        break;
 #ifdef CONFIG_IPV6_ROUTE_INFO
index d4d5d2f271d2f77f17fc7dbfd605cbbe3ab14f5a..9e98c6e567dde518ba28b29ed7211cb6baac19de 100644 (file)
@@ -592,7 +592,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
        } else
                handle = gen_new_kid(ht, htid);
 
-       if (tb[TCA_U32_SEL-1] == 0 ||
+       if (tb[TCA_U32_SEL-1] == NULL ||
            RTA_PAYLOAD(tb[TCA_U32_SEL-1]) < sizeof(struct tc_u32_sel))
                return -EINVAL;
 
index bc16eee4dc80b97041864f5805f7fbc57fa51b95..d2336472f4943bea9fb5547b6dc7b2d67a396334 100644 (file)
@@ -1929,7 +1929,7 @@ asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg,
         *      kernel msghdr to use the kernel address space)
         */
 
-       uaddr = (void __user *)msg_sys.msg_name;
+       uaddr = (__force void __user *)msg_sys.msg_name;
        uaddr_len = COMPAT_NAMELEN(msg);
        if (MSG_CMSG_COMPAT & flags) {
                err = verify_compat_iovec(&msg_sys, iov, addr, VERIFY_WRITE);