diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2010-10-18 08:14:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-24 18:23:35 -0400 |
commit | d618222352ac95ff9a21f1fc1018fffeb8952194 (patch) | |
tree | cb74db8147dd3ac717e0ebd89fc042806391a1eb /net/core | |
parent | 38df7a39492d52f4fad484f611f01a01bd8f1e41 (diff) |
pktgen: clean up handling of local/transient counter vars
The temporary variable "i" is needlessly initialized to zero
in two distinct cases in this file:
1) where it is set to zero and then used as an argument in an addition
before being assigned a non-zero value.
2) where it is only used in a standard/typical loop counter
For (1), simply delete assignment to zero and usages while still
zero; for (2) simply make the loop start at zero as per standard
practice as seen everywhere else in the same file.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/pktgen.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 2c0df0f95b3d..679b797d06b1 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -771,10 +771,10 @@ done: | |||
771 | static unsigned long num_arg(const char __user * user_buffer, | 771 | static unsigned long num_arg(const char __user * user_buffer, |
772 | unsigned long maxlen, unsigned long *num) | 772 | unsigned long maxlen, unsigned long *num) |
773 | { | 773 | { |
774 | int i = 0; | 774 | int i; |
775 | *num = 0; | 775 | *num = 0; |
776 | 776 | ||
777 | for (; i < maxlen; i++) { | 777 | for (i = 0; i < maxlen; i++) { |
778 | char c; | 778 | char c; |
779 | if (get_user(c, &user_buffer[i])) | 779 | if (get_user(c, &user_buffer[i])) |
780 | return -EFAULT; | 780 | return -EFAULT; |
@@ -789,9 +789,9 @@ static unsigned long num_arg(const char __user * user_buffer, | |||
789 | 789 | ||
790 | static int strn_len(const char __user * user_buffer, unsigned int maxlen) | 790 | static int strn_len(const char __user * user_buffer, unsigned int maxlen) |
791 | { | 791 | { |
792 | int i = 0; | 792 | int i; |
793 | 793 | ||
794 | for (; i < maxlen; i++) { | 794 | for (i = 0; i < maxlen; i++) { |
795 | char c; | 795 | char c; |
796 | if (get_user(c, &user_buffer[i])) | 796 | if (get_user(c, &user_buffer[i])) |
797 | return -EFAULT; | 797 | return -EFAULT; |
@@ -846,7 +846,7 @@ static ssize_t pktgen_if_write(struct file *file, | |||
846 | { | 846 | { |
847 | struct seq_file *seq = file->private_data; | 847 | struct seq_file *seq = file->private_data; |
848 | struct pktgen_dev *pkt_dev = seq->private; | 848 | struct pktgen_dev *pkt_dev = seq->private; |
849 | int i = 0, max, len; | 849 | int i, max, len; |
850 | char name[16], valstr[32]; | 850 | char name[16], valstr[32]; |
851 | unsigned long value = 0; | 851 | unsigned long value = 0; |
852 | char *pg_result = NULL; | 852 | char *pg_result = NULL; |
@@ -860,13 +860,13 @@ static ssize_t pktgen_if_write(struct file *file, | |||
860 | return -EINVAL; | 860 | return -EINVAL; |
861 | } | 861 | } |
862 | 862 | ||
863 | max = count - i; | 863 | max = count; |
864 | tmp = count_trail_chars(&user_buffer[i], max); | 864 | tmp = count_trail_chars(user_buffer, max); |
865 | if (tmp < 0) { | 865 | if (tmp < 0) { |
866 | pr_warning("illegal format\n"); | 866 | pr_warning("illegal format\n"); |
867 | return tmp; | 867 | return tmp; |
868 | } | 868 | } |
869 | i += tmp; | 869 | i = tmp; |
870 | 870 | ||
871 | /* Read variable name */ | 871 | /* Read variable name */ |
872 | 872 | ||
@@ -1764,7 +1764,7 @@ static ssize_t pktgen_thread_write(struct file *file, | |||
1764 | { | 1764 | { |
1765 | struct seq_file *seq = file->private_data; | 1765 | struct seq_file *seq = file->private_data; |
1766 | struct pktgen_thread *t = seq->private; | 1766 | struct pktgen_thread *t = seq->private; |
1767 | int i = 0, max, len, ret; | 1767 | int i, max, len, ret; |
1768 | char name[40]; | 1768 | char name[40]; |
1769 | char *pg_result; | 1769 | char *pg_result; |
1770 | 1770 | ||
@@ -1773,12 +1773,12 @@ static ssize_t pktgen_thread_write(struct file *file, | |||
1773 | return -EINVAL; | 1773 | return -EINVAL; |
1774 | } | 1774 | } |
1775 | 1775 | ||
1776 | max = count - i; | 1776 | max = count; |
1777 | len = count_trail_chars(&user_buffer[i], max); | 1777 | len = count_trail_chars(user_buffer, max); |
1778 | if (len < 0) | 1778 | if (len < 0) |
1779 | return len; | 1779 | return len; |
1780 | 1780 | ||
1781 | i += len; | 1781 | i = len; |
1782 | 1782 | ||
1783 | /* Read variable name */ | 1783 | /* Read variable name */ |
1784 | 1784 | ||
@@ -1975,7 +1975,7 @@ static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev, | |||
1975 | const char *ifname) | 1975 | const char *ifname) |
1976 | { | 1976 | { |
1977 | char b[IFNAMSIZ+5]; | 1977 | char b[IFNAMSIZ+5]; |
1978 | int i = 0; | 1978 | int i; |
1979 | 1979 | ||
1980 | for (i = 0; ifname[i] != '@'; i++) { | 1980 | for (i = 0; ifname[i] != '@'; i++) { |
1981 | if (i == IFNAMSIZ) | 1981 | if (i == IFNAMSIZ) |
@@ -2519,8 +2519,8 @@ static void free_SAs(struct pktgen_dev *pkt_dev) | |||
2519 | { | 2519 | { |
2520 | if (pkt_dev->cflows) { | 2520 | if (pkt_dev->cflows) { |
2521 | /* let go of the SAs if we have them */ | 2521 | /* let go of the SAs if we have them */ |
2522 | int i = 0; | 2522 | int i; |
2523 | for (; i < pkt_dev->cflows; i++) { | 2523 | for (i = 0; i < pkt_dev->cflows; i++) { |
2524 | struct xfrm_state *x = pkt_dev->flows[i].x; | 2524 | struct xfrm_state *x = pkt_dev->flows[i].x; |
2525 | if (x) { | 2525 | if (x) { |
2526 | xfrm_state_put(x); | 2526 | xfrm_state_put(x); |