[PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR

From: Roland Dreier
Date: Mon Sep 27 2004 - 11:39:37 EST


Add a HOTPLUG_ENV_VAR macro to <linux/kobject.h>. There's a lot of
boilerplate code involved in setting environment variables in a
hotplug method, so we should have a convenience macro to consolidate
it (and avoid subtle bugs).


Signed-off-by: Roland Dreier <roland@xxxxxxxxxxx>

Index: linux-bk/include/linux/kobject.h
===================================================================
--- linux-bk.orig/include/linux/kobject.h 2004-09-12 15:17:02.000000000 -0700
+++ linux-bk/include/linux/kobject.h 2004-09-12 19:44:31.000000000 -0700
@@ -95,6 +95,20 @@
int num_envp, char *buffer, int buffer_size);
};

+#define HOTPLUG_ENV_VAR(_buf, _size, _envp, _nenvp, _index, _fmt, _arg...) \
+ ({ \
+ int len, ret = 0; \
+ _envp[_index++] = _buf; \
+ len = snprintf(_buf, _size, _fmt, ## _arg); \
+ if (_size - len <= 0 || _index >= _nenvp) \
+ ret = -ENOMEM; \
+ else { \
+ _buf += len + 1; \
+ _size -= len + 1; \
+ } \
+ ret; \
+ })
+
struct kset {
struct subsystem * subsys;
struct kobj_type * ktype;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/