Re: [PATCH 51/64] cachefiles: Implement the I/O routines
From: Nathan Chancellor
Date: Tue Nov 30 2021 - 11:15:26 EST
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@xxxxxxxxxx>
> cc: linux-cachefs@xxxxxxxxxx
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@xxxxxxxxx/
https://lore.kernel.org/r/202111070451.bsfAyznx-lkp@xxxxxxxxx/
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