From: Paul Jackson <pj@sgi.com>
To: Roland Dreier <roland@topspin.com>
Cc: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR
Date: Tue, 28 Sep 2004 09:00:32 -0700 [thread overview]
Message-ID: <20040928090032.292d12e8.pj@sgi.com> (raw)
In-Reply-To: <52mzzacsyk.fsf@topspin.com>
> So the next env var is going to be concatenated with this one.
Right you are - unlike most times where one is trying to concatenate
strings, this time you want the nul char separator.
> It's precisely this sort of easy-to-make off-by-one bug that convinces
> me the hotplug environment variable handling needs to be wrapped up in
> a helper macro or function.
Perhaps - but perhaps also I've shown you ways to use a function with
fewer non-const variables.
And perhaps the placing of the nul chars should be explicit:
if (length < buffer_size)
buffer[length++] = '\0';
so that someone else doesn't either miss the intentional inclusion of
the nul as I just did, or does see it and thinks it's an off-by-one
error and "fixes" it.
That macro was ugly.
Adding to my previous rules of:
* minimum number variables
* simplest invariants on variables
* functions beat macros
now include:
* explicit coding of anything out of the ordinary.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
next prev parent reply other threads:[~2004-09-28 16:02 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 ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Roland Dreier
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 [this message]
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=20040928090032.292d12e8.pj@sgi.com \
--to=pj@sgi.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@topspin.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox