linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: erofs: Add braces to do-while statements
@ 2018-12-09 15:59 Thomas Jespersen
  2018-12-09 16:20 ` Greg KH
  2018-12-09 21:37 ` Gao Xiang
  0 siblings, 2 replies; 7+ messages in thread
From: Thomas Jespersen @ 2018-12-09 15:59 UTC (permalink / raw)
  To: gaoxiang25, yuchao0; +Cc: gregkh, linux-erofs, linux-kernel, Thomas Jespersen

This fixes warning reported by sparse (with -Wsparse-all).

Signed-off-by: Thomas Jespersen <laumann.thomas@gmail.com>
---
 drivers/staging/erofs/internal.h | 4 ++--
 drivers/staging/erofs/utils.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
index 57575c7f5635..bf180a803446 100644
--- a/drivers/staging/erofs/internal.h
+++ b/drivers/staging/erofs/internal.h
@@ -232,9 +232,9 @@ static inline bool erofs_workgroup_get(struct erofs_workgroup *grp, int *ocnt)
 	/* spin if it is temporarily locked at the reclaim path */
 	if (unlikely(o == locked)) {
 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
-		do
+		do {
 			cpu_relax();
-		while (atomic_read(&grp->refcount) == locked);
+		} while (atomic_read(&grp->refcount) == locked);
 #endif
 		goto repeat;
 	}
diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c
index ea8a962e5c95..cd76df4a48c7 100644
--- a/drivers/staging/erofs/utils.c
+++ b/drivers/staging/erofs/utils.c
@@ -217,9 +217,9 @@ unsigned long erofs_shrink_scan(struct shrinker *shrink,
 	unsigned long freed = 0;
 
 	spin_lock(&erofs_sb_list_lock);
-	do
+	do {
 		run_no = ++shrinker_run_no;
-	while (run_no == 0);
+	} while (run_no == 0);
 
 	/* Iterate over all mounted superblocks and try to shrink them */
 	p = erofs_sb_list.next;
-- 
2.19.2


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

* Re: [PATCH] staging: erofs: Add braces to do-while statements
  2018-12-09 15:59 [PATCH] staging: erofs: Add braces to do-while statements Thomas Jespersen
@ 2018-12-09 16:20 ` Greg KH
  2018-12-09 17:27   ` Joe Perches
  2018-12-09 17:30   ` Joe Perches
  2018-12-09 21:37 ` Gao Xiang
  1 sibling, 2 replies; 7+ messages in thread
From: Greg KH @ 2018-12-09 16:20 UTC (permalink / raw)
  To: Thomas Jespersen; +Cc: gaoxiang25, yuchao0, linux-erofs, linux-kernel

On Sun, Dec 09, 2018 at 04:59:00PM +0100, Thomas Jespersen wrote:
> This fixes warning reported by sparse (with -Wsparse-all).

Why is sparse warning about this?

> Signed-off-by: Thomas Jespersen <laumann.thomas@gmail.com>
> ---
>  drivers/staging/erofs/internal.h | 4 ++--
>  drivers/staging/erofs/utils.c    | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
> index 57575c7f5635..bf180a803446 100644
> --- a/drivers/staging/erofs/internal.h
> +++ b/drivers/staging/erofs/internal.h
> @@ -232,9 +232,9 @@ static inline bool erofs_workgroup_get(struct erofs_workgroup *grp, int *ocnt)
>  	/* spin if it is temporarily locked at the reclaim path */
>  	if (unlikely(o == locked)) {
>  #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
> -		do
> +		do {
>  			cpu_relax();
> -		while (atomic_read(&grp->refcount) == locked);
> +		} while (atomic_read(&grp->refcount) == locked);

That looks like valid code to me, why change this?

greg k-h

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

* Re: [PATCH] staging: erofs: Add braces to do-while statements
  2018-12-09 16:20 ` Greg KH
@ 2018-12-09 17:27   ` Joe Perches
  2018-12-09 19:40     ` Greg KH
  2018-12-09 17:30   ` Joe Perches
  1 sibling, 1 reply; 7+ messages in thread
From: Joe Perches @ 2018-12-09 17:27 UTC (permalink / raw)
  To: Greg KH, Thomas Jespersen; +Cc: gaoxiang25, yuchao0, linux-erofs, linux-kernel

On Sun, 2018-12-09 at 17:20 +0100, Greg KH wrote:
> On Sun, Dec 09, 2018 at 04:59:00PM +0100, Thomas Jespersen wrote:
> > This fixes warning reported by sparse (with -Wsparse-all).
> 
> Why is sparse warning about this?

Probably because it's the kernel preferred style
to use single statement

	do {
		<foo>;
	} while (<bar>);

over

by about a 20:1 ratio.

> > Signed-off-by: Thomas Jespersen <laumann.thomas@gmail.com>obab
> > ---
> >  drivers/staging/erofs/internal.h | 4 ++--
> >  drivers/staging/erofs/utils.c    | 4 ++--
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
> > index 57575c7f5635..bf180a803446 100644
> > --- a/drivers/staging/erofs/internal.h
> > +++ b/drivers/staging/erofs/internal.h
> > @@ -232,9 +232,9 @@ static inline bool erofs_workgroup_get(struct erofs_workgroup *grp, int *ocnt)
> >  	/* spin if it is temporarily locked at the reclaim path */
> >  	if (unlikely(o == locked)) {
> >  #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
> > -		do
> > +		do {
> >  			cpu_relax();
> > -		while (atomic_read(&grp->refcount) == locked);
> > +		} while (atomic_read(&grp->refcount) == locked);
> 
> That looks like valid code to me, why change this?
> 
> greg k-h


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

* Re: [PATCH] staging: erofs: Add braces to do-while statements
  2018-12-09 16:20 ` Greg KH
  2018-12-09 17:27   ` Joe Perches
@ 2018-12-09 17:30   ` Joe Perches
  1 sibling, 0 replies; 7+ messages in thread
From: Joe Perches @ 2018-12-09 17:30 UTC (permalink / raw)
  To: Greg KH, Thomas Jespersen; +Cc: gaoxiang25, yuchao0, linux-erofs, linux-kernel

(mrph.  premature send)

On Sun, 2018-12-09 at 17:20 +0100, Greg KH wrote:
> On Sun, Dec 09, 2018 at 04:59:00PM +0100, Thomas Jespersen wrote:
> > This fixes warning reported by sparse (with -Wsparse-all).
> 
> Why is sparse warning about this?

Probably because it's the kernel preferred style
to use single statement

	do {
		<foo>;
	} while (<bar>);

over

	do
		<foo>;
	while (<bar>);

by about a 20:1 ratio.



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

* Re: [PATCH] staging: erofs: Add braces to do-while statements
  2018-12-09 17:27   ` Joe Perches
@ 2018-12-09 19:40     ` Greg KH
  2018-12-10  0:42       ` Luc Van Oostenryck
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2018-12-09 19:40 UTC (permalink / raw)
  To: Joe Perches
  Cc: Thomas Jespersen, gaoxiang25, yuchao0, linux-erofs, linux-kernel

On Sun, Dec 09, 2018 at 09:27:01AM -0800, Joe Perches wrote:
> On Sun, 2018-12-09 at 17:20 +0100, Greg KH wrote:
> > On Sun, Dec 09, 2018 at 04:59:00PM +0100, Thomas Jespersen wrote:
> > > This fixes warning reported by sparse (with -Wsparse-all).
> > 
> > Why is sparse warning about this?
> 
> Probably because it's the kernel preferred style
> to use single statement
> 
> 	do {
> 		<foo>;
> 	} while (<bar>);
> 
> over
> 
> by about a 20:1 ratio.

Sparse is spitting out coding style complaints now?


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

* Re: [PATCH] staging: erofs: Add braces to do-while statements
  2018-12-09 15:59 [PATCH] staging: erofs: Add braces to do-while statements Thomas Jespersen
  2018-12-09 16:20 ` Greg KH
@ 2018-12-09 21:37 ` Gao Xiang
  1 sibling, 0 replies; 7+ messages in thread
From: Gao Xiang @ 2018-12-09 21:37 UTC (permalink / raw)
  To: Thomas Jespersen; +Cc: gaoxiang25, yuchao0, gregkh, linux-erofs, linux-kernel

[oops... I found Thomas sent the exactly the same email again.]

On 2018/12/9 23:59, Thomas Jespersen wrote:
> This fixes warning reported by sparse (with -Wsparse-all).
>
> Signed-off-by: Thomas Jespersen <laumann.thomas@gmail.com>
> ---
>  drivers/staging/erofs/internal.h | 4 ++--
>  drivers/staging/erofs/utils.c    | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h
> index 57575c7f5635..bf180a803446 100644
> --- a/drivers/staging/erofs/internal.h
> +++ b/drivers/staging/erofs/internal.h
> @@ -232,9 +232,9 @@ static inline bool erofs_workgroup_get(struct erofs_workgroup *grp, int *ocnt)
>  	/* spin if it is temporarily locked at the reclaim path */
>  	if (unlikely(o == locked)) {
>  #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
> -		do
> +		do {
>  			cpu_relax();
> -		while (atomic_read(&grp->refcount) == locked);
> +		} while (atomic_read(&grp->refcount) == locked);
>  #endif
>  		goto repeat;
>  	}

Could you please check the latest source code? I cannot find the above code...

So I think this patch cannot be applied directly :(

https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/erofs/internal.h?h=staging-next#n260


... and why you send this patch without modification...

https://lists.ozlabs.org/pipermail/linux-erofs/2018-December/001099.html

https://lists.ozlabs.org/pipermail/linux-erofs/2018-December/001100.html


Thanks,

Gao Xiang


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

* Re: [PATCH] staging: erofs: Add braces to do-while statements
  2018-12-09 19:40     ` Greg KH
@ 2018-12-10  0:42       ` Luc Van Oostenryck
  0 siblings, 0 replies; 7+ messages in thread
From: Luc Van Oostenryck @ 2018-12-10  0:42 UTC (permalink / raw)
  To: Greg KH
  Cc: Joe Perches, Thomas Jespersen, gaoxiang25, yuchao0, linux-erofs,
	linux-kernel

On Sun, Dec 09, 2018 at 08:40:29PM +0100, Greg KH wrote:
> On Sun, Dec 09, 2018 at 09:27:01AM -0800, Joe Perches wrote:
> > On Sun, 2018-12-09 at 17:20 +0100, Greg KH wrote:
> > > On Sun, Dec 09, 2018 at 04:59:00PM +0100, Thomas Jespersen wrote:
> > > > This fixes warning reported by sparse (with -Wsparse-all).
> > > 
> > > Why is sparse warning about this?
> > 
> > Probably because it's the kernel preferred style
> > to use single statement
> > 
> > 	do {
> > 		<foo>;
> > 	} while (<bar>);
> > 
> > over
> > 
> > by about a 20:1 ratio.
> 
> Sparse is spitting out coding style complaints now?

To my own surprise, it's effectively sparse that complained:
	warning: do-while statement is not a compound statement

with the flag -Wsparse-all (or -Wdo-while).
But -Wsparse-all is not a flag normally used for the kernel
(or normaly used on anything at all).

-- Luc

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

end of thread, other threads:[~2018-12-10  0:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-09 15:59 [PATCH] staging: erofs: Add braces to do-while statements Thomas Jespersen
2018-12-09 16:20 ` Greg KH
2018-12-09 17:27   ` Joe Perches
2018-12-09 19:40     ` Greg KH
2018-12-10  0:42       ` Luc Van Oostenryck
2018-12-09 17:30   ` Joe Perches
2018-12-09 21:37 ` Gao Xiang

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).