lkml.org 
[lkml]   [2014]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] input: edt-ft5x06: fixed a macro coding style issue
From
Date
On Tue, 2014-12-09 at 08:34 +0200, Asaf Vertz wrote:
> Fixed a coding style error, macros with complex values should be
> enclosed in parentheses.
[]
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
[]
> @@ -849,10 +849,11 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
> return 0;
> }
>
> -#define EDT_ATTR_CHECKSET(name, reg) \
> +#define EDT_ATTR_CHECKSET(name, reg) { \
> if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \
> pdata->name <= edt_ft5x06_attr_##name.limit_high) \
> - edt_ft5x06_register_write(tsdata, reg, pdata->name)
> + edt_ft5x06_register_write(tsdata, reg, pdata->name); \
> +}

Any time you see a naked if (foo) bar in a macro
prefer to use a do while (0) like;

#define EDT_ATTR_CHECKSET(name, reg) \
do { \
if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \
pdata->name <= edt_ft5x06_attr_##name.limit_high) \
edt_ft5x06_register_write(tsdata, reg, pdata->name); \
while (0)



\
 
 \ /
  Last update: 2014-12-09 08:21    [W:0.054 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site