Index Home About Blog
Newsgroups: fa.linux.kernel
From: Jamie Lokier <>
Subject: Re: [Infiniband-general] Getting an Infiniband access layer in 
	theLinux kernel
Original-Message-ID: <>
Date: Sat, 7 Feb 2004 03:15:02 GMT
Message-ID: <>

Petr Vandrovec wrote:
> Yes, because Linux programmers are only one who care about quality.
> Microsoft happilly offers (W2k DDK,inc/ddk/ntddk.h)
> /* PLIST_ENTRY RemoveHeadList(PLIST_ENTRY ListHead) */
> #define RemoveHeadList(ListHead) \
> 	(ListHead)->Flink;\
> 	{RemoveEntryList((ListHead)->Flink)}
> and they do not care that you cannot use it in an expression, or
> after if () statement, or anywhere else, except directly in an
> assignment which is not in if/while body. So you must know that
> RemoveHeadList() is macro, even that it is macro built from two
> statements, and that you cannot use it as a function at all, as
> it has a value only from left side - from right side it is
> void :-( And of course it evaluates ListHead two times.

Oh, it is much worse than that.

You _can_ use it after an if() statement.  Your program compiles just
fine.  The only problem is it has a serious bug which is invisible and
may not be noticed for years.

I have seen code shipped with this exact bug, and watched someone
spend days debugging a program that contained it, until they brought
the problem to me.  Then we found it quickly - because I already
know why that macro kind is bad, thanks to the GNU CPP manual.

In short, any programmer managed by me who wrote a macro like that
would be educated why it is not acceptable.  If they still wrote code
like that afterwards, they wouldn't remain with me for long.

-- Jamie

Index Home About Blog