All of lore.kernel.org
 help / color / mirror / Atom feed
From: laurentiu.tudor@nxp.com (Laurentiu Tudor)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 02/10] staging: fsl-mc: fix macros with possible side effects
Date: Wed, 14 Jun 2017 12:27:17 +0000	[thread overview]
Message-ID: <59412B9D.10905@nxp.com> (raw)
In-Reply-To: <20170613101225.GA27165@kroah.com>



On 06/13/2017 01:12 PM, Greg KH wrote:
> On Thu, Jun 08, 2017 at 05:28:47PM +0300, laurentiu.tudor at nxp.com wrote:
>> From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>>
>> 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 <laurentiu.tudor@nxp.com>
>> ---
>>
>> 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

WARNING: multiple messages have this Message-ID (diff)
From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: "stuyoder@gmail.com" <stuyoder@gmail.com>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"marc.zyngier@arm.com" <marc.zyngier@arm.com>,
	Roy Pledge <roy.pledge@nxp.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"agraf@suse.de" <agraf@suse.de>,
	"Catalin Horghidan" <catalin.horghidan@nxp.com>,
	Ioana Ciornei <ioana.ciornei@nxp.com>,
	Leo Li <leoyang.li@nxp.com>,
	Bharat Bhushan <bharat.bhushan@nxp.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v7 02/10] staging: fsl-mc: fix macros with possible side effects
Date: Wed, 14 Jun 2017 12:27:17 +0000	[thread overview]
Message-ID: <59412B9D.10905@nxp.com> (raw)
In-Reply-To: <20170613101225.GA27165@kroah.com>



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 <laurentiu.tudor@nxp.com>
>>
>> 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 <laurentiu.tudor@nxp.com>
>> ---
>>
>> 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

  reply	other threads:[~2017-06-14 12:27 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08 14:28 [PATCH v7 00/10] staging: fsl-mc: move bus driver out of staging laurentiu.tudor at nxp.com
2017-06-08 14:28 ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 01/10] staging: fsl-mc: enclose macro params in parens laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 02/10] staging: fsl-mc: fix macros with possible side effects laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-13 10:12   ` Greg KH
2017-06-13 10:12     ` Greg KH
2017-06-14 12:27     ` Laurentiu Tudor [this message]
2017-06-14 12:27       ` Laurentiu Tudor
2017-06-08 14:28 ` [PATCH v7 03/10] staging: fsl-mc: simplify couple of deallocations laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 04/10] staging: fsl-mc: drop a few useless #includes laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 05/10] staging: fsl-mc: remove extra blank line laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 06/10] staging: fsl-mc: drop unused forward declaration laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 07/10] staging: fsl-mc: add binding path to MAINTAINERS laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 08/10] staging: fsl-mc: drop reference to restool laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 09/10] staging: fsl-mc: add reference to mc-bus DT binding laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-08 14:28 ` [PATCH v7 10/10] staging: fsl-mc: move bus driver out of staging laurentiu.tudor at nxp.com
2017-06-08 14:28   ` laurentiu.tudor
2017-06-13 10:22   ` Greg KH
2017-06-13 10:22     ` Greg KH
2017-06-14 13:38     ` Laurentiu Tudor
2017-06-14 13:38       ` Laurentiu Tudor
2017-06-14 13:48       ` Greg KH
2017-06-14 13:48         ` Greg KH

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=59412B9D.10905@nxp.com \
    --to=laurentiu.tudor@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.