On Thu, Oct 24, 2013 at 9:48 PM, Paul Zimmerman
<paul.zimmer...@synopsys.com> wrote:
>> From: Joe Perches [mailto:j...@perches.com]
>> Sent: Thursday, October 24, 2013 9:34 PM
>>
>> On Fri, 2013-10-25 at 03:52 +0000, Paul Zimmerman wrote:
>> > > From: Dan Williams
>> > > Sent: Thursday, October 24, 2013 12:45 AM
>> > >
>> > > On Thu, Oct 24, 2013 at 12:36 AM, Dan Williams 
>> > > <dan.j.willi...@intel.com> wrote:
>> > > > Permit list_for_each redifinitions like:
>> > > >
>> > > > #define for_each_connector_peer(peer, port, c) \
>> > > >        list_for_each_entry(peer, &(c)->ports, node) \
>> > > >                if (port != peer)
>> > > >
>> > > > ...which triggers:
>> > > > ERROR: Macros with complex values should be enclosed in parenthesis
>> >
>> > Kind of off-topic, but that macro looks a little dangerous. From what I 
>> > have
>> > seen in the kernel, it's usually done something like this:
>> >
>> > #define for_each_connector_peer(peer, port, c) \
>> >     list_for_each_entry(peer, &(c)->ports, node) \
>> >             if (port == peer) {} else
>>
>> That seems pretty non-standard.
>> Look at include/linux/list.h or
>> $ git grep -E "\{\s*\}\s*else"
>>
>> Is there any effective difference?
>
> I fail to see your point. There are no similar constructs in list.h that I
> can see, and the output from git grep agrees with what I wrote.
>
> The difference is that with Dan's macro, this:
>
>         if (foo)
>                 for_each_connector_peer(peer, port, c)
>                         bar();
>         else
>                 ...
>
> Will not interpreted by the compiler as the programmer intended.

Ah yes, that would be nasty.  Thanks.

--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to