From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: "Richard B. Johnson" <root@chaos.analogic.com>
Cc: Valdis.Kletnieks@vt.edu, Roland Dreier <roland@topspin.com>,
"Hefty, Sean" <sean.hefty@intel.com>,
Troy Benjegerdes <hozer@hozed.org>,
infiniband-general@lists.sourceforge.net,
Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: [Infiniband-general] Getting an Infiniband access layer in theLinux kernel
Date: Fri, 6 Feb 2004 20:11:08 +0100 [thread overview]
Message-ID: <20040206191107.GA6340@vana.vc.cvut.cz> (raw)
In-Reply-To: <Pine.LNX.4.53.0402061336120.4238@chaos>
On Fri, Feb 06, 2004 at 01:50:42PM -0500, Richard B. Johnson wrote:
> On Fri, 6 Feb 2004 Valdis.Kletnieks@vt.edu wrote:
>
> > On Fri, 06 Feb 2004 13:00:38 EST, "Richard B. Johnson" said:
> >
> > > Yes you can. You just don't use an ';' if you are going
> > > to use 'else'.
> >
> > You did realize we've changed things from macros to inline functions
> > (and vice versa) on occasion?
> >
> > Yes, you *can* hack around the "problem". Is there any actual
> > evidence that any real performance issues arise from the null
> > do/while? Does said issue outweigh the increased fragility of
> > the code?
> >
>
> Well the 'problem' is a demonstration. The last time I answered
> a query about the "do {} while(0)", stuff (as an advocate), there
> were tons of 'experts' that jumped on me for helping to propagate
> this "atrocious" (as I recall) abuse of the 'C' language. I
> was severely tongue-lashed into believing that there was no
> actual reason for doing it that way.
> running off to the head. I have spent a bunch of time looking
> at C/C++ headers for Sun and W$ and the only place I've
> ever seen the "do {} while(0)" stuff is in Linux. I think
> it started with Linux (was a Linux Invention!), as some
> kind of work-around, then it became a "Linux Signature".
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.
Please do not add such traps into Linux kernel code.
Petr Vandrovec
vandrove@vc.cvut.cz
next prev parent reply other threads:[~2004-02-06 19:17 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-06 16:42 Hefty, Sean
2004-02-06 17:05 ` Richard B. Johnson
2004-02-06 17:23 ` Roland Dreier
2004-02-06 18:00 ` Richard B. Johnson
2004-02-06 18:12 ` Måns Rullgård
2004-02-06 18:13 ` Chris Friesen
2004-02-06 18:22 ` Valdis.Kletnieks
2004-02-06 18:50 ` Richard B. Johnson
2004-02-06 19:02 ` Matti Aarnio
2004-02-06 19:11 ` Petr Vandrovec [this message]
2004-02-07 3:05 ` Jamie Lokier
2004-02-06 18:54 ` Måns Rullgård
2004-02-06 19:01 ` somenath
2004-02-06 17:27 ` Troy Benjegerdes
2004-02-06 18:51 ` Greg KH
2004-02-08 8:31 ` Fab Tillier
2004-02-08 16:29 ` Greg KH
2004-02-08 16:51 ` Fab Tillier
2004-02-09 2:55 ` Troy Benjegerdes
2004-02-09 2:57 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2004-02-24 17:55 Woodruff, Robert J
2004-02-24 18:03 ` Greg KH
[not found] <mailman.1076018705.12618.linux-kernel2news@redhat.com>
2004-02-09 1:51 ` Pete Zaitcev
2004-02-08 23:43 Arnd Bergmann
2004-02-08 21:36 Woodruff, Robert J
2004-02-06 4:07 Perez-Gonzalez, Inaky
2004-02-05 23:09 Woodruff, Robert J
2004-02-05 22:55 Woodruff, Robert J
2004-02-05 22:54 ` Randy.Dunlap
2004-02-05 22:26 Hefty, Sean
2004-02-05 22:40 ` Christoph Hellwig
2004-02-05 22:39 ` Randy.Dunlap
2004-02-05 23:19 ` Greg KH
2004-02-06 1:10 ` Troy Benjegerdes
2004-02-05 22:17 Tillier, Fabian
2004-02-05 22:56 ` Brian Gerst
2004-02-05 22:58 ` Bernd Petrovitsch
2004-02-05 22:02 Tillier, Fabian
2004-02-06 1:57 ` Troy Benjegerdes
2004-02-05 20:32 Tillier, Fabian
2004-02-05 21:27 ` Greg KH
2004-02-05 21:56 ` Chris Friesen
2004-02-06 20:22 ` Bill Davidsen
2004-02-05 19:26 Tillier, Fabian
2004-02-05 20:27 ` Greg KH
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=20040206191107.GA6340@vana.vc.cvut.cz \
--to=vandrove@vc.cvut.cz \
--cc=Valdis.Kletnieks@vt.edu \
--cc=hozer@hozed.org \
--cc=infiniband-general@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@topspin.com \
--cc=root@chaos.analogic.com \
--cc=sean.hefty@intel.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
all inboxes | Powered by JetHome®