linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: Adjust indentation in remap_verify_area
@ 2019-12-18  3:23 Nathan Chancellor
  2019-12-18  3:50 ` Al Viro
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2019-12-18  3:23 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-fsdevel, linux-kernel, clang-built-linux, Nathan Chancellor

Clang warns:

../fs/read_write.c:1760:3: warning: misleading indentation; statement is
not part of the previous 'if' [-Wmisleading-indentation]
         if (unlikely((loff_t) (pos + len) < 0))
         ^
../fs/read_write.c:1757:2: note: previous statement is here
        if (unlikely(pos < 0 || len < 0))
        ^
1 warning generated.

This warning occurs because there is a space after the tab on this line.
Remove it so that the indentation is consistent with the Linux kernel
coding style and clang no longer warns.

Fixes: 04b38d601239 ("vfs: pull btrfs clone API to vfs layer")
Link: https://github.com/ClangBuiltLinux/linux/issues/828
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 5bbf587f5bc1..c71e863163bd 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1757,7 +1757,7 @@ static int remap_verify_area(struct file *file, loff_t pos, loff_t len,
 	if (unlikely(pos < 0 || len < 0))
 		return -EINVAL;
 
-	 if (unlikely((loff_t) (pos + len) < 0))
+	if (unlikely((loff_t) (pos + len) < 0))
 		return -EINVAL;
 
 	if (unlikely(inode->i_flctx && mandatory_lock(inode))) {
-- 
2.24.1


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

* Re: [PATCH] vfs: Adjust indentation in remap_verify_area
  2019-12-18  3:23 [PATCH] vfs: Adjust indentation in remap_verify_area Nathan Chancellor
@ 2019-12-18  3:50 ` Al Viro
  2019-12-18  5:16   ` [PATCH v2] " Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2019-12-18  3:50 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: linux-fsdevel, linux-kernel, clang-built-linux

On Tue, Dec 17, 2019 at 08:23:51PM -0700, Nathan Chancellor wrote:
> Clang warns:
> 
> ../fs/read_write.c:1760:3: warning: misleading indentation; statement is
> not part of the previous 'if' [-Wmisleading-indentation]
>          if (unlikely((loff_t) (pos + len) < 0))
>          ^
> ../fs/read_write.c:1757:2: note: previous statement is here
>         if (unlikely(pos < 0 || len < 0))
>         ^
> 1 warning generated.
> 
> This warning occurs because there is a space after the tab on this line.
> Remove it so that the indentation is consistent with the Linux kernel
> coding style and clang no longer warns.
> 
> Fixes: 04b38d601239 ("vfs: pull btrfs clone API to vfs layer")
> Link: https://github.com/ClangBuiltLinux/linux/issues/828
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Egads...  This commit message is way, way over the top.

1) the warning is more obscure than the problem it points to.

2) simple "statement accidentally indented one column too deep"
would do just fine

3) crediting the tool is generally a good idea, but in situation
when the quality of warning is that low you'd be better paraphrasing
it and mentioning the tool that has pointed it out.  No need to quote
the verbiage.

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

* [PATCH v2] vfs: Adjust indentation in remap_verify_area
  2019-12-18  3:50 ` Al Viro
@ 2019-12-18  5:16   ` Nathan Chancellor
  2019-12-18 11:04     ` David Sterba
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2019-12-18  5:16 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-fsdevel, linux-kernel, clang-built-linux, Nathan Chancellor

Clang's -Wmisleading-indentation caught an instance in remap_verify_area
where there was a trailing space after a tab. Remove it to get rid of
the warning.

Fixes: 04b38d601239 ("vfs: pull btrfs clone API to vfs layer")
Link: https://github.com/ClangBuiltLinux/linux/issues/828
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---

v1 -> v2:

* Trim warning and simplify patch explanation.

 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 5bbf587f5bc1..c71e863163bd 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1757,7 +1757,7 @@ static int remap_verify_area(struct file *file, loff_t pos, loff_t len,
 	if (unlikely(pos < 0 || len < 0))
 		return -EINVAL;
 
-	 if (unlikely((loff_t) (pos + len) < 0))
+	if (unlikely((loff_t) (pos + len) < 0))
 		return -EINVAL;
 
 	if (unlikely(inode->i_flctx && mandatory_lock(inode))) {
-- 
2.24.1


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

* Re: [PATCH v2] vfs: Adjust indentation in remap_verify_area
  2019-12-18  5:16   ` [PATCH v2] " Nathan Chancellor
@ 2019-12-18 11:04     ` David Sterba
  2019-12-22  3:16       ` Nathan Chancellor
  0 siblings, 1 reply; 5+ messages in thread
From: David Sterba @ 2019-12-18 11:04 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Al Viro, linux-fsdevel, linux-kernel, clang-built-linux

On Tue, Dec 17, 2019 at 10:16:35PM -0700, Nathan Chancellor wrote:
> Clang's -Wmisleading-indentation caught an instance in remap_verify_area
> where there was a trailing space after a tab. Remove it to get rid of
> the warning.
> 
> Fixes: 04b38d601239 ("vfs: pull btrfs clone API to vfs layer")
> Link: https://github.com/ClangBuiltLinux/linux/issues/828
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> 
> v1 -> v2:
> 
> * Trim warning and simplify patch explanation.
> 
>  fs/read_write.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 5bbf587f5bc1..c71e863163bd 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -1757,7 +1757,7 @@ static int remap_verify_area(struct file *file, loff_t pos, loff_t len,
>  	if (unlikely(pos < 0 || len < 0))
>  		return -EINVAL;
>  
> -	 if (unlikely((loff_t) (pos + len) < 0))
> +	if (unlikely((loff_t) (pos + len) < 0))

Instead of just fixing whitespace, can we please fix the undefined
behaviour on this line? pos and len are signed types, there's a helper
to do that in a way that's UB-safe.

And btw here's a patch:

https://lore.kernel.org/linux-fsdevel/20190808123942.19592-1-dsterba@suse.com/

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

* Re: [PATCH v2] vfs: Adjust indentation in remap_verify_area
  2019-12-18 11:04     ` David Sterba
@ 2019-12-22  3:16       ` Nathan Chancellor
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2019-12-22  3:16 UTC (permalink / raw)
  To: David Sterba; +Cc: Al Viro, linux-fsdevel, linux-kernel, clang-built-linux

On Wed, Dec 18, 2019 at 12:04:37PM +0100, David Sterba wrote:
> On Tue, Dec 17, 2019 at 10:16:35PM -0700, Nathan Chancellor wrote:
> > Clang's -Wmisleading-indentation caught an instance in remap_verify_area
> > where there was a trailing space after a tab. Remove it to get rid of
> > the warning.
> > 
> > Fixes: 04b38d601239 ("vfs: pull btrfs clone API to vfs layer")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/828
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> > 
> > v1 -> v2:
> > 
> > * Trim warning and simplify patch explanation.
> > 
> >  fs/read_write.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/read_write.c b/fs/read_write.c
> > index 5bbf587f5bc1..c71e863163bd 100644
> > --- a/fs/read_write.c
> > +++ b/fs/read_write.c
> > @@ -1757,7 +1757,7 @@ static int remap_verify_area(struct file *file, loff_t pos, loff_t len,
> >  	if (unlikely(pos < 0 || len < 0))
> >  		return -EINVAL;
> >  
> > -	 if (unlikely((loff_t) (pos + len) < 0))
> > +	if (unlikely((loff_t) (pos + len) < 0))
> 
> Instead of just fixing whitespace, can we please fix the undefined
> behaviour on this line? pos and len are signed types, there's a helper
> to do that in a way that's UB-safe.
> 
> And btw here's a patch:
> 
> https://lore.kernel.org/linux-fsdevel/20190808123942.19592-1-dsterba@suse.com/

I do not particularly care how this warning gets fixed, just that it
does. I will review that patch like Nick did.

Cheers,
Nathan

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

end of thread, other threads:[~2019-12-22  3:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18  3:23 [PATCH] vfs: Adjust indentation in remap_verify_area Nathan Chancellor
2019-12-18  3:50 ` Al Viro
2019-12-18  5:16   ` [PATCH v2] " Nathan Chancellor
2019-12-18 11:04     ` David Sterba
2019-12-22  3:16       ` Nathan Chancellor

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