diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-10-09 04:59:42 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:54:48 -0400 |
commit | cfcabdcc2d5a810208e5bb3974121b7ed60119aa (patch) | |
tree | 1aed711eeecc5a303b57f1fc47e1b5746e8a72c2 /net/core | |
parent | de83c058af25aa97ed4864abab11e90e8dead6e2 (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/core')
-rw-r--r-- | net/core/dev.c | 4 | ||||
-rw-r--r-- | net/core/pktgen.c | 30 | ||||
-rw-r--r-- | net/core/scm.c | 9 |
3 files changed, 22 insertions, 21 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index d99864662582..13a1bc5d3bfd 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) | |||
780 | int i = 0; | 780 | int i = 0; |
781 | const char *p; | 781 | const char *p; |
782 | const int max_netdevices = 8*PAGE_SIZE; | 782 | const int max_netdevices = 8*PAGE_SIZE; |
783 | long *inuse; | 783 | unsigned long *inuse; |
784 | struct net_device *d; | 784 | struct net_device *d; |
785 | 785 | ||
786 | p = strnchr(name, IFNAMSIZ-1, '%'); | 786 | p = strnchr(name, IFNAMSIZ-1, '%'); |
@@ -794,7 +794,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf) | |||
794 | return -EINVAL; | 794 | return -EINVAL; |
795 | 795 | ||
796 | /* Use one page as a bit array of possible slots */ | 796 | /* Use one page as a bit array of possible slots */ |
797 | inuse = (long *) get_zeroed_page(GFP_ATOMIC); | 797 | inuse = (unsigned long *) get_zeroed_page(GFP_ATOMIC); |
798 | if (!inuse) | 798 | if (!inuse) |
799 | return -ENOMEM; | 799 | return -ENOMEM; |
800 | 800 | ||
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index f07bd590f8f9..2100c734b102 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -1563,15 +1563,17 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1563 | } | 1563 | } |
1564 | 1564 | ||
1565 | if (!strcmp(name, "mpls")) { | 1565 | if (!strcmp(name, "mpls")) { |
1566 | unsigned n, offset; | 1566 | unsigned n, cnt; |
1567 | |||
1567 | len = get_labels(&user_buffer[i], pkt_dev); | 1568 | len = get_labels(&user_buffer[i], pkt_dev); |
1568 | if (len < 0) { return len; } | 1569 | if (len < 0) |
1570 | return len; | ||
1569 | i += len; | 1571 | i += len; |
1570 | offset = sprintf(pg_result, "OK: mpls="); | 1572 | cnt = sprintf(pg_result, "OK: mpls="); |
1571 | for (n = 0; n < pkt_dev->nr_labels; n++) | 1573 | for (n = 0; n < pkt_dev->nr_labels; n++) |
1572 | offset += sprintf(pg_result + offset, | 1574 | cnt += sprintf(pg_result + cnt, |
1573 | "%08x%s", ntohl(pkt_dev->labels[n]), | 1575 | "%08x%s", ntohl(pkt_dev->labels[n]), |
1574 | n == pkt_dev->nr_labels-1 ? "" : ","); | 1576 | n == pkt_dev->nr_labels-1 ? "" : ","); |
1575 | 1577 | ||
1576 | if (pkt_dev->nr_labels && pkt_dev->vlan_id != 0xffff) { | 1578 | if (pkt_dev->nr_labels && pkt_dev->vlan_id != 0xffff) { |
1577 | pkt_dev->vlan_id = 0xffff; /* turn off VLAN/SVLAN */ | 1579 | 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 | unsigned int prefixlen = 0; | 2733 | unsigned int prefixlen = 0; |
2732 | unsigned int suffixlen = 0; | 2734 | unsigned int suffixlen = 0; |
2733 | __be32 tmp; | 2735 | __be32 tmp; |
2736 | char *pos; | ||
2734 | 2737 | ||
2735 | for (i = 0; i < 16; i++) | 2738 | for (i = 0; i < 16; i++) |
2736 | ip[i] = 0; | 2739 | ip[i] = 0; |
@@ -2745,12 +2748,9 @@ static unsigned int scan_ip6(const char *s, char ip[16]) | |||
2745 | } | 2748 | } |
2746 | s++; | 2749 | s++; |
2747 | } | 2750 | } |
2748 | { | ||
2749 | char *tmp; | ||
2750 | u = simple_strtoul(s, &tmp, 16); | ||
2751 | i = tmp - s; | ||
2752 | } | ||
2753 | 2751 | ||
2752 | u = simple_strtoul(s, &pos, 16); | ||
2753 | i = pos - s; | ||
2754 | if (!i) | 2754 | if (!i) |
2755 | return 0; | 2755 | return 0; |
2756 | if (prefixlen == 12 && s[i] == '.') { | 2756 | if (prefixlen == 12 && s[i] == '.') { |
@@ -2778,11 +2778,9 @@ static unsigned int scan_ip6(const char *s, char ip[16]) | |||
2778 | len++; | 2778 | len++; |
2779 | } else if (suffixlen != 0) | 2779 | } else if (suffixlen != 0) |
2780 | break; | 2780 | break; |
2781 | { | 2781 | |
2782 | char *tmp; | 2782 | u = simple_strtol(s, &pos, 16); |
2783 | u = simple_strtol(s, &tmp, 16); | 2783 | i = pos - s; |
2784 | i = tmp - s; | ||
2785 | } | ||
2786 | if (!i) { | 2784 | if (!i) { |
2787 | if (*s) | 2785 | if (*s) |
2788 | len--; | 2786 | len--; |
diff --git a/net/core/scm.c b/net/core/scm.c index 44c4ec2c8769..530bee8d9ed9 100644 --- a/net/core/scm.c +++ b/net/core/scm.c | |||
@@ -167,7 +167,8 @@ error: | |||
167 | 167 | ||
168 | int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) | 168 | int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data) |
169 | { | 169 | { |
170 | struct cmsghdr __user *cm = (struct cmsghdr __user *)msg->msg_control; | 170 | struct cmsghdr __user *cm |
171 | = (__force struct cmsghdr __user *)msg->msg_control; | ||
171 | struct cmsghdr cmhdr; | 172 | struct cmsghdr cmhdr; |
172 | int cmlen = CMSG_LEN(len); | 173 | int cmlen = CMSG_LEN(len); |
173 | int err; | 174 | int err; |
@@ -202,7 +203,8 @@ out: | |||
202 | 203 | ||
203 | void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm) | 204 | void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm) |
204 | { | 205 | { |
205 | struct cmsghdr __user *cm = (struct cmsghdr __user*)msg->msg_control; | 206 | struct cmsghdr __user *cm |
207 | = (__force struct cmsghdr __user*)msg->msg_control; | ||
206 | 208 | ||
207 | int fdmax = 0; | 209 | int fdmax = 0; |
208 | int fdnum = scm->fp->count; | 210 | int fdnum = scm->fp->count; |
@@ -222,7 +224,8 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm) | |||
222 | if (fdnum < fdmax) | 224 | if (fdnum < fdmax) |
223 | fdmax = fdnum; | 225 | fdmax = fdnum; |
224 | 226 | ||
225 | for (i=0, cmfptr=(int __user *)CMSG_DATA(cm); i<fdmax; i++, cmfptr++) | 227 | for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax; |
228 | i++, cmfptr++) | ||
226 | { | 229 | { |
227 | int new_fd; | 230 | int new_fd; |
228 | err = security_file_receive(fp[i]); | 231 | err = security_file_receive(fp[i]); |