linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: Fix macro definition
@ 2016-12-03 10:11 Chinmay VS
  2016-12-03 10:22 ` Greg KH
  2016-12-03 20:24 ` kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Chinmay VS @ 2016-12-03 10:11 UTC (permalink / raw)
  To: gregkh, elder, johan, pure.logic; +Cc: devel, linux-kernel, ChinmayVS

From: ChinmayVS <cvs268@gmail.com>

Macros with multiple statements should be enclosed in a do - while loop

Signed-off-by: ChinmayVS <cvs268@gmail.com>
---
 drivers/staging/greybus/loopback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 7882306..39f0a25 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -177,9 +177,11 @@ static ssize_t name##_avg_show(struct device *dev,		\
 static DEVICE_ATTR_RO(name##_avg)
 
 #define gb_loopback_stats_attrs(field)				\
+do {								\
 	gb_loopback_ro_stats_attr(field, min, u);		\
 	gb_loopback_ro_stats_attr(field, max, u);		\
-	gb_loopback_ro_avg_attr(field)
+	gb_loopback_ro_avg_attr(field)				\
+} while (0)
 
 #define gb_loopback_attr(field, type)					\
 static ssize_t field##_show(struct device *dev,				\
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: greybus: Fix macro definition
  2016-12-03 10:11 [PATCH] staging: greybus: Fix macro definition Chinmay VS
@ 2016-12-03 10:22 ` Greg KH
  2016-12-03 10:47   ` Chinmay V S
  2016-12-03 20:24 ` kbuild test robot
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2016-12-03 10:22 UTC (permalink / raw)
  To: Chinmay VS; +Cc: elder, johan, pure.logic, devel, linux-kernel

On Sat, Dec 03, 2016 at 03:41:19PM +0530, Chinmay VS wrote:
> From: ChinmayVS <cvs268@gmail.com>
> 
> Macros with multiple statements should be enclosed in a do - while loop
> 
> Signed-off-by: ChinmayVS <cvs268@gmail.com>
> ---
>  drivers/staging/greybus/loopback.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
> index 7882306..39f0a25 100644
> --- a/drivers/staging/greybus/loopback.c
> +++ b/drivers/staging/greybus/loopback.c
> @@ -177,9 +177,11 @@ static ssize_t name##_avg_show(struct device *dev,		\
>  static DEVICE_ATTR_RO(name##_avg)
>  
>  #define gb_loopback_stats_attrs(field)				\
> +do {								\
>  	gb_loopback_ro_stats_attr(field, min, u);		\
>  	gb_loopback_ro_stats_attr(field, max, u);		\
> -	gb_loopback_ro_avg_attr(field)
> +	gb_loopback_ro_avg_attr(field)				\
> +} while (0)
>  
>  #define gb_loopback_attr(field, type)					\
>  static ssize_t field##_show(struct device *dev,				\

Always build test your changes so you don't get a grumpy maintainer
yelling at you for not test-building your patches...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: greybus: Fix macro definition
  2016-12-03 10:22 ` Greg KH
@ 2016-12-03 10:47   ` Chinmay V S
  0 siblings, 0 replies; 4+ messages in thread
From: Chinmay V S @ 2016-12-03 10:47 UTC (permalink / raw)
  To: Greg KH; +Cc: elder, johan, Bryan O'Donoghue, devel, linux-kernel

On Sat, Dec 3, 2016 at 3:52 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Sat, Dec 03, 2016 at 03:41:19PM +0530, Chinmay VS wrote:
>> From: ChinmayVS <cvs268@gmail.com>
>>
>> Macros with multiple statements should be enclosed in a do - while loop
>>
>> Signed-off-by: ChinmayVS <cvs268@gmail.com>
>> ---
>>  drivers/staging/greybus/loopback.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
>> index 7882306..39f0a25 100644
>> --- a/drivers/staging/greybus/loopback.c
>> +++ b/drivers/staging/greybus/loopback.c
>> @@ -177,9 +177,11 @@ static ssize_t name##_avg_show(struct device *dev,               \
>>  static DEVICE_ATTR_RO(name##_avg)
>>
>>  #define gb_loopback_stats_attrs(field)                               \
>> +do {                                                         \
>>       gb_loopback_ro_stats_attr(field, min, u);               \
>>       gb_loopback_ro_stats_attr(field, max, u);               \
>> -     gb_loopback_ro_avg_attr(field)
>> +     gb_loopback_ro_avg_attr(field)                          \
>> +} while (0)
>>
>>  #define gb_loopback_attr(field, type)                                        \
>>  static ssize_t field##_show(struct device *dev,                              \
>
> Always build test your changes so you don't get a grumpy maintainer
> yelling at you for not test-building your patches...
>

Thanks. My bad.
Now that i tried and saw it doesn't even build, i see my mistake.
gb_loopback_stats_attrs() is used to define functions from a template.
The macro is not in any function by itself already.

Back to running checkpatch and finding other ERRORs to cleanup in staging.
(will remember to +V before pushing to the mailing list.)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: greybus: Fix macro definition
  2016-12-03 10:11 [PATCH] staging: greybus: Fix macro definition Chinmay VS
  2016-12-03 10:22 ` Greg KH
@ 2016-12-03 20:24 ` kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2016-12-03 20:24 UTC (permalink / raw)
  To: Chinmay VS
  Cc: kbuild-all, gregkh, elder, johan, pure.logic, devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 12380 bytes --]

Hi ChinmayVS,

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v4.9-rc7 next-20161202]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chinmay-VS/staging-greybus-Fix-macro-definition/20161204-035614
config: i386-randconfig-s0-201649 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

>> drivers/staging/greybus/loopback.c:180:1: error: expected identifier or '(' before 'do'
    do {        \
    ^
>> drivers/staging/greybus/loopback.c:288:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(latency);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:184:3: error: expected identifier or '(' before 'while'
    } while (0)
      ^
>> drivers/staging/greybus/loopback.c:288:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(latency);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:180:1: error: expected identifier or '(' before 'do'
    do {        \
    ^
   drivers/staging/greybus/loopback.c:290:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(requests_per_second);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:184:3: error: expected identifier or '(' before 'while'
    } while (0)
      ^
   drivers/staging/greybus/loopback.c:290:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(requests_per_second);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:180:1: error: expected identifier or '(' before 'do'
    do {        \
    ^
   drivers/staging/greybus/loopback.c:292:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(throughput);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:184:3: error: expected identifier or '(' before 'while'
    } while (0)
      ^
   drivers/staging/greybus/loopback.c:292:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(throughput);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:180:1: error: expected identifier or '(' before 'do'
    do {        \
    ^
   drivers/staging/greybus/loopback.c:294:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(apbridge_unipro_latency);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:184:3: error: expected identifier or '(' before 'while'
    } while (0)
      ^
   drivers/staging/greybus/loopback.c:294:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(apbridge_unipro_latency);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:180:1: error: expected identifier or '(' before 'do'
    do {        \
    ^
   drivers/staging/greybus/loopback.c:296:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(gbphy_firmware_latency);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:184:3: error: expected identifier or '(' before 'while'
    } while (0)
      ^
   drivers/staging/greybus/loopback.c:296:1: note: in expansion of macro 'gb_loopback_stats_attrs'
    gb_loopback_stats_attrs(gbphy_firmware_latency);
    ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:334:3: error: 'dev_attr_latency_min' undeclared here (not in a function)
     &dev_attr_latency_min.attr,
      ^~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:335:3: error: 'dev_attr_latency_max' undeclared here (not in a function)
     &dev_attr_latency_max.attr,
      ^~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:336:3: error: 'dev_attr_latency_avg' undeclared here (not in a function)
     &dev_attr_latency_avg.attr,
      ^~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:337:3: error: 'dev_attr_requests_per_second_min' undeclared here (not in a function)
     &dev_attr_requests_per_second_min.attr,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:338:3: error: 'dev_attr_requests_per_second_max' undeclared here (not in a function)
     &dev_attr_requests_per_second_max.attr,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:339:3: error: 'dev_attr_requests_per_second_avg' undeclared here (not in a function)
     &dev_attr_requests_per_second_avg.attr,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:340:3: error: 'dev_attr_throughput_min' undeclared here (not in a function)
     &dev_attr_throughput_min.attr,
      ^~~~~~~~~~~~~~~~~~~~~~~
>> drivers/staging/greybus/loopback.c:341:3: error: 'dev_attr_throughput_max' undeclared here (not in a function)
     &dev_attr_throughput_max.attr,
      ^~~~~~~~~~~~~~~~~~~~~~~

vim +180 drivers/staging/greybus/loopback.c

   174		do_div(rem, count);						\
   175		return sprintf(buf, "%llu.%06u\n", avg, (u32)rem);		\
   176	}									\
   177	static DEVICE_ATTR_RO(name##_avg)
   178	
   179	#define gb_loopback_stats_attrs(field)				\
 > 180	do {								\
   181		gb_loopback_ro_stats_attr(field, min, u);		\
   182		gb_loopback_ro_stats_attr(field, max, u);		\
   183		gb_loopback_ro_avg_attr(field)				\
 > 184	} while (0)
   185	
   186	#define gb_loopback_attr(field, type)					\
   187	static ssize_t field##_show(struct device *dev,				\
   188				    struct device_attribute *attr,		\
   189				    char *buf)					\
   190	{									\
   191		struct gb_loopback *gb = dev_get_drvdata(dev);			\
   192		return sprintf(buf, "%"#type"\n", gb->field);			\
   193	}									\
   194	static ssize_t field##_store(struct device *dev,			\
   195				    struct device_attribute *attr,		\
   196				    const char *buf,				\
   197				    size_t len)					\
   198	{									\
   199		int ret;							\
   200		struct gb_loopback *gb = dev_get_drvdata(dev);			\
   201		mutex_lock(&gb->mutex);						\
   202		ret = sscanf(buf, "%"#type, &gb->field);			\
   203		if (ret != 1)							\
   204			len = -EINVAL;						\
   205		else								\
   206			gb_loopback_check_attr(gb, bundle);			\
   207		mutex_unlock(&gb->mutex);					\
   208		return len;							\
   209	}									\
   210	static DEVICE_ATTR_RW(field)
   211	
   212	#define gb_dev_loopback_ro_attr(field, conn)				\
   213	static ssize_t field##_show(struct device *dev,		\
   214				    struct device_attribute *attr,		\
   215				    char *buf)					\
   216	{									\
   217		struct gb_loopback *gb = dev_get_drvdata(dev);			\
   218		return sprintf(buf, "%u\n", gb->field);				\
   219	}									\
   220	static DEVICE_ATTR_RO(field)
   221	
   222	#define gb_dev_loopback_rw_attr(field, type)				\
   223	static ssize_t field##_show(struct device *dev,				\
   224				    struct device_attribute *attr,		\
   225				    char *buf)					\
   226	{									\
   227		struct gb_loopback *gb = dev_get_drvdata(dev);			\
   228		return sprintf(buf, "%"#type"\n", gb->field);			\
   229	}									\
   230	static ssize_t field##_store(struct device *dev,			\
   231				    struct device_attribute *attr,		\
   232				    const char *buf,				\
   233				    size_t len)					\
   234	{									\
   235		int ret;							\
   236		struct gb_loopback *gb = dev_get_drvdata(dev);			\
   237		mutex_lock(&gb->mutex);						\
   238		ret = sscanf(buf, "%"#type, &gb->field);			\
   239		if (ret != 1)							\
   240			len = -EINVAL;						\
   241		else								\
   242			gb_loopback_check_attr(gb);		\
   243		mutex_unlock(&gb->mutex);					\
   244		return len;							\
   245	}									\
   246	static DEVICE_ATTR_RW(field)
   247	
   248	static void gb_loopback_reset_stats(struct gb_loopback *gb);
   249	static void gb_loopback_check_attr(struct gb_loopback *gb)
   250	{
   251		if (gb->us_wait > GB_LOOPBACK_US_WAIT_MAX)
   252			gb->us_wait = GB_LOOPBACK_US_WAIT_MAX;
   253		if (gb->size > gb_dev.size_max)
   254			gb->size = gb_dev.size_max;
   255		gb->requests_timedout = 0;
   256		gb->requests_completed = 0;
   257		gb->iteration_count = 0;
   258		gb->send_count = 0;
   259		gb->error = 0;
   260	
   261		if (kfifo_depth < gb->iteration_max) {
   262			dev_warn(gb->dev,
   263				 "cannot log bytes %u kfifo_depth %u\n",
   264				 gb->iteration_max, kfifo_depth);
   265		}
   266		kfifo_reset_out(&gb->kfifo_lat);
   267		kfifo_reset_out(&gb->kfifo_ts);
   268	
   269		switch (gb->type) {
   270		case GB_LOOPBACK_TYPE_PING:
   271		case GB_LOOPBACK_TYPE_TRANSFER:
   272		case GB_LOOPBACK_TYPE_SINK:
   273			gb->jiffy_timeout = usecs_to_jiffies(gb->timeout);
   274			if (!gb->jiffy_timeout)
   275				gb->jiffy_timeout = GB_LOOPBACK_TIMEOUT_MIN;
   276			else if (gb->jiffy_timeout > GB_LOOPBACK_TIMEOUT_MAX)
   277				gb->jiffy_timeout = GB_LOOPBACK_TIMEOUT_MAX;
   278			gb_loopback_reset_stats(gb);
   279			wake_up(&gb->wq);
   280			break;
   281		default:
   282			gb->type = 0;
   283			break;
   284		}
   285	}
   286	
   287	/* Time to send and receive one message */
 > 288	gb_loopback_stats_attrs(latency);
   289	/* Number of requests sent per second on this cport */
   290	gb_loopback_stats_attrs(requests_per_second);
   291	/* Quantity of data sent and received on this cport */
   292	gb_loopback_stats_attrs(throughput);
   293	/* Latency across the UniPro link from APBridge's perspective */
   294	gb_loopback_stats_attrs(apbridge_unipro_latency);
   295	/* Firmware induced overhead in the GPBridge */
 > 296	gb_loopback_stats_attrs(gbphy_firmware_latency);
   297	
   298	/* Number of errors encountered during loop */
   299	gb_loopback_ro_attr(error);
   300	/* Number of requests successfully completed async */
   301	gb_loopback_ro_attr(requests_completed);
   302	/* Number of requests timed out async */
   303	gb_loopback_ro_attr(requests_timedout);
   304	/* Timeout minimum in useconds */
   305	gb_loopback_ro_attr(timeout_min);
   306	/* Timeout minimum in useconds */
   307	gb_loopback_ro_attr(timeout_max);
   308	
   309	/*
   310	 * Type of loopback message to send based on protocol type definitions
   311	 * 0 => Don't send message
   312	 * 2 => Send ping message continuously (message without payload)
   313	 * 3 => Send transfer message continuously (message with payload,
   314	 *					   payload returned in response)
   315	 * 4 => Send a sink message (message with payload, no payload in response)
   316	 */
   317	gb_dev_loopback_rw_attr(type, d);
   318	/* Size of transfer message payload: 0-4096 bytes */
   319	gb_dev_loopback_rw_attr(size, u);
   320	/* Time to wait between two messages: 0-1000 ms */
   321	gb_dev_loopback_rw_attr(us_wait, d);
   322	/* Maximum iterations for a given operation: 1-(2^32-1), 0 implies infinite */
   323	gb_dev_loopback_rw_attr(iteration_max, u);
   324	/* The current index of the for (i = 0; i < iteration_max; i++) loop */
   325	gb_dev_loopback_ro_attr(iteration_count, false);
   326	/* A flag to indicate synchronous or asynchronous operations */
   327	gb_dev_loopback_rw_attr(async, u);
   328	/* Timeout of an individual asynchronous request */
   329	gb_dev_loopback_rw_attr(timeout, u);
   330	/* Maximum number of in-flight operations before back-off */
   331	gb_dev_loopback_rw_attr(outstanding_operations_max, u);
   332	
   333	static struct attribute *loopback_attrs[] = {
 > 334		&dev_attr_latency_min.attr,
 > 335		&dev_attr_latency_max.attr,
 > 336		&dev_attr_latency_avg.attr,
 > 337		&dev_attr_requests_per_second_min.attr,
 > 338		&dev_attr_requests_per_second_max.attr,
 > 339		&dev_attr_requests_per_second_avg.attr,
 > 340		&dev_attr_throughput_min.attr,
 > 341		&dev_attr_throughput_max.attr,
 > 342		&dev_attr_throughput_avg.attr,
 > 343		&dev_attr_apbridge_unipro_latency_min.attr,
 > 344		&dev_attr_apbridge_unipro_latency_max.attr,
 > 345		&dev_attr_apbridge_unipro_latency_avg.attr,
 > 346		&dev_attr_gbphy_firmware_latency_min.attr,
 > 347		&dev_attr_gbphy_firmware_latency_max.attr,
 > 348		&dev_attr_gbphy_firmware_latency_avg.attr,
   349		&dev_attr_type.attr,
   350		&dev_attr_size.attr,
   351		&dev_attr_us_wait.attr,

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 22506 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-03 20:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-03 10:11 [PATCH] staging: greybus: Fix macro definition Chinmay VS
2016-12-03 10:22 ` Greg KH
2016-12-03 10:47   ` Chinmay V S
2016-12-03 20:24 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).