Skip to contentSkip to conversation

Coding style fix

PATCH In review Fatih YILDIRIM 3 participants 4 messages Feb 10, 2021 – Feb 11, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Coding style fix

Hi,
I have a coding style fix in greybus subsystem.

By the way, I'm following the Eudyptula Challenge Linux kernel tasks and this patch is related to my task no 10. I hope I'm doing it the right way. Thanks for your understanding and kind comments.

Fatih YILDIRIM (1):
Macros with multiple statements should be enclosed in a do - while
loop.

 drivers/staging/greybus/loopback.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 Macros with multiple statements should be enclosed in a do - while loop.

---
 drivers/staging/greybus/loopback.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/greybus/loopback.c +6 -4
index 2471448ba42a..c88ef3e894fa 100644
@@ -162,10 +162,12 @@ static ssize_t name##_avg_show(struct device *dev,		\
 }									\
 static DEVICE_ATTR_RO(name##_avg)
 
-#define gb_loopback_stats_attrs(field)				\
-	gb_loopback_ro_stats_attr(field, min, u);		\
-	gb_loopback_ro_stats_attr(field, max, u);		\
-	gb_loopback_ro_avg_attr(field)
+#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);				\
+	} while (0)
 
 #define gb_loopback_attr(field, type)					\
 static ssize_t field##_show(struct device *dev,				\
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 1/1] Macros with multiple statements should be enclosed in a do - while loop.

Thank you for the patch! Yet something to improve:

Hi Fatih,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on v5.11-rc7 next-20210125]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Fatih-YILDIRIM/Coding-style-fix/20210211-061613
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 6953026f21092199a59f2c641a880b1c4025f932
config: powerpc-randconfig-r026-20210209 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project c9439ca36342fb6013187d0a69aef92736951476)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/0day-ci/linux/commit/68ce21dfbba245eaa3442ad1269237e99aae5d50
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Fatih-YILDIRIM/Coding-style-fix/20210211-061613 git checkout 68ce21dfbba245eaa3442ad1269237e99aae5d50
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> drivers/staging/greybus/loopback.c:273:1: error: expected identifier or '('
   gb_loopback_stats_attrs(latency);
   ^
   drivers/staging/greybus/loopback.c:166:2: note: expanded from macro 'gb_loopback_stats_attrs'
           do {                                                            \
           ^
>> drivers/staging/greybus/loopback.c:273:1: error: expected identifier or '('
   drivers/staging/greybus/loopback.c:170:4: note: expanded from macro 'gb_loopback_stats_attrs'
           } while (0)
             ^
   drivers/staging/greybus/loopback.c:275:1: error: expected identifier or '('
   gb_loopback_stats_attrs(requests_per_second);
   ^
   drivers/staging/greybus/loopback.c:166:2: note: expanded from macro 'gb_loopback_stats_attrs'
           do {                                                            \
           ^
   drivers/staging/greybus/loopback.c:275:1: error: expected identifier or '('
   drivers/staging/greybus/loopback.c:170:4: note: expanded from macro 'gb_loopback_stats_attrs'
           } while (0)
             ^
   drivers/staging/greybus/loopback.c:277:1: error: expected identifier or '('
   gb_loopback_stats_attrs(throughput);
   ^
   drivers/staging/greybus/loopback.c:166:2: note: expanded from macro 'gb_loopback_stats_attrs'
           do {                                                            \
           ^
   drivers/staging/greybus/loopback.c:277:1: error: expected identifier or '('
   drivers/staging/greybus/loopback.c:170:4: note: expanded from macro 'gb_loopback_stats_attrs'
           } while (0)
             ^
   drivers/staging/greybus/loopback.c:279:1: error: expected identifier or '('
   gb_loopback_stats_attrs(apbridge_unipro_latency);
   ^
   drivers/staging/greybus/loopback.c:166:2: note: expanded from macro 'gb_loopback_stats_attrs'
           do {                                                            \
           ^
   drivers/staging/greybus/loopback.c:279:1: error: expected identifier or '('
   drivers/staging/greybus/loopback.c:170:4: note: expanded from macro 'gb_loopback_stats_attrs'
           } while (0)
             ^
   drivers/staging/greybus/loopback.c:281:1: error: expected identifier or '('
   gb_loopback_stats_attrs(gbphy_firmware_latency);
   ^
   drivers/staging/greybus/loopback.c:166:2: note: expanded from macro 'gb_loopback_stats_attrs'
           do {                                                            \
           ^
   drivers/staging/greybus/loopback.c:281:1: error: expected identifier or '('
   drivers/staging/greybus/loopback.c:170:4: note: expanded from macro 'gb_loopback_stats_attrs'
           } while (0)
             ^
>> drivers/staging/greybus/loopback.c:319:3: error: use of undeclared identifier 'dev_attr_latency_min'; did you mean 'dev_attr_timeout_min'?
           &dev_attr_latency_min.attr,
            ^~~~~~~~~~~~~~~~~~~~
            dev_attr_timeout_min
   drivers/staging/greybus/loopback.c:290:1: note: 'dev_attr_timeout_min' declared here
   gb_loopback_ro_attr(timeout_min);
   ^
   drivers/staging/greybus/loopback.c:130:8: note: expanded from macro 'gb_loopback_ro_attr'
   static DEVICE_ATTR_RO(field)
          ^
   include/linux/device.h:135:26: note: expanded from macro 'DEVICE_ATTR_RO'
           struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
                                   ^
   <scratch space>:46:1: note: expanded from here
   dev_attr_timeout_min
   ^
>> drivers/staging/greybus/loopback.c:320:3: error: use of undeclared identifier 'dev_attr_latency_max'; did you mean 'dev_attr_timeout_max'?
           &dev_attr_latency_max.attr,
            ^~~~~~~~~~~~~~~~~~~~
            dev_attr_timeout_max
   drivers/staging/greybus/loopback.c:292:1: note: 'dev_attr_timeout_max' declared here
   gb_loopback_ro_attr(timeout_max);
   ^
   drivers/staging/greybus/loopback.c:130:8: note: expanded from macro 'gb_loopback_ro_attr'
   static DEVICE_ATTR_RO(field)
          ^
   include/linux/device.h:135:26: note: expanded from macro 'DEVICE_ATTR_RO'
           struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
                                   ^
   <scratch space>:50:1: note: expanded from here
   dev_attr_timeout_max
   ^
>> drivers/staging/greybus/loopback.c:321:3: error: use of undeclared identifier 'dev_attr_latency_avg'
           &dev_attr_latency_avg.attr,
            ^
>> drivers/staging/greybus/loopback.c:322:3: error: use of undeclared identifier 'dev_attr_requests_per_second_min'
           &dev_attr_requests_per_second_min.attr,
            ^
>> drivers/staging/greybus/loopback.c:323:3: error: use of undeclared identifier 'dev_attr_requests_per_second_max'
           &dev_attr_requests_per_second_max.attr,
            ^
>> drivers/staging/greybus/loopback.c:324:3: error: use of undeclared identifier 'dev_attr_requests_per_second_avg'
           &dev_attr_requests_per_second_avg.attr,
            ^
>> drivers/staging/greybus/loopback.c:325:3: error: use of undeclared identifier 'dev_attr_throughput_min'; did you mean 'dev_attr_timeout_min'?
           &dev_attr_throughput_min.attr,
            ^~~~~~~~~~~~~~~~~~~~~~~
            dev_attr_timeout_min
   drivers/staging/greybus/loopback.c:290:1: note: 'dev_attr_timeout_min' declared here
   gb_loopback_ro_attr(timeout_min);
   ^
   drivers/staging/greybus/loopback.c:130:8: note: expanded from macro 'gb_loopback_ro_attr'
   static DEVICE_ATTR_RO(field)
          ^
   include/linux/device.h:135:26: note: expanded from macro 'DEVICE_ATTR_RO'
           struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
                                   ^
   <scratch space>:46:1: note: expanded from here
   dev_attr_timeout_min
   ^
>> drivers/staging/greybus/loopback.c:326:3: error: use of undeclared identifier 'dev_attr_throughput_max'; did you mean 'dev_attr_timeout_max'?
           &dev_attr_throughput_max.attr,
            ^~~~~~~~~~~~~~~~~~~~~~~
            dev_attr_timeout_max
   drivers/staging/greybus/loopback.c:292:1: note: 'dev_attr_timeout_max' declared here
   gb_loopback_ro_attr(timeout_max);
   ^
   drivers/staging/greybus/loopback.c:130:8: note: expanded from macro 'gb_loopback_ro_attr'
   static DEVICE_ATTR_RO(field)
          ^
   include/linux/device.h:135:26: note: expanded from macro 'DEVICE_ATTR_RO'
           struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
                                   ^
   <scratch space>:50:1: note: expanded from here
   dev_attr_timeout_max
   ^
>> drivers/staging/greybus/loopback.c:327:3: error: use of undeclared identifier 'dev_attr_throughput_avg'
           &dev_attr_throughput_avg.attr,
            ^

fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated.

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

355a7058153e04 Alexandre Bailon 2015-03-31 271

355a7058153e04 Alexandre Bailon 2015-03-31  272  /* Time to send and receive one message */
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @273  gb_loopback_stats_attrs(latency);
583cbf50e0a4c8 Bryan O'Donoghue 2015-07-21  274  /* Number of requests sent per second on this cport */
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  275  gb_loopback_stats_attrs(requests_per_second);
355a7058153e04 Alexandre Bailon 2015-03-31  276  /* Quantity of data sent and received on this cport */
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  277  gb_loopback_stats_attrs(throughput);
1ec5843ee98899 Bryan O'Donoghue 2015-10-15  278  /* Latency across the UniPro link from APBridge's perspective */
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  279  gb_loopback_stats_attrs(apbridge_unipro_latency);
1ec5843ee98899 Bryan O'Donoghue 2015-10-15  280  /* Firmware induced overhead in the GPBridge */
e54b106dd1be50 Sandeep Patil    2016-05-19  281  gb_loopback_stats_attrs(gbphy_firmware_latency);
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  282  
e140c75ed9f689 Bryan O'Donoghue 2015-07-21  283  /* Number of errors encountered during loop */
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  284  gb_loopback_ro_attr(error);
12927835d21127 Bryan O'Donoghue 2015-12-07  285  /* Number of requests successfully completed async */
12927835d21127 Bryan O'Donoghue 2015-12-07  286  gb_loopback_ro_attr(requests_completed);
12927835d21127 Bryan O'Donoghue 2015-12-07  287  /* Number of requests timed out async */
12927835d21127 Bryan O'Donoghue 2015-12-07  288  gb_loopback_ro_attr(requests_timedout);
12927835d21127 Bryan O'Donoghue 2015-12-07  289  /* Timeout minimum in useconds */
12927835d21127 Bryan O'Donoghue 2015-12-07  290  gb_loopback_ro_attr(timeout_min);
12927835d21127 Bryan O'Donoghue 2015-12-07  291  /* Timeout minimum in useconds */
12927835d21127 Bryan O'Donoghue 2015-12-07  292  gb_loopback_ro_attr(timeout_max);
355a7058153e04 Alexandre Bailon 2015-03-31  293  
355a7058153e04 Alexandre Bailon 2015-03-31  294  /*
799a3f03572afa Bryan O'Donoghue 2015-07-21  295   * Type of loopback message to send based on protocol type definitions
355a7058153e04 Alexandre Bailon 2015-03-31  296   * 0 => Don't send message
799a3f03572afa Bryan O'Donoghue 2015-07-21  297   * 2 => Send ping message continuously (message without payload)
006335a02677ed Alex Elder       2015-08-03  298   * 3 => Send transfer message continuously (message with payload,
799a3f03572afa Bryan O'Donoghue 2015-07-21  299   *					   payload returned in response)
799a3f03572afa Bryan O'Donoghue 2015-07-21  300   * 4 => Send a sink message (message with payload, no payload in response)
355a7058153e04 Alexandre Bailon 2015-03-31  301   */
67d1eeceb1aab4 Bryan O'Donoghue 2015-08-17  302  gb_dev_loopback_rw_attr(type, d);
355a7058153e04 Alexandre Bailon 2015-03-31  303  /* Size of transfer message payload: 0-4096 bytes */
67d1eeceb1aab4 Bryan O'Donoghue 2015-08-17  304  gb_dev_loopback_rw_attr(size, u);
48f19ee8244776 Alex Elder       2015-05-11  305  /* Time to wait between two messages: 0-1000 ms */
b36f04fa9417c5 Bryan O'Donoghue 2015-12-07  306  gb_dev_loopback_rw_attr(us_wait, d);
00af6583d15038 Bryan O'Donoghue 2015-07-21  307  /* Maximum iterations for a given operation: 1-(2^32-1), 0 implies infinite */
67d1eeceb1aab4 Bryan O'Donoghue 2015-08-17  308  gb_dev_loopback_rw_attr(iteration_max, u);
67d1eeceb1aab4 Bryan O'Donoghue 2015-08-17  309  /* The current index of the for (i = 0; i < iteration_max; i++) loop */
f06272b283e159 Bryan O'Donoghue 2015-08-17  310  gb_dev_loopback_ro_attr(iteration_count, false);
12927835d21127 Bryan O'Donoghue 2015-12-07  311  /* A flag to indicate synchronous or asynchronous operations */
12927835d21127 Bryan O'Donoghue 2015-12-07  312  gb_dev_loopback_rw_attr(async, u);
12927835d21127 Bryan O'Donoghue 2015-12-07  313  /* Timeout of an individual asynchronous request */
12927835d21127 Bryan O'Donoghue 2015-12-07  314  gb_dev_loopback_rw_attr(timeout, u);
8e3fba55d379bb Bryan O'Donoghue 2015-12-11  315  /* Maximum number of in-flight operations before back-off */
8e3fba55d379bb Bryan O'Donoghue 2015-12-11  316  gb_dev_loopback_rw_attr(outstanding_operations_max, u);
355a7058153e04 Alexandre Bailon 2015-03-31  317  
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  318  static struct attribute *loopback_attrs[] = {
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @319  	&dev_attr_latency_min.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @320  	&dev_attr_latency_max.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @321  	&dev_attr_latency_avg.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @322  	&dev_attr_requests_per_second_min.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @323  	&dev_attr_requests_per_second_max.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @324  	&dev_attr_requests_per_second_avg.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @325  	&dev_attr_throughput_min.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @326  	&dev_attr_throughput_max.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03 @327  	&dev_attr_throughput_avg.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  328  	&dev_attr_apbridge_unipro_latency_min.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  329  	&dev_attr_apbridge_unipro_latency_max.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  330  	&dev_attr_apbridge_unipro_latency_avg.attr,
e54b106dd1be50 Sandeep Patil    2016-05-19  331  	&dev_attr_gbphy_firmware_latency_min.attr,
e54b106dd1be50 Sandeep Patil    2016-05-19  332  	&dev_attr_gbphy_firmware_latency_max.attr,
e54b106dd1be50 Sandeep Patil    2016-05-19  333  	&dev_attr_gbphy_firmware_latency_avg.attr,
355a7058153e04 Alexandre Bailon 2015-03-31  334  	&dev_attr_type.attr,
355a7058153e04 Alexandre Bailon 2015-03-31  335  	&dev_attr_size.attr,
b36f04fa9417c5 Bryan O'Donoghue 2015-12-07  336  	&dev_attr_us_wait.attr,
00af6583d15038 Bryan O'Donoghue 2015-07-21  337  	&dev_attr_iteration_count.attr,
00af6583d15038 Bryan O'Donoghue 2015-07-21  338  	&dev_attr_iteration_max.attr,
12927835d21127 Bryan O'Donoghue 2015-12-07  339  	&dev_attr_async.attr,
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  340  	&dev_attr_error.attr,
12927835d21127 Bryan O'Donoghue 2015-12-07  341  	&dev_attr_requests_completed.attr,
12927835d21127 Bryan O'Donoghue 2015-12-07  342  	&dev_attr_requests_timedout.attr,
12927835d21127 Bryan O'Donoghue 2015-12-07  343  	&dev_attr_timeout.attr,
8e3fba55d379bb Bryan O'Donoghue 2015-12-11  344  	&dev_attr_outstanding_operations_max.attr,
12927835d21127 Bryan O'Donoghue 2015-12-07  345  	&dev_attr_timeout_min.attr,
12927835d21127 Bryan O'Donoghue 2015-12-07  346  	&dev_attr_timeout_max.attr,
f06272b283e159 Bryan O'Donoghue 2015-08-17  347  	NULL,
f06272b283e159 Bryan O'Donoghue 2015-08-17  348  };
8e1d6c336d7497 Bryan O'Donoghue 2015-12-03  349  ATTRIBUTE_GROUPS(loopback);

355a7058153e04 Alexandre Bailon 2015-03-31 350

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

maintainer
#3 lore raw

Re: [PATCH 1/1] Macros with multiple statements should be enclosed in a do - while loop.

In reply to Fatih YILDIRIM
Quoted 29 lines · Fatih YILDIRIM
---
 drivers/staging/greybus/loopback.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/greybus/loopback.c +6 -4
index 2471448ba42a..c88ef3e894fa 100644
@@ -162,10 +162,12 @@ static ssize_t name##_avg_show(struct device *dev,		\
 }									\
 static DEVICE_ATTR_RO(name##_avg)
 
-#define gb_loopback_stats_attrs(field)				\
-	gb_loopback_ro_stats_attr(field, min, u);		\
-	gb_loopback_ro_stats_attr(field, max, u);		\
-	gb_loopback_ro_avg_attr(field)
+#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);				\
+	} while (0)
 
 #define gb_loopback_attr(field, type)					\
 static ssize_t field##_show(struct device *dev,				\
Signature · 1 line
2.20.1

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- Your patch breaks the build.

- You did not specify a description of why the patch is needed, or possibly, any description at all, in the email body. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what is needed in order to properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg, and everyone else, to know what this patch is all about. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what a proper Subject: line should look like.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot