Message ID | 20210730112930.1184874-1-festevam@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | util: Use a proper cast in the error message | expand |
Hi Christian, On Fri, Jul 30, 2021 at 8:29 AM Fabio Estevam <festevam@gmail.com> wrote: > > Commit 508b824ae456 ("util: Use %llu for printing 'long long unsigned int'") > fixed a build warning, but introduced another one as reported by > Christian Storm: > > include/util.h:91:41: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 9 has type 'long unsigned int' [-Wformat=] > > The reason for this behaviour is because the members of the 'struct statvfs' > are defined with different sizes (32 versus 64 bits) depending > on __USE_FILE_OFFSET64. > > Cast it to (unsigned long long) which can work on both cases. > > Reported-by: Christian Storm <christian.storm@siemens.com> > Signed-off-by: Fabio Estevam <festevam@gmail.com> > --- > Hi Christian, > > Please test it on your system if you have a chance. Does this patch fixes the build warning for you? Thanks
Hi Fabio, > > Commit 508b824ae456 ("util: Use %llu for printing 'long long unsigned int'") > > fixed a build warning, but introduced another one as reported by > > Christian Storm: > > > > include/util.h:91:41: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 9 has type 'long unsigned int' [-Wformat=] > > > > The reason for this behaviour is because the members of the 'struct statvfs' > > are defined with different sizes (32 versus 64 bits) depending > > on __USE_FILE_OFFSET64. > > > > Cast it to (unsigned long long) which can work on both cases. > > > > Reported-by: Christian Storm <christian.storm@siemens.com> > > Signed-off-by: Fabio Estevam <festevam@gmail.com> > > --- > > Hi Christian, > > > > Please test it on your system if you have a chance. > > Does this patch fixes the build warning for you? Indeed, it has fixed the issue and since c9e7753 it's on -master, so, all good and thanks for caring! Kind regards, Christian
diff --git a/core/util.c b/core/util.c index d4ff9408e84f..1210b3753f82 100644 --- a/core/util.c +++ b/core/util.c @@ -1115,7 +1115,7 @@ static bool check_free_space(int fd, long long size, char *fname) if (statvfs.f_bfree * statvfs.f_bsize < size) { ERROR("Not enough free space to extract %s (needed %llu, got %llu)", - fname, size, statvfs.f_bfree * statvfs.f_bsize); + fname, size, (unsigned long long)statvfs.f_bfree * statvfs.f_bsize); return false; }
Commit 508b824ae456 ("util: Use %llu for printing 'long long unsigned int'") fixed a build warning, but introduced another one as reported by Christian Storm: include/util.h:91:41: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 9 has type 'long unsigned int' [-Wformat=] The reason for this behaviour is because the members of the 'struct statvfs' are defined with different sizes (32 versus 64 bits) depending on __USE_FILE_OFFSET64. Cast it to (unsigned long long) which can work on both cases. Reported-by: Christian Storm <christian.storm@siemens.com> Signed-off-by: Fabio Estevam <festevam@gmail.com> --- Hi Christian, Please test it on your system if you have a chance. Thanks core/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)