All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: loopback: Fix Coding Style Error
@ 2022-02-17 19:07 Husni Faiz
  2022-02-17 19:26 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Husni Faiz @ 2022-02-17 19:07 UTC (permalink / raw)
  To: pure.logic, elder, gregkh
  Cc: Husni Faiz, greybus-dev, linux-staging, linux-kernel

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

Signed-off-by: Husni Faiz <ahamedhusni73@gmail.com>
---
 drivers/staging/greybus/loopback.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 2471448ba42a..33666a49e0a8 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -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,				\
-- 
2.25.1


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

* Re: [PATCH] staging: greybus: loopback: Fix Coding Style Error
  2022-02-17 19:07 [PATCH] staging: greybus: loopback: Fix Coding Style Error Husni Faiz
@ 2022-02-17 19:26 ` Greg KH
  2022-02-18  4:52   ` Ahamed Husni
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2022-02-17 19:26 UTC (permalink / raw)
  To: Husni Faiz; +Cc: pure.logic, elder, greybus-dev, linux-staging, linux-kernel

On Fri, Feb 18, 2022 at 12:37:22AM +0530, Husni Faiz wrote:
> Macros with multiple statements should be enclosed in a do - while
> block.
> 
> Signed-off-by: Husni Faiz <ahamedhusni73@gmail.com>
> ---
>  drivers/staging/greybus/loopback.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
> index 2471448ba42a..33666a49e0a8 100644
> --- a/drivers/staging/greybus/loopback.c
> +++ b/drivers/staging/greybus/loopback.c
> @@ -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,				\
> -- 
> 2.25.1
> 
> 

Did you try to build this change?

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

* Re: [PATCH] staging: greybus: loopback: Fix Coding Style Error
  2022-02-17 19:26 ` Greg KH
@ 2022-02-18  4:52   ` Ahamed Husni
  2022-02-18  7:10     ` Greg KH
  2022-03-02 15:49     ` [greybus-dev] " Alex Elder
  0 siblings, 2 replies; 5+ messages in thread
From: Ahamed Husni @ 2022-02-18  4:52 UTC (permalink / raw)
  To: Greg KH
  Cc: Bryan O'Donoghue, elder, greybus-dev, linux-staging, linux-kernel

Hi Greg,

On Fri, Feb 18, 2022 at 12:56 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> Did you try to build this change?

I am a newbie kernel dev and trying to understand how things work.
I did not build this change by the time I sent you this, thinking this
is just a style change.
I should have tested the build. I am sorry.

Now I built the changes by setting the following configurations.
CONFIG_GREYBUS
CONFIG_STAGING
CONFIG_GREYBUS_LOOPBACK

My change introduces the following error.
''''
drivers/staging/greybus/loopback.c:166:2: error: expected identifier
or ‘(’ before ‘do’
  166 |  do {            \
      |  ^~
''''
I could not fix or find the reason for this error. Please guide me in
this regard.

Thanks,
Husni.

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

* Re: [PATCH] staging: greybus: loopback: Fix Coding Style Error
  2022-02-18  4:52   ` Ahamed Husni
@ 2022-02-18  7:10     ` Greg KH
  2022-03-02 15:49     ` [greybus-dev] " Alex Elder
  1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2022-02-18  7:10 UTC (permalink / raw)
  To: Ahamed Husni
  Cc: Bryan O'Donoghue, elder, greybus-dev, linux-staging, linux-kernel

On Fri, Feb 18, 2022 at 10:22:28AM +0530, Ahamed Husni wrote:
> Hi Greg,
> 
> On Fri, Feb 18, 2022 at 12:56 AM Greg KH <gregkh@linuxfoundation.org> wrote:
> > Did you try to build this change?
> 
> I am a newbie kernel dev and trying to understand how things work.
> I did not build this change by the time I sent you this, thinking this
> is just a style change.
> I should have tested the build. I am sorry.

You always have to build-test your changes, as you have found out.

> Now I built the changes by setting the following configurations.
> CONFIG_GREYBUS
> CONFIG_STAGING
> CONFIG_GREYBUS_LOOPBACK
> 
> My change introduces the following error.
> ''''
> drivers/staging/greybus/loopback.c:166:2: error: expected identifier
> or ‘(’ before ‘do’
>   166 |  do {            \
>       |  ^~
> ''''
> I could not fix or find the reason for this error. Please guide me in
> this regard.

There is nothing wrong with the original code here.  Remember that
checkpatch is a perl script that gives good advice, but it is not always
correct.  You must always manually check it based on your knowledge of
the C language.

I recommend learning a bit more C before working on kernel code.

Best of luck!

greg k-h

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

* Re: [greybus-dev] Re: [PATCH] staging: greybus: loopback: Fix Coding Style Error
  2022-02-18  4:52   ` Ahamed Husni
  2022-02-18  7:10     ` Greg KH
@ 2022-03-02 15:49     ` Alex Elder
  1 sibling, 0 replies; 5+ messages in thread
From: Alex Elder @ 2022-03-02 15:49 UTC (permalink / raw)
  To: Ahamed Husni, Greg KH; +Cc: elder, greybus-dev, linux-staging, linux-kernel

On 2/17/22 10:52 PM, Ahamed Husni wrote:
> Hi Greg,
> 
> On Fri, Feb 18, 2022 at 12:56 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>> Did you try to build this change?
> 
> I am a newbie kernel dev and trying to understand how things work.
> I did not build this change by the time I sent you this, thinking this
> is just a style change.
> I should have tested the build. I am sorry.
> 
> Now I built the changes by setting the following configurations.
> CONFIG_GREYBUS
> CONFIG_STAGING
> CONFIG_GREYBUS_LOOPBACK
> 
> My change introduces the following error.
> ''''
> drivers/staging/greybus/loopback.c:166:2: error: expected identifier
> or ‘(’ before ‘do’
>    166 |  do {            \
>        |  ^~
> ''''
> I could not fix or find the reason for this error. Please guide me in
> this regard.

You should understand that you cannot contribute to the Linux
kernel if you don't understand details of the C language well.
And you really must test your changes (certainly a build test)
before you send them for review.

To answer your question, the macro you changed does not
expand into code that is itself incorporated in an executable
block.  The macro is used to generate entire functions in a
unified way.

					-Alex

> 
> Thanks,
> Husni.
> _______________________________________________
> greybus-dev mailing list -- greybus-dev@lists.linaro.org
> To unsubscribe send an email to greybus-dev-leave@lists.linaro.org


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

end of thread, other threads:[~2022-03-02 15:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 19:07 [PATCH] staging: greybus: loopback: Fix Coding Style Error Husni Faiz
2022-02-17 19:26 ` Greg KH
2022-02-18  4:52   ` Ahamed Husni
2022-02-18  7:10     ` Greg KH
2022-03-02 15:49     ` [greybus-dev] " Alex Elder

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.