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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
bdc4960a0b
commit
bf62456eb9
@@ -1163,6 +1163,7 @@ static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
|
||||
struct unit_directory *ud;
|
||||
int i = 0;
|
||||
int length = 0;
|
||||
int retval = 0;
|
||||
/* ieee1394:venNmoNspNverN */
|
||||
char buf[8 + 1 + 3 + 8 + 2 + 8 + 2 + 8 + 3 + 8 + 1];
|
||||
|
||||
@@ -1176,14 +1177,11 @@ static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
|
||||
|
||||
#define PUT_ENVP(fmt,val) \
|
||||
do { \
|
||||
int printed; \
|
||||
envp[i++] = buffer; \
|
||||
printed = snprintf(buffer, buffer_size - length, \
|
||||
fmt, val); \
|
||||
if ((buffer_size - (length+printed) <= 0) || (i >= num_envp)) \
|
||||
return -ENOMEM; \
|
||||
length += printed+1; \
|
||||
buffer += printed+1; \
|
||||
retval = add_uevent_var(envp, num_envp, &i, \
|
||||
buffer, buffer_size, &length, \
|
||||
fmt, val); \
|
||||
if (retval) \
|
||||
return retval; \
|
||||
} while (0)
|
||||
|
||||
PUT_ENVP("VENDOR_ID=%06x", ud->vendor_id);
|
||||
|
Reference in New Issue
Block a user