diff mbox series

[13/24] Don't assume tv_sec is a unsigned long (for NetBSD)

Message ID 20201214163623.2127-14-bouyer@netbsd.org (mailing list archive)
State New, archived
Headers show
Series NetBSD fixes | expand

Commit Message

Manuel Bouyer Dec. 14, 2020, 4:36 p.m. UTC
---
 tools/libs/light/libxl_create.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Roger Pau Monne Dec. 29, 2020, 2:02 p.m. UTC | #1
On Mon, Dec 14, 2020 at 05:36:12PM +0100, Manuel Bouyer wrote:
> ---
>  tools/libs/light/libxl_create.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
> index 321a13e519..44691010bc 100644
> --- a/tools/libs/light/libxl_create.c
> +++ b/tools/libs/light/libxl_create.c
> @@ -496,7 +496,7 @@ int libxl__domain_build(libxl__gc *gc,
>          vments[2] = "image/ostype";
>          vments[3] = "hvm";
>          vments[4] = "start_time";
> -        vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> +        vments[5] = GCSPRINTF("%jd.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);

You don't cast tv_sec to intmax_t here...

>  
>          localents = libxl__calloc(gc, 13, sizeof(char *));
>          i = 0;
> @@ -535,7 +535,7 @@ int libxl__domain_build(libxl__gc *gc,
>          vments[i++] = "image/kernel";
>          vments[i++] = (char *) state->pv_kernel.path;
>          vments[i++] = "start_time";
> -        vments[i++] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> +        vments[i++] = GCSPRINTF("%jd.%02d", (intmax_t)start_time.tv_sec,(int)start_time.tv_usec/10000);

... yet you do it here. I think the first occurrence is missing the
cast?

Thanks, Roger.
Manuel Bouyer Jan. 4, 2021, 10:31 a.m. UTC | #2
On Tue, Dec 29, 2020 at 03:02:15PM +0100, Roger Pau Monné wrote:
> On Mon, Dec 14, 2020 at 05:36:12PM +0100, Manuel Bouyer wrote:
> > ---
> >  tools/libs/light/libxl_create.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
> > index 321a13e519..44691010bc 100644
> > --- a/tools/libs/light/libxl_create.c
> > +++ b/tools/libs/light/libxl_create.c
> > @@ -496,7 +496,7 @@ int libxl__domain_build(libxl__gc *gc,
> >          vments[2] = "image/ostype";
> >          vments[3] = "hvm";
> >          vments[4] = "start_time";
> > -        vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> > +        vments[5] = GCSPRINTF("%jd.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> 
> You don't cast tv_sec to intmax_t here...
> 
> >  
> >          localents = libxl__calloc(gc, 13, sizeof(char *));
> >          i = 0;
> > @@ -535,7 +535,7 @@ int libxl__domain_build(libxl__gc *gc,
> >          vments[i++] = "image/kernel";
> >          vments[i++] = (char *) state->pv_kernel.path;
> >          vments[i++] = "start_time";
> > -        vments[i++] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> > +        vments[i++] = GCSPRINTF("%jd.%02d", (intmax_t)start_time.tv_sec,(int)start_time.tv_usec/10000);
> 
> ... yet you do it here. I think the first occurrence is missing the
> cast?

thanks, fixed.
Roger Pau Monne Jan. 4, 2021, 6:17 p.m. UTC | #3
On Mon, Jan 04, 2021 at 11:31:56AM +0100, Manuel Bouyer wrote:
> On Tue, Dec 29, 2020 at 03:02:15PM +0100, Roger Pau Monné wrote:
> > On Mon, Dec 14, 2020 at 05:36:12PM +0100, Manuel Bouyer wrote:
> > > ---
> > >  tools/libs/light/libxl_create.c | 8 ++++----
> > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
> > > index 321a13e519..44691010bc 100644
> > > --- a/tools/libs/light/libxl_create.c
> > > +++ b/tools/libs/light/libxl_create.c
> > > @@ -496,7 +496,7 @@ int libxl__domain_build(libxl__gc *gc,
> > >          vments[2] = "image/ostype";
> > >          vments[3] = "hvm";
> > >          vments[4] = "start_time";
> > > -        vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> > > +        vments[5] = GCSPRINTF("%jd.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> > 
> > You don't cast tv_sec to intmax_t here...
> > 
> > >  
> > >          localents = libxl__calloc(gc, 13, sizeof(char *));
> > >          i = 0;
> > > @@ -535,7 +535,7 @@ int libxl__domain_build(libxl__gc *gc,
> > >          vments[i++] = "image/kernel";
> > >          vments[i++] = (char *) state->pv_kernel.path;
> > >          vments[i++] = "start_time";
> > > -        vments[i++] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> > > +        vments[i++] = GCSPRINTF("%jd.%02d", (intmax_t)start_time.tv_sec,(int)start_time.tv_usec/10000);
> > 
> > ... yet you do it here. I think the first occurrence is missing the
> > cast?
> 
> thanks, fixed.

Add my:

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Then.

Thanks, Roger.
diff mbox series

Patch

diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index 321a13e519..44691010bc 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -496,7 +496,7 @@  int libxl__domain_build(libxl__gc *gc,
         vments[2] = "image/ostype";
         vments[3] = "hvm";
         vments[4] = "start_time";
-        vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
+        vments[5] = GCSPRINTF("%jd.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
 
         localents = libxl__calloc(gc, 13, sizeof(char *));
         i = 0;
@@ -535,7 +535,7 @@  int libxl__domain_build(libxl__gc *gc,
         vments[i++] = "image/kernel";
         vments[i++] = (char *) state->pv_kernel.path;
         vments[i++] = "start_time";
-        vments[i++] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
+        vments[i++] = GCSPRINTF("%jd.%02d", (intmax_t)start_time.tv_sec,(int)start_time.tv_usec/10000);
         if (state->pv_ramdisk.path) {
             vments[i++] = "image/ramdisk";
             vments[i++] = (char *) state->pv_ramdisk.path;
@@ -1502,7 +1502,7 @@  static void domcreate_stream_done(libxl__egc *egc,
         vments[2] = "image/ostype";
         vments[3] = "hvm";
         vments[4] = "start_time";
-        vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
+        vments[5] = GCSPRINTF("%jd.%02d", (intmax_t)start_time.tv_sec,(int)start_time.tv_usec/10000);
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         vments = libxl__calloc(gc, 11, sizeof(char *));
@@ -1512,7 +1512,7 @@  static void domcreate_stream_done(libxl__egc *egc,
         vments[i++] = "image/kernel";
         vments[i++] = (char *) state->pv_kernel.path;
         vments[i++] = "start_time";
-        vments[i++] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
+        vments[i++] = GCSPRINTF("%jd.%02d", (intmax_t)start_time.tv_sec,(int)start_time.tv_usec/10000);
         if (state->pv_ramdisk.path) {
             vments[i++] = "image/ramdisk";
             vments[i++] = (char *) state->pv_ramdisk.path;