Commit d6182223 authored by Paul Gortmaker's avatar Paul Gortmaker Committed by David S. Miller

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: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 38df7a39
...@@ -771,10 +771,10 @@ static int count_trail_chars(const char __user * user_buffer, ...@@ -771,10 +771,10 @@ static int count_trail_chars(const char __user * user_buffer,
static unsigned long num_arg(const char __user * user_buffer, static unsigned long num_arg(const char __user * user_buffer,
unsigned long maxlen, unsigned long *num) unsigned long maxlen, unsigned long *num)
{ {
int i = 0; int i;
*num = 0; *num = 0;
for (; i < maxlen; i++) { for (i = 0; i < maxlen; i++) {
char c; char c;
if (get_user(c, &user_buffer[i])) if (get_user(c, &user_buffer[i]))
return -EFAULT; return -EFAULT;
...@@ -789,9 +789,9 @@ static unsigned long num_arg(const char __user * user_buffer, ...@@ -789,9 +789,9 @@ static unsigned long num_arg(const char __user * user_buffer,
static int strn_len(const char __user * user_buffer, unsigned int maxlen) static int strn_len(const char __user * user_buffer, unsigned int maxlen)
{ {
int i = 0; int i;
for (; i < maxlen; i++) { for (i = 0; i < maxlen; i++) {
char c; char c;
if (get_user(c, &user_buffer[i])) if (get_user(c, &user_buffer[i]))
return -EFAULT; return -EFAULT;
...@@ -846,7 +846,7 @@ static ssize_t pktgen_if_write(struct file *file, ...@@ -846,7 +846,7 @@ static ssize_t pktgen_if_write(struct file *file,
{ {
struct seq_file *seq = file->private_data; struct seq_file *seq = file->private_data;
struct pktgen_dev *pkt_dev = seq->private; struct pktgen_dev *pkt_dev = seq->private;
int i = 0, max, len; int i, max, len;
char name[16], valstr[32]; char name[16], valstr[32];
unsigned long value = 0; unsigned long value = 0;
char *pg_result = NULL; char *pg_result = NULL;
...@@ -860,13 +860,13 @@ static ssize_t pktgen_if_write(struct file *file, ...@@ -860,13 +860,13 @@ static ssize_t pktgen_if_write(struct file *file,
return -EINVAL; return -EINVAL;
} }
max = count - i; max = count;
tmp = count_trail_chars(&user_buffer[i], max); tmp = count_trail_chars(user_buffer, max);
if (tmp < 0) { if (tmp < 0) {
pr_warning("illegal format\n"); pr_warning("illegal format\n");
return tmp; return tmp;
} }
i += tmp; i = tmp;
/* Read variable name */ /* Read variable name */
...@@ -1764,7 +1764,7 @@ static ssize_t pktgen_thread_write(struct file *file, ...@@ -1764,7 +1764,7 @@ static ssize_t pktgen_thread_write(struct file *file,
{ {
struct seq_file *seq = file->private_data; struct seq_file *seq = file->private_data;
struct pktgen_thread *t = seq->private; struct pktgen_thread *t = seq->private;
int i = 0, max, len, ret; int i, max, len, ret;
char name[40]; char name[40];
char *pg_result; char *pg_result;
...@@ -1773,12 +1773,12 @@ static ssize_t pktgen_thread_write(struct file *file, ...@@ -1773,12 +1773,12 @@ static ssize_t pktgen_thread_write(struct file *file,
return -EINVAL; return -EINVAL;
} }
max = count - i; max = count;
len = count_trail_chars(&user_buffer[i], max); len = count_trail_chars(user_buffer, max);
if (len < 0) if (len < 0)
return len; return len;
i += len; i = len;
/* Read variable name */ /* Read variable name */
...@@ -1975,7 +1975,7 @@ static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev, ...@@ -1975,7 +1975,7 @@ static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev,
const char *ifname) const char *ifname)
{ {
char b[IFNAMSIZ+5]; char b[IFNAMSIZ+5];
int i = 0; int i;
for (i = 0; ifname[i] != '@'; i++) { for (i = 0; ifname[i] != '@'; i++) {
if (i == IFNAMSIZ) if (i == IFNAMSIZ)
...@@ -2519,8 +2519,8 @@ static void free_SAs(struct pktgen_dev *pkt_dev) ...@@ -2519,8 +2519,8 @@ static void free_SAs(struct pktgen_dev *pkt_dev)
{ {
if (pkt_dev->cflows) { if (pkt_dev->cflows) {
/* let go of the SAs if we have them */ /* let go of the SAs if we have them */
int i = 0; int i;
for (; i < pkt_dev->cflows; i++) { for (i = 0; i < pkt_dev->cflows; i++) {
struct xfrm_state *x = pkt_dev->flows[i].x; struct xfrm_state *x = pkt_dev->flows[i].x;
if (x) { if (x) {
xfrm_state_put(x); xfrm_state_put(x);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment