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

From: Paul Jackson
Date: Tue Sep 28 2004 - 11:03:33 EST


> 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@xxxxxxx> 1.650.933.1373
-
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/