Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1158492
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Sergei Zviagintsev <sergei@s15v.net> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] kdbus: use parentheses in KDBUS_ITEM_FOREACH macro uniformly |
| Date | Thu, 04 Jun 2015 13:50:02 +0200 |
| Message-ID | <pxBOO-8al-13@gated-at.bofh.it> (permalink) |
| References | <pxASK-6NR-17@gated-at.bofh.it> <pxBvs-7Nj-15@gated-at.bofh.it> |
| X-Original-To | David Herrmann <dh.herrmann@gmail.com> |
| Dkim-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d=s15v.net; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=MEgWy 4Im12rORcDYJqa4rZ0/bxQ=; b=WYYwWLEEc+f9UqQ8Ip0xkyBXa3niYE/Xp83SI m0Lw9kRnrJEoshWsPV3efHpDzmDG2kBHBLEQR5PlgXsYV5Sjhf1n6p2w24oqSHU3 7aZFNBhhdv4azmdCYsqa2ePl1MZHFlgNut5Sa+OAJ2stcGDHQ9ejKjEZkn9l/XnD /KJ4B8= |
| Dkim-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=MEgWy4Im12rORcDYJqa4rZ0/bxQ=; b=JNE2C 9z975H9X3biHuB8orr05xCQe0PPTZUsweaasPP/liBkmUttZkGSuRzv1SGEYYEcy lHVK+r9GB5sjmSAo8YnGpm/9ID8zAm+Ia4w//h20ZH7cpJymSePELrjhJx6SeBw2 G2rwPZhxWWIBGxWwRbm/0S4PJK0HjDWqE2eHQI= |
| X-Sasl-Enc | tO03iNv5QaXWIPAdgh0PwD5qAo87ceFin9z1jZscUocl 1433418464 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 73 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Daniel Mack <daniel@zonque.org>, David Herrmann <dh.herrmann@googlemail.com>, Djalal Harouni <tixxdz@opendz.org>, linux-kernel <linux-kernel@vger.kernel.org> |
| X-Original-Date | Thu, 4 Jun 2015 14:47:43 +0300 |
| X-Original-Message-ID | <20150604114743.GE4549@localhost.localdomain> |
| X-Original-References | <1433414370-17557-2-git-send-email-sergei@s15v.net> <CANq1E4S4vy+BTnj=ifd0NSE3DoSc=aS998Lqt-GCWe5TAXWQyw@mail.gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | aioe.org linux.kernel:1158492 |
Show key headers only | View raw
Hi David, On Thu, Jun 04, 2015 at 01:29:22PM +0200, David Herrmann wrote: > Hi > > On Thu, Jun 4, 2015 at 12:39 PM, Sergei Zviagintsev <sergei@s15v.net> wrote: > > _i is used as loop cursor and must be a proper lvalue, whereas two other > > arguments can be complex expressions. Stay uniform across the macro and > > enclose _is and _s with parentheses in all cases, but keep _i without > > them (any valid lvalue will not break cast to (u8 *) due to precedence > > rules). Update documentation example. > > > > List macroses (e.g. list_for_each) were taken as an example for this > > change. > > I'm not a big fan of this patch. Treating arguments differently just > makes the macros harder to read, imo. Why not keep the parantheses > around all arguments? It doesn't hurt and keeps the style consistent. I agree, the point is just to keep things consistent. I'll send v2. > Besides, lvalues might consist of more complex expressions, so I'm not > sure this is even the right way to go. > > Thanks > David > > > Signed-off-by: Sergei Zviagintsev <sergei@s15v.net> > > --- > > Documentation/kdbus/kdbus.item.xml | 4 ++-- > > ipc/kdbus/item.h | 6 +++--- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/Documentation/kdbus/kdbus.item.xml b/Documentation/kdbus/kdbus.item.xml > > index b0eeeef995af..fb8b6c151a0d 100644 > > --- a/Documentation/kdbus/kdbus.item.xml > > +++ b/Documentation/kdbus/kdbus.item.xml > > @@ -73,8 +73,8 @@ > > > > #define KDBUS_ITEM_FOREACH(item, head, first) \ > > for (item = (head)->first; \ > > - ((uint8_t *)(item) < (uint8_t *)(head) + (head)->size) && \ > > - ((uint8_t *)(item) >= (uint8_t *)(head)); \ > > + ((uint8_t *)item < (uint8_t *)(head) + (head)->size) && \ > > + ((uint8_t *)item >= (uint8_t *)(head)); \ > > item = KDBUS_ITEM_NEXT(item)) > > ]]></programlisting> > > </refsect2> > > diff --git a/ipc/kdbus/item.h b/ipc/kdbus/item.h > > index 03612368b3bb..592b68a7c2db 100644 > > --- a/ipc/kdbus/item.h > > +++ b/ipc/kdbus/item.h > > @@ -28,9 +28,9 @@ > > #define KDBUS_ITEM_PAYLOAD_SIZE(_i) ((_i)->size - KDBUS_ITEM_HEADER_SIZE) > > > > #define KDBUS_ITEMS_FOREACH(_i, _is, _s) \ > > - for (_i = _is; \ > > - ((u8 *)(_i) < (u8 *)(_is) + (_s)) && \ > > - ((u8 *)(_i) >= (u8 *)(_is)); \ > > + for (_i = (_is); \ > > + ((u8 *)_i < (u8 *)(_is) + (_s)) && \ > > + ((u8 *)_i >= (u8 *)(_is)); \ > > _i = KDBUS_ITEM_NEXT(_i)) > > > > #define KDBUS_ITEM_VALID(_i, _is, _s) \ > > -- > > 1.8.3.1 > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] kdbus: use parentheses in KDBUS_ITEM_FOREACH macro uniformly Sergei Zviagintsev <sergei@s15v.net> - 2015-06-04 12:50 +0200
Re: [PATCH] kdbus: use parentheses in KDBUS_ITEM_FOREACH macro uniformly David Herrmann <dh.herrmann@gmail.com> - 2015-06-04 13:30 +0200
Re: [PATCH] kdbus: use parentheses in KDBUS_ITEM_FOREACH macro uniformly Sergei Zviagintsev <sergei@s15v.net> - 2015-06-04 13:50 +0200
csiph-web