public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] 2.4.19-rc2-ac2 pdc202xx.c update
@ 2002-07-23 10:49 Mikael Pettersson
  0 siblings, 0 replies; 9+ messages in thread
From: Mikael Pettersson @ 2002-07-23 10:49 UTC (permalink / raw)
  To: romieu, support; +Cc: hanky, linux-kernel

On Tue, 23 Jul 2002 09:19:15 +0200, Francois Romieu wrote:
>support <support@promise.com.tw> :
>> We think there is no problems, Acturally it is
>> 
>> if (speed == XFER_UDMA_2) {
>>         OUT_BYTE((thold + adj), indexreg);
>>         OUT_BYTE((IN_BYTE(datareg) & 0x7f), datareg);
>> }
>> 
>> So,
>> if (speed == XFER_UDMA_2)
>>         set_2regs(thold, (IN_BYTE(datareg) & 0x7f));

The problem is a common one for complex statement-like macros.
You have a macro M consisting of (in this case) two statements
S1 and S2: "#define M S1; S2". Now consider what happens when
M is used in non-block context, i.e. not as a top-level
statement between { and } but rather in e.g. the true branch
of an if-statement:

	if (condition)
		M;

which after preprocessing becomes

	if (condition)
		S1; S2;

However, indentation doesn't matter, only grouping does, so this
USE of the macro really is

	if (condition)
		S1;
	S2;

Now do you see? The macro body was broken up, and the second statement
is now executed unconditionally.

The traditional approach is to write the body of a complex macro as a
do { ... } while(0) statement (i.e. #define M do { S1; S2; } while(0))
since this turns the macro body into a single unbreakable statement
which is safe to use in any context where a statement may occur.

Simply wrapping the macro body with a pair of braces { } doesn't work
in all contexts; the do{...}while(0) idiom does.

/Mikael

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH] 2.4.19-rc2-ac2 pdc202xx.c update
@ 2002-07-19  9:09 support
  2002-07-19  9:52 ` Giro
  0 siblings, 1 reply; 9+ messages in thread
From: support @ 2002-07-19  9:09 UTC (permalink / raw)
  To: Alan Cox (Linux Kernel), Marcelo (Linux Kernel); +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

Hi, Alan.

    I update the patch merge with 2.4.19-rc2-ac2 for fix minor things
with pdc202xx.c, patch-2.4.19rc1-ac series and patch-2.4.19rc2-ac
series has some different with pdc202xx.c, I don't know who rewrite
this code...Why pdc202xx_ratefilter() down UDMA mode with
tune_chipset function?

    Now we are the maintainer of pdc202xx controllers. We know the
ASIC detail spec. So please let us modify and maintain.
We can provide best support for world wide Promise users.

    Alan, please merge this patch in your series. thanks.
    Marcelo, Maybe you can help us to merge with 2.4.19rc3?

Thanks in advance
--
Hank Yang
Promise Technology, Inc.




[-- Attachment #2: promise-patch-2.4.19-rc2-ac2.gz --]
[-- Type: application/x-gzip, Size: 9697 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-07-23 17:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <01b801c22f0b$c02cc360$47cba8c0@promise.com.tw>
2002-07-22  3:16 ` [PATCH] 2.4.19-rc2-ac2 pdc202xx.c update support
2002-07-22  6:35   ` Francois Romieu
2002-07-23  1:05     ` support
2002-07-23  7:19       ` Francois Romieu
2002-07-23 17:08         ` Michal Jaegermann
2002-07-23 10:49 Mikael Pettersson
  -- strict thread matches above, loose matches on Subject: below --
2002-07-19  9:09 support
2002-07-19  9:52 ` Giro
2002-07-19  9:56   ` Giro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox