aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-10-09 01:59:42 -0700
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 16:54:48 -0700
commitcfcabdcc2d5a810208e5bb3974121b7ed60119aa (patch)
tree1aed711eeecc5a303b57f1fc47e1b5746e8a72c2 /net
parentde83c058af25aa97ed4864abab11e90e8dead6e2 (diff)
[NET]: sparse warning fixes
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>
Diffstat (limited to 'net')
-rw-r--r--net/appletalk/aarp.c2
-rw-r--r--net/atm/signaling.c2
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/pktgen.c30
-rw-r--r--net/core/scm.c9
-rw-r--r--net/ipv4/igmp.c5
-rw-r--r--net/ipv4/inet_lro.c2
-rw-r--r--net/ipv4/ip_sockglue.c6
-rw-r--r--net/ipv4/proc.c2
-rw-r--r--net/ipv4/route.c4
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv6/anycast.c2
-rw-r--r--net/ipv6/ipv6_sockglue.c2
-rw-r--r--net/ipv6/mcast.c4
-rw-r--r--net/ipv6/ndisc.c2
-rw-r--r--net/sched/cls_u32.c2
-rw-r--r--net/socket.c2
17 files changed, 40 insertions, 42 deletions
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index 92cd74973c9..6c5c6dc098e 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -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);
diff --git a/net/atm/signaling.c b/net/atm/signaling.c
index bced78b77f1..22992140052 100644
--- a/net/atm/signaling.c
+++ b/net/atm/signaling.c
@@ -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);
}
diff --git a/net/core/dev.c b/net/core/dev.c
index d9986466258..13a1bc5d3bf 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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;
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index f07bd590f8f..2100c734b10 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -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--;
diff --git a/net/core/scm.c b/net/core/scm.c
index 44c4ec2c876..530bee8d9ed 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -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]);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index ad500a43b35..2b6e59c4c0d 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -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;
diff --git a/net/ipv4/inet_lro.c b/net/ipv4/inet_lro.c
index 20bc593bb96..4545b64e281 100644
--- a/net/ipv4/inet_lro.c
+++ b/net/ipv4/inet_lro.c
@@ -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))
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index b2b3053dfef..f51f20e487c 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -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;
}
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 9dee70e1cf0..e5b05b03910 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -144,7 +144,7 @@ static struct {
{ "TimestampReps", ICMP_TIMESTAMPREPLY },
{ "AddrMasks", ICMP_ADDRESS },
{ "AddrMaskReps", ICMP_ADDRESSREPLY },
- { 0, 0 }
+ { NULL, 0 }
};
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 2a9b363e820..307e1f1107c 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -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) {
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 4268cd13ff9..e8c39488cf5 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -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);
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index d407992c148..5810852c558 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -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;
}
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index eb330a44bac..532425db11f 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -663,7 +663,7 @@ done:
break;
}
gsf = kmalloc(optlen,GFP_KERNEL);
- if (gsf == 0) {
+ if (!gsf) {
retv = -ENOBUFS;
break;
}
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 8668ab3af32..cc8d4e2a953 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -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);
}
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index b761dbed8ce..d4acd283111 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -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
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index d4d5d2f271d..9e98c6e567d 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -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;
diff --git a/net/socket.c b/net/socket.c
index bc16eee4dc8..d2336472f49 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -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);