From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752894AbbF0GFB (ORCPT ); Sat, 27 Jun 2015 02:05:01 -0400 Received: from smtprelay0229.hostedemail.com ([216.40.44.229]:40152 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751828AbbF0GEw (ORCPT ); Sat, 27 Jun 2015 02:04:52 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:69:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3870:3871:3872:4321:5007:6119:6261:7903:9592:10004:10400:10848:11026:11232:11657:11658:11914:12043:12296:12517:12519:12555:12740:13019:13069:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: truck27_d35f6a223834 X-Filterd-Recvd-Size: 2915 Message-ID: <1435385089.9377.72.camel@perches.com> Subject: Re: [PATCH] staging: lustre: obdclass: fix macro coding style issue in uuid.c From: Joe Perches To: Vasiliy Korchagin Cc: oleg.drokin@intel.com, andreas.dilger@intel.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Date: Fri, 26 Jun 2015 23:04:49 -0700 In-Reply-To: <1435383365-25679-1-git-send-email-vasiliy.korchagin@gmail.com> References: <1435380784.9377.69.camel@perches.com> <1435383365-25679-1-git-send-email-vasiliy.korchagin@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2015-06-27 at 06:36 +0100, Vasiliy Korchagin wrote: > This patch fixes the checkpatch.pl error: > > ERROR: Macros with complex values should be enclosed in parentheses > +#define CONSUME(val, ptr) (val) = consume(sizeof(val), (ptr)) > > by expanding it as this macro is used only once. [] > Notes: > Here is another version with macro expansion. Inline function expansion doesn't > seem like a good idea to me as it would make things overcomplicated. It looks like it'd be simpler to use vsprintf extension %pU --- drivers/staging/lustre/lustre/obdclass/uuid.c | 34 +-------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c b/drivers/staging/lustre/lustre/obdclass/uuid.c index ff0a01b..b0b0157 100644 --- a/drivers/staging/lustre/lustre/obdclass/uuid.c +++ b/drivers/staging/lustre/lustre/obdclass/uuid.c @@ -43,40 +43,8 @@ #include "../include/obd_support.h" #include "../include/obd_class.h" - -static inline __u32 consume(int nob, __u8 **ptr) -{ - __u32 value; - - LASSERT(nob <= sizeof(value)); - - for (value = 0; nob > 0; --nob) - value = (value << 8) | *((*ptr)++); - return value; -} - -#define CONSUME(val, ptr) (val) = consume(sizeof(val), (ptr)) - -static void uuid_unpack(class_uuid_t in, __u16 *uu, int nr) -{ - __u8 *ptr = in; - - LASSERT(nr * sizeof(*uu) == sizeof(class_uuid_t)); - - while (nr-- > 0) - CONSUME(uu[nr], &ptr); -} - void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out) { - /* uu as an array of __u16's */ - __u16 uuid[sizeof(class_uuid_t) / sizeof(__u16)]; - - CLASSERT(ARRAY_SIZE(uuid) == 8); - - uuid_unpack(uu, uuid, ARRAY_SIZE(uuid)); - sprintf(out->uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x", - uuid[0], uuid[1], uuid[2], uuid[3], - uuid[4], uuid[5], uuid[6], uuid[7]); + sprintf(out->uuid, "%pU", uu); } EXPORT_SYMBOL(class_uuid_unparse);