All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roland Dreier <roland@topspin.com>
To: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR
Date: Mon, 27 Sep 2004 09:31:50 -0700	[thread overview]
Message-ID: <10963027102899@topspin.com> (raw)
In-Reply-To: <1096302710971@topspin.com>

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, _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;


  reply	other threads:[~2004-09-27 16:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-27 16:31 [PATCH][0/2] [RESEND] Hotplug variable patches Roland Dreier
2004-09-27 16:31 ` Roland Dreier [this message]
2004-09-27 16:31   ` [PATCH][2/2] [RESEND] USB: use HOTPLUG_ENV_VAR in core/usb.c Roland Dreier
2004-09-27 20:10   ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Paul Jackson
2004-09-27 22:10     ` Roland Dreier
2004-09-28  6:43       ` Paul Jackson
2004-09-28 15:29         ` Roland Dreier
2004-09-28 16:00           ` Paul Jackson
2004-09-28 16:13             ` Roland Dreier
2004-09-28 21:56               ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2004-09-27 16:59 [PATCH][0/2] [RESEND] Hotplug variable patches Roland Dreier
2004-09-27 16:59 ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Roland Dreier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10963027102899@topspin.com \
    --to=roland@topspin.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.