Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752817AbbFDKkE (ORCPT ); Thu, 4 Jun 2015 06:40:04 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:37936 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751373AbbFDKj5 (ORCPT ); Thu, 4 Jun 2015 06:39:57 -0400 X-Sasl-enc: QpJDHMn8jMHDpy5RPWIiKYwiZSjSZkJRJDBj5TFn1Zdt 1433414395 From: Sergei Zviagintsev To: Greg Kroah-Hartman , Daniel Mack , David Herrmann , Djalal Harouni Cc: linux-kernel@vger.kernel.org, Sergei Zviagintsev Subject: [PATCH] kdbus: use parentheses in KDBUS_ITEM_FOREACH macro uniformly Date: Thu, 4 Jun 2015 13:39:29 +0300 Message-Id: <1433414370-17557-2-git-send-email-sergei@s15v.net> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2177 Lines: 55 _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 --- 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)) ]]> 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/