Messages in this thread Patch in this message | | | Subject | [PATCH][1/2] kobject: add HOTPLUG_ENV_VAR | Date | Sun, 12 Sep 2004 20:09:25 -0700 | From | Roland Dreier <> |
| |
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@topspin.com>
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, ...) \ + ({ \ + int len, ret = 0; \ + _envp[_index++] = _buf; \ + len = snprintf(_buf, _size, _fmt, ## __VA_ARGS__); \ + 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |