Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752459AbdFNM10 (ORCPT ); Wed, 14 Jun 2017 08:27:26 -0400 Received: from mail-db5eur01on0063.outbound.protection.outlook.com ([104.47.2.63]:2784 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751863AbdFNM1Y (ORCPT ); Wed, 14 Jun 2017 08:27:24 -0400 From: Laurentiu Tudor To: Greg KH CC: "stuyoder@gmail.com" , "devel@driverdev.osuosl.org" , "arnd@arndb.de" , "marc.zyngier@arm.com" , Roy Pledge , "linux-kernel@vger.kernel.org" , "agraf@suse.de" , "Catalin Horghidan" , Ioana Ciornei , Leo Li , Bharat Bhushan , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v7 02/10] staging: fsl-mc: fix macros with possible side effects Thread-Topic: [PATCH v7 02/10] staging: fsl-mc: fix macros with possible side effects Thread-Index: AQHS4GOe7IcdEDsjVUqvXzA1XmC4+aIimlSAgAG3+YA= Date: Wed, 14 Jun 2017 12:27:17 +0000 Message-ID: <59412B9D.10905@nxp.com> References: <20170608142855.10455-1-laurentiu.tudor@nxp.com> <20170608142855.10455-3-laurentiu.tudor@nxp.com> <20170613101225.GA27165@kroah.com> In-Reply-To: <20170613101225.GA27165@kroah.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [192.88.146.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0401MB2271;7:mlRExp1dGkQKcmVCK6G90oP6bxLffq0Km1c8l1xAqyCQwhy9RB+xRjGmiR6klM2B6kZ96LujTzENrv2SmBEB+FI7k/dcDBgtuUmmCW3C4RUASNsdKAXtdgFsVg1SIlyvWs2QsnkrNShy2Esccq9yyhMhX2dj4MJCgvbaozo4gP+ugKYSiGpNK7iAn8Mj0/HV5ADPP9yaHpXx8XY0nf7T/mQybCcqk1B4AYqtrg14NDGF9A7fH0Dlsxm+xQB8H5jPwwDKhhefB2E5KSMYuo3T47K6UtQOsDHGVNZGL8nRhdyC0Nny4HwEdJeYwvyC/Qu2c/kIwZh/ded9pbUs6mIPvw== x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(6009001)(39850400002)(39400400002)(39840400002)(39450400003)(39410400002)(39860400002)(377454003)(24454002)(4326008)(189998001)(81166006)(86362001)(6246003)(53936002)(110136004)(3280700002)(229853002)(478600001)(8936002)(38730400002)(53546009)(36756003)(3660700001)(25786009)(6116002)(102836003)(5250100002)(2900100001)(3846002)(8676002)(14454004)(99286003)(6506006)(6436002)(54906002)(2906002)(6512007)(6486002)(50986999)(54356999)(76176999)(65816999)(7736002)(5660300001)(33656002)(66066001)(305945005)(2950100002)(6916009)(39060400002)(56340200001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB2271;H:VI1PR0401MB1856.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; x-ms-traffictypediagnostic: VI1PR0401MB2271: x-ms-office365-filtering-correlation-id: 5e26a0e6-f472-4d24-0a83-08d4b320b23e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:VI1PR0401MB2271; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123560025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:VI1PR0401MB2271;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:VI1PR0401MB2271; x-forefront-prvs: 033857D0BD spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="Windows-1252" Content-ID: <45EDEB2E06AD474DB417E17980E15164@eurprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jun 2017 12:27:17.5568 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2271 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v5ECRdX7029027 Content-Length: 2581 Lines: 74 On 06/13/2017 01:12 PM, Greg KH wrote: > On Thu, Jun 08, 2017 at 05:28:47PM +0300, laurentiu.tudor@nxp.com wrote: >> From: Laurentiu Tudor >> >> Several macros were triggering this checkpatch.pl warning: >> "Macro argument reuse '$arg' - possible side-effects?" >> Fix the warning by avoiding multiple macro argument use. >> >> Signed-off-by: Laurentiu Tudor >> --- >> >> Notes: >> -v7 >> -no changes >> >> drivers/staging/fsl-mc/bus/dprc-driver.c | 10 +++++++--- >> drivers/staging/fsl-mc/bus/fsl-mc-allocator.c | 11 +++++++---- >> 2 files changed, 14 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c >> index d723c69..39c9a3b 100644 >> --- a/drivers/staging/fsl-mc/bus/dprc-driver.c >> +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c >> @@ -21,9 +21,13 @@ >> >> #define FSL_MC_DPRC_DRIVER_NAME "fsl_mc_dprc" >> >> -#define FSL_MC_DEVICE_MATCH(_mc_dev, _obj_desc) \ >> - (strcmp((_mc_dev)->obj_desc.type, (_obj_desc)->type) == 0 && \ >> - (_mc_dev)->obj_desc.id == (_obj_desc)->id) >> +#define FSL_MC_DEVICE_MATCH(_mc_dev, _obj_desc) \ >> +({ \ >> + struct fsl_mc_device *__mc_dev = _mc_dev; \ >> + struct dprc_obj_desc *__obj_desc = _obj_desc; \ >> + (strcmp(__mc_dev->obj_desc.type, __obj_desc->type) == 0 && \ >> + __mc_dev->obj_desc.id == __obj_desc->id); \ >> +}) > > Ick, no. Just make this a real function please. > >> >> struct dprc_child_objs { >> int child_count; >> diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c >> index ce07096..d3def40 100644 >> --- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c >> +++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c >> @@ -17,10 +17,13 @@ >> #include "dpcon-cmd.h" >> #include "fsl-mc-private.h" >> >> -#define FSL_MC_IS_ALLOCATABLE(_obj_type) \ >> - (strcmp(_obj_type, "dpbp") == 0 || \ >> - strcmp(_obj_type, "dpmcp") == 0 || \ >> - strcmp(_obj_type, "dpcon") == 0) >> +#define FSL_MC_IS_ALLOCATABLE(_obj_type) \ >> +({ \ >> + const char *__obj_type = _obj_type; \ >> + (strcmp(__obj_type, "dpbp") == 0 || \ >> + strcmp(__obj_type, "dpmcp") == 0 || \ >> + strcmp(__obj_type, "dpcon") == 0); \ >> +}) > > Same here. Don't put real logic in a #define, it never makes sense to > do it and only makes things much harder to debug. > Ok, will do. Lets drop this patch and i'll send another one changing all these to functions. --- Thanks & Best Regards, Laurentiu