Date: Thu, 17 Aug 2006 15:55:18 -0700 From: Julian Elischer <julian@elischer.org> To: John-Mark Gurney <gurney_j@resnet.uoregon.edu> Cc: usb@freebsd.org, Tofig Suleymanov <tofik@oxygen.az> Subject: Re: USB_ATTACH_SETUP macros question Message-ID: <44E4F3D6.9040808@elischer.org> In-Reply-To: <20060817223716.GW99774@funkthat.com> References: <35069.85.132.32.38.1155816624.squirrel@85.132.32.38> <20060817223716.GW99774@funkthat.com>
index | next in thread | previous in thread | raw e-mail
John-Mark Gurney wrote:
>Tofig Suleymanov wrote this message on Thu, Aug 17, 2006 at 17:10 +0500:
>
>
>>is there anybody to explain why do we have infinite loop inside of
>>USB_ATTACH_SETUP macros inside of usb_port.h ? How does his loop gets
>>escaped when we use it in some usb driver ?
>>
>>#define USB_ATTACH_SETUP \
>> do { \
>> sc->sc_dev = self; \
>> device_set_desc_copy(self, devinfo); \
>> device_printf(self, "%s\n", devinfo); \
>> } while (0);
>>
>>
>
>The real bug here is the extra ; after the while(0) part... because
>if you use it as such:
> if (case)
> USB_ATTACH_SETUP;
> else
> somethingelse;
>
>you will get a compile error due to the double semicolon...
>
>
yes style(9) specifies this form of macro should NOT have the semicolon.
>In cases like this, it is also common to have parens after the macro
>name so that it looks like a function, and not a simple expresion.
>
>
yes
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44E4F3D6.9040808>
