All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] f2fs: replace a build-time warning with runtime WARN_ON
@ 2016-10-27 15:32 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-10-27 15:32 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Arnd Bergmann, Fan Li, Weichao Guo, linux-f2fs-devel, linux-kernel

gcc is unsure about the use of last_ofs_in_node, which might happen
without a prior initialization:

fs/f2fs//git/arm-soc/fs/f2fs/data.c: In function ‘f2fs_map_blocks’:
fs/f2fs/data.c:799:54: warning: ‘last_ofs_in_node’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) {

As pointed out by Chao Yu, the code is actually correct as 'prealloc'
is only set if the last_ofs_in_node has been set, the two always
get updated together.

This initializes last_ofs_in_node to dn.ofs_in_node for each
new dnode at the start of the 'next_block' loop, which at that
point is a correct initialization as well. I assume that compilers
that correctly track the contents of the variables and do not
warn about the condition also figure out that they can eliminate
the extra assignment here.

Fixes: 46008c6d4232 ("f2fs: support in batch multi blocks preallocation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

v2: use simpler workaround, as discussed with Chao Yu.

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 68edb47f5f71..cf5ec39f907d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -713,7 +713,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
 	}
 
 	prealloc = 0;
-	ofs_in_node = dn.ofs_in_node;
+	last_ofs_in_node = ofs_in_node = dn.ofs_in_node;
 	end_offset = ADDRS_PER_PAGE(dn.node_page, inode);
 
 next_block:
-- 
2.9.0

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

* [PATCH v2] f2fs: replace a build-time warning with runtime WARN_ON
@ 2016-10-27 15:32 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-10-27 15:32 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: Weichao Guo, linux-kernel, Arnd Bergmann, linux-f2fs-devel

gcc is unsure about the use of last_ofs_in_node, which might happen
without a prior initialization:

fs/f2fs//git/arm-soc/fs/f2fs/data.c: In function ‘f2fs_map_blocks’:
fs/f2fs/data.c:799:54: warning: ‘last_ofs_in_node’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) {

As pointed out by Chao Yu, the code is actually correct as 'prealloc'
is only set if the last_ofs_in_node has been set, the two always
get updated together.

This initializes last_ofs_in_node to dn.ofs_in_node for each
new dnode at the start of the 'next_block' loop, which at that
point is a correct initialization as well. I assume that compilers
that correctly track the contents of the variables and do not
warn about the condition also figure out that they can eliminate
the extra assignment here.

Fixes: 46008c6d4232 ("f2fs: support in batch multi blocks preallocation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

v2: use simpler workaround, as discussed with Chao Yu.

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 68edb47f5f71..cf5ec39f907d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -713,7 +713,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
 	}
 
 	prealloc = 0;
-	ofs_in_node = dn.ofs_in_node;
+	last_ofs_in_node = ofs_in_node = dn.ofs_in_node;
 	end_offset = ADDRS_PER_PAGE(dn.node_page, inode);
 
 next_block:
-- 
2.9.0


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [PATCH v2] f2fs: replace a build-time warning with runtime WARN_ON
  2016-10-27 15:32 ` Arnd Bergmann
@ 2016-11-02  7:09   ` Chao Yu
  -1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2016-11-02  7:09 UTC (permalink / raw)
  To: Arnd Bergmann, Jaegeuk Kim
  Cc: Fan Li, Weichao Guo, linux-f2fs-devel, linux-kernel

Hi Arnd, Jaegeuk,

It is trivial, but it's better keep commit *title*, commit log and code
consistent. :)

Thanks,

On 2016/10/27 23:32, Arnd Bergmann wrote:
> gcc is unsure about the use of last_ofs_in_node, which might happen
> without a prior initialization:
> 
> fs/f2fs//git/arm-soc/fs/f2fs/data.c: In function ‘f2fs_map_blocks’:
> fs/f2fs/data.c:799:54: warning: ‘last_ofs_in_node’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) {
> 
> As pointed out by Chao Yu, the code is actually correct as 'prealloc'
> is only set if the last_ofs_in_node has been set, the two always
> get updated together.
> 
> This initializes last_ofs_in_node to dn.ofs_in_node for each
> new dnode at the start of the 'next_block' loop, which at that
> point is a correct initialization as well. I assume that compilers
> that correctly track the contents of the variables and do not
> warn about the condition also figure out that they can eliminate
> the extra assignment here.
> 
> Fixes: 46008c6d4232 ("f2fs: support in batch multi blocks preallocation")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  fs/f2fs/data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> v2: use simpler workaround, as discussed with Chao Yu.
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 68edb47f5f71..cf5ec39f907d 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -713,7 +713,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
>  	}
>  
>  	prealloc = 0;
> -	ofs_in_node = dn.ofs_in_node;
> +	last_ofs_in_node = ofs_in_node = dn.ofs_in_node;
>  	end_offset = ADDRS_PER_PAGE(dn.node_page, inode);
>  
>  next_block:
> 

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

* Re: [PATCH v2] f2fs: replace a build-time warning with runtime WARN_ON
@ 2016-11-02  7:09   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2016-11-02  7:09 UTC (permalink / raw)
  To: Arnd Bergmann, Jaegeuk Kim; +Cc: Weichao Guo, linux-kernel, linux-f2fs-devel

Hi Arnd, Jaegeuk,

It is trivial, but it's better keep commit *title*, commit log and code
consistent. :)

Thanks,

On 2016/10/27 23:32, Arnd Bergmann wrote:
> gcc is unsure about the use of last_ofs_in_node, which might happen
> without a prior initialization:
> 
> fs/f2fs//git/arm-soc/fs/f2fs/data.c: In function ‘f2fs_map_blocks’:
> fs/f2fs/data.c:799:54: warning: ‘last_ofs_in_node’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) {
> 
> As pointed out by Chao Yu, the code is actually correct as 'prealloc'
> is only set if the last_ofs_in_node has been set, the two always
> get updated together.
> 
> This initializes last_ofs_in_node to dn.ofs_in_node for each
> new dnode at the start of the 'next_block' loop, which at that
> point is a correct initialization as well. I assume that compilers
> that correctly track the contents of the variables and do not
> warn about the condition also figure out that they can eliminate
> the extra assignment here.
> 
> Fixes: 46008c6d4232 ("f2fs: support in batch multi blocks preallocation")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  fs/f2fs/data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> v2: use simpler workaround, as discussed with Chao Yu.
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 68edb47f5f71..cf5ec39f907d 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -713,7 +713,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
>  	}
>  
>  	prealloc = 0;
> -	ofs_in_node = dn.ofs_in_node;
> +	last_ofs_in_node = ofs_in_node = dn.ofs_in_node;
>  	end_offset = ADDRS_PER_PAGE(dn.node_page, inode);
>  
>  next_block:
> 


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [PATCH v2] f2fs: replace a build-time warning with runtime WARN_ON
  2016-11-02  7:09   ` Chao Yu
@ 2016-11-02 13:53     ` Arnd Bergmann
  -1 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-11-02 13:53 UTC (permalink / raw)
  To: Chao Yu; +Cc: Jaegeuk Kim, Fan Li, Weichao Guo, linux-f2fs-devel, linux-kernel

On Wednesday 02 November 2016, Chao Yu wrote:
> Hi Arnd, Jaegeuk,
> 
> It is trivial, but it's better keep commit *title*, commit log and code
> consistent. :)

Sorry for my silly mistake, sent it again with a new subject now.

	Arnd

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

* Re: [PATCH v2] f2fs: replace a build-time warning with runtime WARN_ON
@ 2016-11-02 13:53     ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-11-02 13:53 UTC (permalink / raw)
  To: Chao Yu; +Cc: Weichao Guo, Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On Wednesday 02 November 2016, Chao Yu wrote:
> Hi Arnd, Jaegeuk,
> 
> It is trivial, but it's better keep commit *title*, commit log and code
> consistent. :)

Sorry for my silly mistake, sent it again with a new subject now.

	Arnd

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

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

end of thread, other threads:[~2016-11-02 13:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 15:32 [PATCH v2] f2fs: replace a build-time warning with runtime WARN_ON Arnd Bergmann
2016-10-27 15:32 ` Arnd Bergmann
2016-11-02  7:09 ` Chao Yu
2016-11-02  7:09   ` Chao Yu
2016-11-02 13:53   ` Arnd Bergmann
2016-11-02 13:53     ` Arnd Bergmann

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.