Commit d618222352ac95ff9a21f1fc1018fffeb8952194

Authored by Paul Gortmaker
Committed by David S. Miller
1 parent 38df7a3949

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>

Showing 1 changed file with 15 additions and 15 deletions Side-by-side Diff

... ... @@ -771,10 +771,10 @@
771 771 static unsigned long num_arg(const char __user * user_buffer,
772 772 unsigned long maxlen, unsigned long *num)
773 773 {
774   - int i = 0;
  774 + int i;
775 775 *num = 0;
776 776  
777   - for (; i < maxlen; i++) {
  777 + for (i = 0; i < maxlen; i++) {
778 778 char c;
779 779 if (get_user(c, &user_buffer[i]))
780 780 return -EFAULT;
781 781  
... ... @@ -789,9 +789,9 @@
789 789  
790 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 795 char c;
796 796 if (get_user(c, &user_buffer[i]))
797 797 return -EFAULT;
... ... @@ -846,7 +846,7 @@
846 846 {
847 847 struct seq_file *seq = file->private_data;
848 848 struct pktgen_dev *pkt_dev = seq->private;
849   - int i = 0, max, len;
  849 + int i, max, len;
850 850 char name[16], valstr[32];
851 851 unsigned long value = 0;
852 852 char *pg_result = NULL;
853 853  
... ... @@ -860,13 +860,13 @@
860 860 return -EINVAL;
861 861 }
862 862  
863   - max = count - i;
864   - tmp = count_trail_chars(&user_buffer[i], max);
  863 + max = count;
  864 + tmp = count_trail_chars(user_buffer, max);
865 865 if (tmp < 0) {
866 866 pr_warning("illegal format\n");
867 867 return tmp;
868 868 }
869   - i += tmp;
  869 + i = tmp;
870 870  
871 871 /* Read variable name */
872 872  
... ... @@ -1764,7 +1764,7 @@
1764 1764 {
1765 1765 struct seq_file *seq = file->private_data;
1766 1766 struct pktgen_thread *t = seq->private;
1767   - int i = 0, max, len, ret;
  1767 + int i, max, len, ret;
1768 1768 char name[40];
1769 1769 char *pg_result;
1770 1770  
1771 1771  
... ... @@ -1773,12 +1773,12 @@
1773 1773 return -EINVAL;
1774 1774 }
1775 1775  
1776   - max = count - i;
1777   - len = count_trail_chars(&user_buffer[i], max);
  1776 + max = count;
  1777 + len = count_trail_chars(user_buffer, max);
1778 1778 if (len < 0)
1779 1779 return len;
1780 1780  
1781   - i += len;
  1781 + i = len;
1782 1782  
1783 1783 /* Read variable name */
1784 1784  
... ... @@ -1975,7 +1975,7 @@
1975 1975 const char *ifname)
1976 1976 {
1977 1977 char b[IFNAMSIZ+5];
1978   - int i = 0;
  1978 + int i;
1979 1979  
1980 1980 for (i = 0; ifname[i] != '@'; i++) {
1981 1981 if (i == IFNAMSIZ)
... ... @@ -2519,8 +2519,8 @@
2519 2519 {
2520 2520 if (pkt_dev->cflows) {
2521 2521 /* let go of the SAs if we have them */
2522   - int i = 0;
2523   - for (; i < pkt_dev->cflows; i++) {
  2522 + int i;
  2523 + for (i = 0; i < pkt_dev->cflows; i++) {
2524 2524 struct xfrm_state *x = pkt_dev->flows[i].x;
2525 2525 if (x) {
2526 2526 xfrm_state_put(x);