Re: An alternative way of populating /proc

From: Mitchell Blank Jr (mitch@sfgoth.com)
Date: Thu Apr 13 2000 - 03:28:45 EST


dean gaudet wrote:
> > create_proc_entries(NULL,
> > "test:{bar:{x:%d,y:%d,z:%d},foo:%f}",
> > &x, &y, &z, foo_fun);
>
> printf-style stuff sucks whenever you use more abstract types.

I tend to agree - the "%" convention is just a throwback to a time
before C had string constant concatenation. The above would be
much cleaner if we did:

#define PROC_ENT_INTEGER "\376"
#define PROC_ENT_FUNCTION "\375"

Plus it would make the parser (very slightly) simpler.

Think about it - no one minds printf too much since we all know what "%d"
means... but how are we supposed to know what magic "%f" means to
create_proc_entries? A symbolic constant makes so much more sense.
And while we're defining a constant anyway, why use a printable
character?

> also, varargs doesn't give you type-checking. printf works out fine
> because gcc -Wall knows how to parse printf args. but that's quite
> limiting, you can't extend it.
>
> is the real concern codesize and you're totally willing to throw away
> type checking and such?

For common cases you can easily wrap the varargs version in a simple
inline wrapper to keep type safety if you want.

-Mitch

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



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:20 EST