Re: [PATCH 1/8] bonding: Remove trailing NULs from sysfs interface.

2007-12-07 Thread Jeff Garzik

Jay Vosburgh wrote:

From: Wagner Ferenc [EMAIL PROTECTED]

From: Wagner Ferenc [EMAIL PROTECTED]

Also remove trailing spaces from multivalued files.

This fixes output like for example:

$ od -c /sys/class/net/bond0/bonding/slaves
000   e   t   h   -   l   e   f   t   e   t   h   -   r   i   g
020   h   t  \n  \0
025

It mostly entails deleting '+1'-s after sprintf() calls: the return value
of sprintf is the number of characters printed, without the closing NUL,
ie. exactly what the sysfs interface requires.  The three multivalue
cases are different, because they also have to swallow back a trailing
space.

Signed-off-by: Ferenc Wagner [EMAIL PROTECTED]
Acked-by: Jay Vosburgh [EMAIL PROTECTED]
---
 drivers/net/bonding/bond_sysfs.c |   66 +
 1 files changed, 30 insertions(+), 36 deletions(-)


applied 1-8 to #upstream-fixes

Your script is duplicating the From:  line twice


--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/8] bonding: Remove trailing NULs from sysfs interface.

2007-12-06 Thread Jay Vosburgh
From: Wagner Ferenc [EMAIL PROTECTED]

From: Wagner Ferenc [EMAIL PROTECTED]

Also remove trailing spaces from multivalued files.

This fixes output like for example:

$ od -c /sys/class/net/bond0/bonding/slaves
000   e   t   h   -   l   e   f   t   e   t   h   -   r   i   g
020   h   t  \n  \0
025

It mostly entails deleting '+1'-s after sprintf() calls: the return value
of sprintf is the number of characters printed, without the closing NUL,
ie. exactly what the sysfs interface requires.  The three multivalue
cases are different, because they also have to swallow back a trailing
space.

Signed-off-by: Ferenc Wagner [EMAIL PROTECTED]
Acked-by: Jay Vosburgh [EMAIL PROTECTED]
---
 drivers/net/bonding/bond_sysfs.c |   66 +
 1 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index b29330d..a3f1b4a 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -86,14 +86,13 @@ static ssize_t bonding_show_bonds(struct class *cls, char 
*buffer)
/* not enough space for another interface name */
if ((PAGE_SIZE - res)  10)
res = PAGE_SIZE - 10;
-   res += sprintf(buffer + res, ++more++);
+   res += sprintf(buffer + res, ++more++ );
break;
}
res += sprintf(buffer + res, %s ,
   bond-dev-name);
}
-   res += sprintf(buffer + res, \n);
-   res++;
+   if (res) buffer[res-1] = '\n'; /* eat the leftover space */
up_read((bonding_rwsem));
return res;
 }
@@ -235,14 +234,13 @@ static ssize_t bonding_show_slaves(struct device *d,
/* not enough space for another interface name */
if ((PAGE_SIZE - res)  10)
res = PAGE_SIZE - 10;
-   res += sprintf(buf + res, ++more++);
+   res += sprintf(buf + res, ++more++ );
break;
}
res += sprintf(buf + res, %s , slave-dev-name);
}
read_unlock(bond-lock);
-   res += sprintf(buf + res, \n);
-   res++;
+   if (res) buf[res-1] = '\n'; /* eat the leftover space */
return res;
 }
 
@@ -406,7 +404,7 @@ static ssize_t bonding_show_mode(struct device *d,
 
return sprintf(buf, %s %d\n,
bond_mode_tbl[bond-params.mode].modename,
-   bond-params.mode) + 1;
+   bond-params.mode);
 }
 
 static ssize_t bonding_store_mode(struct device *d,
@@ -463,11 +461,11 @@ static ssize_t bonding_show_xmit_hash(struct device *d,
if ((bond-params.mode != BOND_MODE_XOR) 
(bond-params.mode != BOND_MODE_8023AD)) {
// Not Applicable
-   count = sprintf(buf, NA\n) + 1;
+   count = sprintf(buf, NA\n);
} else {
count = sprintf(buf, %s %d\n,
xmit_hashtype_tbl[bond-params.xmit_policy].modename,
-   bond-params.xmit_policy) + 1;
+   bond-params.xmit_policy);
}
 
return count;
@@ -527,7 +525,7 @@ static ssize_t bonding_show_arp_validate(struct device *d,
 
return sprintf(buf, %s %d\n,
   arp_validate_tbl[bond-params.arp_validate].modename,
-  bond-params.arp_validate) + 1;
+  bond-params.arp_validate);
 }
 
 static ssize_t bonding_store_arp_validate(struct device *d,
@@ -627,7 +625,7 @@ static ssize_t bonding_show_arp_interval(struct device *d,
 {
struct bonding *bond = to_bond(d);
 
-   return sprintf(buf, %d\n, bond-params.arp_interval) + 1;
+   return sprintf(buf, %d\n, bond-params.arp_interval);
 }
 
 static ssize_t bonding_store_arp_interval(struct device *d,
@@ -711,10 +709,7 @@ static ssize_t bonding_show_arp_targets(struct device *d,
res += sprintf(buf + res, %u.%u.%u.%u ,
   NIPQUAD(bond-params.arp_targets[i]));
}
-   if (res)
-   res--;  /* eat the leftover space */
-   res += sprintf(buf + res, \n);
-   res++;
+   if (res) buf[res-1] = '\n'; /* eat the leftover space */
return res;
 }
 
@@ -815,7 +810,7 @@ static ssize_t bonding_show_downdelay(struct device *d,
 {
struct bonding *bond = to_bond(d);
 
-   return sprintf(buf, %d\n, bond-params.downdelay * 
bond-params.miimon) + 1;
+   return sprintf(buf, %d\n, bond-params.downdelay * 
bond-params.miimon);
 }
 
 static ssize_t bonding_store_downdelay(struct device *d,
@@ -872,7 +867,7 @@ static ssize_t bonding_show_updelay(struct device *d,
 {
struct bonding *bond = to_bond(d);
 
-   return sprintf(buf, %d\n, bond-params.updelay *