提交 cfcabdcc 编写于 作者: S Stephen Hemminger 提交者: David S. Miller

[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: NStephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 de83c058
...@@ -107,7 +107,7 @@ struct inet_hashinfo { ...@@ -107,7 +107,7 @@ struct inet_hashinfo {
*/ */
struct inet_bind_hashbucket *bhash; struct inet_bind_hashbucket *bhash;
int bhash_size; unsigned int bhash_size;
unsigned int ehash_size; unsigned int ehash_size;
/* All sockets in TCP_LISTEN state will be in here. This is the only /* All sockets in TCP_LISTEN state will be in here. This is the only
......
...@@ -485,17 +485,17 @@ static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb) ...@@ -485,17 +485,17 @@ static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb)
skb->next = NULL; skb->next = NULL;
} }
#define sk_wait_event(__sk, __timeo, __condition) \ #define sk_wait_event(__sk, __timeo, __condition) \
({ int rc; \ ({ int __rc; \
release_sock(__sk); \ release_sock(__sk); \
rc = __condition; \ __rc = __condition; \
if (!rc) { \ if (!__rc) { \
*(__timeo) = schedule_timeout(*(__timeo)); \ *(__timeo) = schedule_timeout(*(__timeo)); \
} \ } \
lock_sock(__sk); \ lock_sock(__sk); \
rc = __condition; \ __rc = __condition; \
rc; \ __rc; \
}) })
extern int sk_stream_wait_connect(struct sock *sk, long *timeo_p); extern int sk_stream_wait_connect(struct sock *sk, long *timeo_p);
extern int sk_stream_wait_memory(struct sock *sk, long *timeo_p); extern int sk_stream_wait_memory(struct sock *sk, long *timeo_p);
......
...@@ -822,8 +822,6 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -822,8 +822,6 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
* address. So as a precaution flush any * address. So as a precaution flush any
* entries we have for this address. * entries we have for this address.
*/ */
struct aarp_entry *a;
a = __aarp_find_entry(resolved[sa.s_node % a = __aarp_find_entry(resolved[sa.s_node %
(AARP_HASH_SIZE - 1)], (AARP_HASH_SIZE - 1)],
skb->dev, &sa); skb->dev, &sa);
......
...@@ -230,7 +230,7 @@ static void sigd_close(struct atm_vcc *vcc) ...@@ -230,7 +230,7 @@ static void sigd_close(struct atm_vcc *vcc)
struct hlist_head *head = &vcc_hash[i]; struct hlist_head *head = &vcc_hash[i];
sk_for_each(s, node, head) { sk_for_each(s, node, head) {
struct atm_vcc *vcc = atm_sk(s); vcc = atm_sk(s);
purge_vcc(vcc); purge_vcc(vcc);
} }
......
...@@ -780,7 +780,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf) ...@@ -780,7 +780,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
int i = 0; int i = 0;
const char *p; const char *p;
const int max_netdevices = 8*PAGE_SIZE; const int max_netdevices = 8*PAGE_SIZE;
long *inuse; unsigned long *inuse;
struct net_device *d; struct net_device *d;
p = strnchr(name, IFNAMSIZ-1, '%'); p = strnchr(name, IFNAMSIZ-1, '%');
...@@ -794,7 +794,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf) ...@@ -794,7 +794,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
return -EINVAL; return -EINVAL;
/* Use one page as a bit array of possible slots */ /* 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) if (!inuse)
return -ENOMEM; return -ENOMEM;
......
...@@ -1563,15 +1563,17 @@ static ssize_t pktgen_if_write(struct file *file, ...@@ -1563,15 +1563,17 @@ static ssize_t pktgen_if_write(struct file *file,
} }
if (!strcmp(name, "mpls")) { if (!strcmp(name, "mpls")) {
unsigned n, offset; unsigned n, cnt;
len = get_labels(&user_buffer[i], pkt_dev); len = get_labels(&user_buffer[i], pkt_dev);
if (len < 0) { return len; } if (len < 0)
return len;
i += len; i += len;
offset = sprintf(pg_result, "OK: mpls="); cnt = sprintf(pg_result, "OK: mpls=");
for (n = 0; n < pkt_dev->nr_labels; n++) for (n = 0; n < pkt_dev->nr_labels; n++)
offset += sprintf(pg_result + offset, cnt += sprintf(pg_result + cnt,
"%08x%s", ntohl(pkt_dev->labels[n]), "%08x%s", ntohl(pkt_dev->labels[n]),
n == pkt_dev->nr_labels-1 ? "" : ","); n == pkt_dev->nr_labels-1 ? "" : ",");
if (pkt_dev->nr_labels && pkt_dev->vlan_id != 0xffff) { if (pkt_dev->nr_labels && pkt_dev->vlan_id != 0xffff) {
pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */ pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */
...@@ -2731,6 +2733,7 @@ static unsigned int scan_ip6(const char *s, char ip[16]) ...@@ -2731,6 +2733,7 @@ static unsigned int scan_ip6(const char *s, char ip[16])
unsigned int prefixlen = 0; unsigned int prefixlen = 0;
unsigned int suffixlen = 0; unsigned int suffixlen = 0;
__be32 tmp; __be32 tmp;
char *pos;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
ip[i] = 0; ip[i] = 0;
...@@ -2745,12 +2748,9 @@ static unsigned int scan_ip6(const char *s, char ip[16]) ...@@ -2745,12 +2748,9 @@ static unsigned int scan_ip6(const char *s, char ip[16])
} }
s++; s++;
} }
{
char *tmp;
u = simple_strtoul(s, &tmp, 16);
i = tmp - s;
}
u = simple_strtoul(s, &pos, 16);
i = pos - s;
if (!i) if (!i)
return 0; return 0;
if (prefixlen == 12 && s[i] == '.') { if (prefixlen == 12 && s[i] == '.') {
...@@ -2778,11 +2778,9 @@ static unsigned int scan_ip6(const char *s, char ip[16]) ...@@ -2778,11 +2778,9 @@ static unsigned int scan_ip6(const char *s, char ip[16])
len++; len++;
} else if (suffixlen != 0) } else if (suffixlen != 0)
break; break;
{
char *tmp; u = simple_strtol(s, &pos, 16);
u = simple_strtol(s, &tmp, 16); i = pos - s;
i = tmp - s;
}
if (!i) { if (!i) {
if (*s) if (*s)
len--; len--;
......
...@@ -167,7 +167,8 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p) ...@@ -167,7 +167,8 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) 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; struct cmsghdr cmhdr;
int cmlen = CMSG_LEN(len); int cmlen = CMSG_LEN(len);
int err; int err;
...@@ -202,7 +203,8 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) ...@@ -202,7 +203,8 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm) 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 fdmax = 0;
int fdnum = scm->fp->count; int fdnum = scm->fp->count;
...@@ -222,7 +224,8 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm) ...@@ -222,7 +224,8 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
if (fdnum < fdmax) if (fdnum < fdmax)
fdmax = fdnum; 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; int new_fd;
err = security_file_receive(fp[i]); err = security_file_receive(fp[i]);
......
...@@ -1695,8 +1695,8 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode, ...@@ -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]); (void) ip_mc_del1_src(pmc, sfmode, &psfsrc[i]);
} else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) { } else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) {
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
struct in_device *in_dev = pmc->interface;
struct ip_sf_list *psf; struct ip_sf_list *psf;
in_dev = pmc->interface;
#endif #endif
/* filter mode change */ /* filter mode change */
...@@ -1799,7 +1799,7 @@ static int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml, ...@@ -1799,7 +1799,7 @@ static int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml,
{ {
int err; int err;
if (iml->sflist == 0) { if (iml->sflist == NULL) {
/* any-source empty exclude case */ /* any-source empty exclude case */
return ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr, return ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr,
iml->sfmode, 0, NULL, 0); iml->sfmode, 0, NULL, 0);
...@@ -2167,7 +2167,6 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf, ...@@ -2167,7 +2167,6 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
return -EFAULT; return -EFAULT;
} }
for (i=0; i<copycount; i++) { for (i=0; i<copycount; i++) {
struct sockaddr_in *psin;
struct sockaddr_storage ss; struct sockaddr_storage ss;
psin = (struct sockaddr_in *)&ss; psin = (struct sockaddr_in *)&ss;
......
...@@ -482,7 +482,7 @@ static struct sk_buff *__lro_proc_segment(struct net_lro_mgr *lro_mgr, ...@@ -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_init_desc(lro_desc, skb, iph, tcph, 0, NULL);
LRO_INC_STATS(lro_mgr, aggregated); LRO_INC_STATS(lro_mgr, aggregated);
return 0; return NULL;
} }
if (lro_desc->tcp_next_seq != ntohl(tcph->seq)) if (lro_desc->tcp_next_seq != ntohl(tcph->seq))
......
...@@ -659,7 +659,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -659,7 +659,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
break; break;
} }
msf = kmalloc(optlen, GFP_KERNEL); msf = kmalloc(optlen, GFP_KERNEL);
if (msf == 0) { if (!msf) {
err = -ENOBUFS; err = -ENOBUFS;
break; break;
} }
...@@ -816,7 +816,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -816,7 +816,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
break; break;
} }
gsf = kmalloc(optlen,GFP_KERNEL); gsf = kmalloc(optlen,GFP_KERNEL);
if (gsf == 0) { if (!gsf) {
err = -ENOBUFS; err = -ENOBUFS;
break; break;
} }
...@@ -836,7 +836,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -836,7 +836,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
} }
msize = IP_MSFILTER_SIZE(gsf->gf_numsrc); msize = IP_MSFILTER_SIZE(gsf->gf_numsrc);
msf = kmalloc(msize,GFP_KERNEL); msf = kmalloc(msize,GFP_KERNEL);
if (msf == 0) { if (!msf) {
err = -ENOBUFS; err = -ENOBUFS;
goto mc_msf_out; goto mc_msf_out;
} }
......
...@@ -144,7 +144,7 @@ static struct { ...@@ -144,7 +144,7 @@ static struct {
{ "TimestampReps", ICMP_TIMESTAMPREPLY }, { "TimestampReps", ICMP_TIMESTAMPREPLY },
{ "AddrMasks", ICMP_ADDRESS }, { "AddrMasks", ICMP_ADDRESS },
{ "AddrMaskReps", ICMP_ADDRESSREPLY }, { "AddrMaskReps", ICMP_ADDRESSREPLY },
{ 0, 0 } { NULL, 0 }
}; };
......
...@@ -246,7 +246,7 @@ static spinlock_t *rt_hash_locks; ...@@ -246,7 +246,7 @@ static spinlock_t *rt_hash_locks;
static struct rt_hash_bucket *rt_hash_table; static struct rt_hash_bucket *rt_hash_table;
static unsigned rt_hash_mask; static unsigned rt_hash_mask;
static int rt_hash_log; static unsigned int rt_hash_log;
static unsigned int rt_hash_rnd; static unsigned int rt_hash_rnd;
static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat); static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);
...@@ -593,7 +593,7 @@ static void rt_check_expire(struct work_struct *work) ...@@ -593,7 +593,7 @@ static void rt_check_expire(struct work_struct *work)
i = (i + 1) & rt_hash_mask; i = (i + 1) & rt_hash_mask;
rthp = &rt_hash_table[i].chain; rthp = &rt_hash_table[i].chain;
if (*rthp == 0) if (*rthp == NULL)
continue; continue;
spin_lock_bh(rt_hash_lock_addr(i)); spin_lock_bh(rt_hash_lock_addr(i));
while ((rth = *rthp) != NULL) { while ((rth = *rthp) != NULL) {
......
...@@ -2704,7 +2704,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, s32 *seq_rtt_p) ...@@ -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->lost_out >= 0);
BUG_TRAP((int)tp->retrans_out >= 0); BUG_TRAP((int)tp->retrans_out >= 0);
if (!tp->packets_out && tcp_is_sack(tp)) { 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) { if (tp->lost_out) {
printk(KERN_DEBUG "Leak l=%u %d\n", printk(KERN_DEBUG "Leak l=%u %d\n",
tp->lost_out, icsk->icsk_ca_state); tp->lost_out, icsk->icsk_ca_state);
......
...@@ -414,7 +414,7 @@ static int ipv6_chk_acast_dev(struct net_device *dev, struct in6_addr *addr) ...@@ -414,7 +414,7 @@ static int ipv6_chk_acast_dev(struct net_device *dev, struct in6_addr *addr)
break; break;
read_unlock_bh(&idev->lock); read_unlock_bh(&idev->lock);
in6_dev_put(idev); in6_dev_put(idev);
return aca != 0; return aca != NULL;
} }
return 0; return 0;
} }
......
...@@ -663,7 +663,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -663,7 +663,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
break; break;
} }
gsf = kmalloc(optlen,GFP_KERNEL); gsf = kmalloc(optlen,GFP_KERNEL);
if (gsf == 0) { if (!gsf) {
retv = -ENOBUFS; retv = -ENOBUFS;
break; break;
} }
......
...@@ -1407,7 +1407,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size) ...@@ -1407,7 +1407,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
/* we assume size > sizeof(ra) here */ /* we assume size > sizeof(ra) here */
skb = sock_alloc_send_skb(sk, size + LL_RESERVED_SPACE(dev), 1, &err); skb = sock_alloc_send_skb(sk, size + LL_RESERVED_SPACE(dev), 1, &err);
if (skb == 0) if (!skb)
return NULL; return NULL;
skb_reserve(skb, LL_RESERVED_SPACE(dev)); 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, ...@@ -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, /* 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 * so no other readers or writers of iml or its sflist
*/ */
if (iml->sflist == 0) { if (!iml->sflist) {
/* any-source empty exclude case */ /* any-source empty exclude case */
return ip6_mc_del_src(idev, &iml->addr, iml->sfmode, 0, NULL, 0); return ip6_mc_del_src(idev, &iml->addr, iml->sfmode, 0, NULL, 0);
} }
......
...@@ -256,7 +256,7 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, ...@@ -256,7 +256,7 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
break; break;
case ND_OPT_PREFIX_INFO: case ND_OPT_PREFIX_INFO:
ndopts->nd_opts_pi_end = nd_opt; 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; ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
break; break;
#ifdef CONFIG_IPV6_ROUTE_INFO #ifdef CONFIG_IPV6_ROUTE_INFO
......
...@@ -592,7 +592,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, ...@@ -592,7 +592,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
} else } else
handle = gen_new_kid(ht, htid); 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)) RTA_PAYLOAD(tb[TCA_U32_SEL-1]) < sizeof(struct tc_u32_sel))
return -EINVAL; return -EINVAL;
......
...@@ -1929,7 +1929,7 @@ asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg, ...@@ -1929,7 +1929,7 @@ asmlinkage long sys_recvmsg(int fd, struct msghdr __user *msg,
* kernel msghdr to use the kernel address space) * 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); uaddr_len = COMPAT_NAMELEN(msg);
if (MSG_CMSG_COMPAT & flags) { if (MSG_CMSG_COMPAT & flags) {
err = verify_compat_iovec(&msg_sys, iov, addr, VERIFY_WRITE); err = verify_compat_iovec(&msg_sys, iov, addr, VERIFY_WRITE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册