diff mbox series

[v2,3/4] xfs_fsr: correct type in fsrprintf() call

Message ID 20240613211933.1169581-4-bodonnel@redhat.com (mailing list archive)
State Superseded, archived
Headers show
Series xfsprogs: coverity fixes | expand

Commit Message

Bill O'Donnell June 13, 2024, 9:09 p.m. UTC
Use %ld instead of %d for howlong variable.

Coverity-id: 1596598

Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>
---
 fsr/xfs_fsr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Darrick J. Wong June 14, 2024, 3:54 a.m. UTC | #1
On Thu, Jun 13, 2024 at 04:09:17PM -0500, Bill O'Donnell wrote:
> Use %ld instead of %d for howlong variable.
> 
> Coverity-id: 1596598
> 
> Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>
> ---
>  fsr/xfs_fsr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> index fdd37756..d204e3a4 100644
> --- a/fsr/xfs_fsr.c
> +++ b/fsr/xfs_fsr.c
> @@ -426,7 +426,7 @@ fsrallfs(char *mtab, time_t howlong, char *leftofffile)
>  	fsdesc_t *fsp;
>  	struct stat sb, sb2;
>  
> -	fsrprintf("xfs_fsr -m %s -t %d -f %s ...\n", mtab, howlong, leftofffile);
> +	fsrprintf("xfs_fsr -m %s -t %ld -f %s ...\n", mtab, howlong, leftofffile);

The exact definition of time_t varies by platform and architecture.
I'd paste that is, but in libc it's a twisty mess of indirection that
eventually ends at 'signed long int' or 'long long int'.

Either way, some linter is likely to balk at this, so you might as well
cast howlong to (long long) and use %lld here.

--D

>  
>  	endtime = starttime + howlong;
>  	fs = fsbase;
> -- 
> 2.45.2
> 
>
Bill O'Donnell June 14, 2024, 3:20 p.m. UTC | #2
On Thu, Jun 13, 2024 at 08:54:08PM -0700, Darrick J. Wong wrote:
> On Thu, Jun 13, 2024 at 04:09:17PM -0500, Bill O'Donnell wrote:
> > Use %ld instead of %d for howlong variable.
> > 
> > Coverity-id: 1596598
> > 
> > Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>
> > ---
> >  fsr/xfs_fsr.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> > index fdd37756..d204e3a4 100644
> > --- a/fsr/xfs_fsr.c
> > +++ b/fsr/xfs_fsr.c
> > @@ -426,7 +426,7 @@ fsrallfs(char *mtab, time_t howlong, char *leftofffile)
> >  	fsdesc_t *fsp;
> >  	struct stat sb, sb2;
> >  
> > -	fsrprintf("xfs_fsr -m %s -t %d -f %s ...\n", mtab, howlong, leftofffile);
> > +	fsrprintf("xfs_fsr -m %s -t %ld -f %s ...\n", mtab, howlong, leftofffile);
> 
> The exact definition of time_t varies by platform and architecture.
> I'd paste that is, but in libc it's a twisty mess of indirection that
> eventually ends at 'signed long int' or 'long long int'.
> 
> Either way, some linter is likely to balk at this, so you might as well
> cast howlong to (long long) and use %lld here.

Good idea. I'll send a v3.
Thanks-
Bill


> 
> --D
> 
> >  
> >  	endtime = starttime + howlong;
> >  	fs = fsbase;
> > -- 
> > 2.45.2
> > 
> > 
>
diff mbox series

Patch

diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index fdd37756..d204e3a4 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -426,7 +426,7 @@  fsrallfs(char *mtab, time_t howlong, char *leftofffile)
 	fsdesc_t *fsp;
 	struct stat sb, sb2;
 
-	fsrprintf("xfs_fsr -m %s -t %d -f %s ...\n", mtab, howlong, leftofffile);
+	fsrprintf("xfs_fsr -m %s -t %ld -f %s ...\n", mtab, howlong, leftofffile);
 
 	endtime = starttime + howlong;
 	fs = fsbase;