public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* Re: [PATCH 51/64] cachefiles: Implement the I/O routines
       [not found] ` <163819647945.215744.17827962047487125939.stgit@warthog.procyon.org.uk>
@ 2021-11-30 16:15   ` Nathan Chancellor
  2021-11-30 21:05     ` David Howells
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2021-11-30 16:15 UTC (permalink / raw)
  To: David Howells
  Cc: linux-cachefs, Trond Myklebust, Anna Schumaker, Steve French,
	Dominique Martinet, Jeff Layton, Matthew Wilcox, Alexander Viro,
	Omar Sandoval, Linus Torvalds, linux-afs, linux-nfs, linux-cifs,
	ceph-devel, v9fs-developer, linux-fsdevel, linux-kernel, llvm

On Mon, Nov 29, 2021 at 02:34:39PM +0000, David Howells wrote:
> Implement the I/O routines for cachefiles.  There are two sets of routines
> here: preparation and actual I/O.
> 
> Preparation for read involves looking to see whether there is data present,
> and how much.  Netfslib tells us what it wants us to do and we have the
> option of adjusting shrinking and telling it whether to read from the
> cache, download from the server or simply clear a region.
> 
> Preparation for write involves checking for space and defending against
> possibly running short of space, if necessary punching out a hole in the
> file so that we don't leave old data in the cache if we update the
> coherency information.
> 
> Then there's a read routine and a write routine.  They wait for the cookie
> state to move to something appropriate and then start a potentially
> asynchronous direct I/O operation upon it.
> 
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: linux-cachefs@redhat.com

This patch as commit 0443b01eccbb ("cachefiles: Implement the I/O
routines") in -next causes the following clang warning/error:

fs/cachefiles/io.c:489:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (pos == 0)
            ^~~~~~~~
fs/cachefiles/io.c:492:6: note: uninitialized use occurs here
        if (ret < 0) {
            ^~~
fs/cachefiles/io.c:489:2: note: remove the 'if' if its condition is always true
        if (pos == 0)
        ^~~~~~~~~~~~~
fs/cachefiles/io.c:440:9: note: initialize the variable 'ret' to silence this warning
        int ret;
               ^
                = 0
1 error generated.

It is the same one that has been reported two other times over the past
two months:

https://lore.kernel.org/r/202110150048.HPNa2Mn7-lkp@intel.com/
https://lore.kernel.org/r/202111070451.bsfAyznx-lkp@intel.com/

Should ret just be initialized to zero or does it need to be set to
something else if pos is not equal to zero at the end?

Cheers,
Nathan

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

* Re: [PATCH 51/64] cachefiles: Implement the I/O routines
  2021-11-30 16:15   ` [PATCH 51/64] cachefiles: Implement the I/O routines Nathan Chancellor
@ 2021-11-30 21:05     ` David Howells
  0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2021-11-30 21:05 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: dhowells, linux-cachefs, Trond Myklebust, Anna Schumaker,
	Steve French, Dominique Martinet, Jeff Layton, Matthew Wilcox,
	Alexander Viro, Omar Sandoval, Linus Torvalds, linux-afs,
	linux-nfs, linux-cifs, ceph-devel, v9fs-developer, linux-fsdevel,
	linux-kernel, llvm

Nathan Chancellor <nathan@kernel.org> wrote:

> This patch as commit 0443b01eccbb ("cachefiles: Implement the I/O
> routines") in -next causes the following clang warning/error:
> 
> fs/cachefiles/io.c:489:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>         if (pos == 0)
>             ^~~~~~~~
> fs/cachefiles/io.c:492:6: note: uninitialized use occurs here
>         if (ret < 0) {
>             ^~~
> fs/cachefiles/io.c:489:2: note: remove the 'if' if its condition is always true
>         if (pos == 0)
>         ^~~~~~~~~~~~~
> fs/cachefiles/io.c:440:9: note: initialize the variable 'ret' to silence this warning
>         int ret;
>                ^
>                 = 0
> 1 error generated.

	pos = cachefiles_inject_remove_error();
	if (pos == 0)
		ret = vfs_fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,

That should be:

	ret = cachefiles_inject_remove_error();
	if (ret == 0)
		ret = vfs_fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,

David


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

end of thread, other threads:[~2021-11-30 21:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <163819575444.215744.318477214576928110.stgit@warthog.procyon.org.uk>
     [not found] ` <163819647945.215744.17827962047487125939.stgit@warthog.procyon.org.uk>
2021-11-30 16:15   ` [PATCH 51/64] cachefiles: Implement the I/O routines Nathan Chancellor
2021-11-30 21:05     ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox