mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergei Zviagintsev <sergei@s15v.net>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Daniel Mack <daniel@zonque.org>,
	David Herrmann <dh.herrmann@googlemail.com>,
	Djalal Harouni <tixxdz@opendz.org>
Cc: linux-kernel@vger.kernel.org, Sergei Zviagintsev <sergei@s15v.net>
Subject: [PATCH] kdbus: use parentheses in KDBUS_ITEM_FOREACH macro uniformly
Date: Thu,  4 Jun 2015 13:39:29 +0300	[thread overview]
Message-ID: <1433414370-17557-2-git-send-email-sergei@s15v.net> (raw)

_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.

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


             reply	other threads:[~2015-06-04 10:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-04 10:39 Sergei Zviagintsev [this message]
2015-06-04 11:29 ` David Herrmann
2015-06-04 11:47   ` Sergei Zviagintsev

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=1433414370-17557-2-git-send-email-sergei@s15v.net \
    --to=sergei@s15v.net \
    --cc=daniel@zonque.org \
    --cc=dh.herrmann@googlemail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tixxdz@opendz.org \
    /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®