FIX: Cast the time_t values to avoid warnings
PATCH v2 1/1 FIX: Cast the time_t values to avoid warnings
I added 4 casts from time_t to unsigned long long int in the libxl_sprintf functions, so there is no warning at compilation time (and no failing with -Werror).
The casting format has been discussed, and since the long long int is preferable, the syntax of the libxl_sprintf second argument has been changed.
--- tools/libxl/libxl_create.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/libxl/libxl_create.c +4 -4
@@ -350,7 +350,7 @@ int libxl__domain_build(libxl__gc *gc, vments[2 ] ="image/ostype" ; vments[3 ] ="hvm" ; vments[4 ] ="start_time" ; - vments[5 ] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[5 ] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(start_time.tv_sec),(int )start_time.tv_usec/10000 ); localents =libxl__calloc (gc,7 ,sizeof (char *)); localents[0 ] ="platform/acpi" ;
@@ -373,7 +373,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++] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[i++] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(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;
@@ -846,7 +846,7 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void, vments[2 ] ="image/ostype" ; vments[3 ] ="hvm" ; vments[4 ] ="start_time" ; - vments[5 ] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[5 ] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(start_time.tv_sec),(int )start_time.tv_usec/10000 );break ;case LIBXL_DOMAIN_TYPE_PV : vments =libxl__calloc (gc,11 ,sizeof (char *));
@@ -856,7 +856,7 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void, vments[i++] ="image/kernel" ; vments[i++] = (char *) state->pv_kernel.path; vments[i++] ="start_time" ; - vments[i++] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[i++] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(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;
Signature · 1 line
1.7.10.4
Quoted 9 lines · On Sun, Apr 28, 2013 at 01:32:16AM +0200, 7heo wrote:
I added 4 casts from
time_tto unsigned long long int in thelibxl_sprintffunctions, so there is no warning at compilation time (and no failing with -Werror).The casting format has been discussed, and since the long long int is preferable, the syntax of the
libxl_sprintfsecond argument has been changed.
That's better :-)
Cheers,
Patrick
Quoted 9 lines · On Sun, 2013-04-28 at 00:32 +0100, 7heo wrote:
I added 4 casts from
time_tto unsigned long long int in thelibxl_sprintffunctions, so there is no warning at compilation time (and no failing with -Werror).The casting format has been discussed, and since the long long int is preferable, the syntax of the
libxl_sprintfsecond argument has been changed.
Thanks.
1
Quoted 10 lines
Signed-off-by 7heo <[email protected]>--- tools/libxl/libxl_create.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/libxl/libxl_create.c +0
-0
tools/libxl/libxl_create.c int libxl__domain_build(libxl__gc *gc, · line 353
Quoted 5 lines
tools/libxl/libxl_create.c +1
-1@@ -350,7 +350,7 @@ int libxl__domain_build(libxl__gc *gc, vments[2 ] ="image/ostype" ; vments[3 ] ="hvm" ; vments[4 ] ="start_time" ; - vments[5 ] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[5 ] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(start_time.tv_sec),(int )start_time.tv_usec/10000 );
These lines were overly long already but now they are really too long, any chance you could wrap them a bit?
You could also consider a cast to uint64_t + PRIx64 which I think would be shorter overall? Switching to GCSPRINTF might also help.
(seems to be a lot of duplicated code here, but that's not your problem().
Quoted 30 lines
tools/libxl/libxl_create.c +3
-3localents =libxl__calloc (gc,7 ,sizeof (char *)); localents[0 ] ="platform/acpi" ;@@ -373,7 +373,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++] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[i++] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(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;@@ -846,7 +846,7 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void, vments[2 ] ="image/ostype" ; vments[3 ] ="hvm" ; vments[4 ] ="start_time" ; - vments[5 ] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[5 ] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(start_time.tv_sec),(int )start_time.tv_usec/10000 );break ;case LIBXL_DOMAIN_TYPE_PV : vments =libxl__calloc (gc,11 ,sizeof (char *));@@ -856,7 +856,7 @@ void libxl__xc_domain_restore_done(libxl__egc *egc, void *dcs_void, vments[i++] ="image/kernel" ; vments[i++] = (char *) state->pv_kernel.path; vments[i++] ="start_time" ; - vments[i++] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[i++] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(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;
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 13 lines · On Mon, 2013-04-29 at 12:08 +0100, [email protected] wrote:
Quoted 5 lines
Quoted 5 lines
tools/libxl/libxl_create.c +0
-0@@ -350,7 +350,7 @@ int libxl__domain_build(libxl__gc *gc,Quoted 8 lines
tools/libxl/libxl_create.c int libxl__domain_build(libxl__gc *gc, · line 353
Quoted 5 lines
tools/libxl/libxl_create.c +1
-1vments[2 ] ="image/ostype" ; vments[3 ] ="hvm" ; vments[4 ] ="start_time" ; - vments[5 ] =libxl__sprintf (gc,"%lu.%02d" , start_time.tv_sec,(int )start_time.tv_usec/10000 ); + vments[5 ] =libxl__sprintf (gc,"%llu.%02d" , (unsigned long long int )(start_time.tv_sec),(int )start_time.tv_usec/10000 );These lines were overly long already but now they are really too long, any chance you could wrap them a bit?
Quoted 1 line
Of course.
Did you send a v3 of this patch which I missed?
Ian.