summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorEric Rannaud <eric.rannaud@gmail.com>2007-03-30 22:23:12 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 10:57:29 -0700
commitbf62456eb91f3d2ef0736081583d09b0b3c8b7ea (patch)
tree851c2559ae11835e19763b7c7c54393f0ae0d5f6 /net/core
parentbdc4960a0b4831a24276b65f1f7afdfc57f2f5cf (diff)
uevent: use add_uevent_var() instead of open coding it
Make use of add_uevent_var() instead of (often incorrectly) open coding it. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Eric Rannaud <eric.rannaud@gmail.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/net-sysfs.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index e441ec7988c..b21307b15b8 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -412,31 +412,25 @@ static int netdev_uevent(struct device *d, char **envp,
int num_envp, char *buf, int size)
{
struct net_device *dev = to_net_dev(d);
- int i = 0;
- int n;
+ int retval, len = 0, i = 0;
/* pass interface to uevent. */
- envp[i++] = buf;
- n = snprintf(buf, size, "INTERFACE=%s", dev->name) + 1;
- buf += n;
- size -= n;
-
- if ((size <= 0) || (i >= num_envp))
- return -ENOMEM;
+ retval = add_uevent_var(envp, num_envp, &i,
+ buf, size, &len,
+ "INTERFACE=%s", dev->name);
+ if (retval)
+ goto exit;
/* pass ifindex to uevent.
* ifindex is useful as it won't change (interface name may change)
* and is what RtNetlink uses natively. */
- envp[i++] = buf;
- n = snprintf(buf, size, "IFINDEX=%d", dev->ifindex) + 1;
- buf += n;
- size -= n;
-
- if ((size <= 0) || (i >= num_envp))
- return -ENOMEM;
+ retval = add_uevent_var(envp, num_envp, &i,
+ buf, size, &len,
+ "IFINDEX=%d", dev->ifindex);
+exit:
envp[i] = NULL;
- return 0;
+ return retval;
}
#endif