diff mbox series

tools/helpers: fix snprintf argument in init-dom0less.c

Message ID 20220629124938.26498-1-luca.fancellu@arm.com (mailing list archive)
State Accepted
Headers show
Series tools/helpers: fix snprintf argument in init-dom0less.c | expand

Commit Message

Luca Fancellu June 29, 2022, 12:49 p.m. UTC
Fix snprintf argument in init-dom0less.c because two instances of
the function are using libxl_dominfo struct members that are uint64_t
types, so change "%lu" to "%"PRIu64 to handle it properly when
building on arm32 and arm64.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
 tools/helpers/init-dom0less.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Bertrand Marquis July 4, 2022, 3:32 p.m. UTC | #1
Hi Luca,

> On 29 Jun 2022, at 13:49, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
> 
> Fix snprintf argument in init-dom0less.c because two instances of
> the function are using libxl_dominfo struct members that are uint64_t
> types, so change "%lu" to "%"PRIu64 to handle it properly when
> building on arm32 and arm64.
> 
> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> tools/helpers/init-dom0less.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c
> index 4c90dd6a0c8f..fee93459c4b9 100644
> --- a/tools/helpers/init-dom0less.c
> +++ b/tools/helpers/init-dom0less.c
> @@ -5,6 +5,7 @@
> #include <stdlib.h>
> #include <sys/mman.h>
> #include <sys/time.h>
> +#include <inttypes.h>
> #include <xenstore.h>
> #include <xenctrl.h>
> #include <xenguest.h>
> @@ -138,10 +139,10 @@ static int create_xenstore(struct xs_handle *xsh,
>                   "vm/" LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
>     if (rc < 0 || rc >= STR_MAX_LENGTH)
>         return rc;
> -    rc = snprintf(max_memkb_str, STR_MAX_LENGTH, "%lu", info->max_memkb);
> +    rc = snprintf(max_memkb_str, STR_MAX_LENGTH, "%"PRIu64, info->max_memkb);
>     if (rc < 0 || rc >= STR_MAX_LENGTH)
>         return rc;
> -    rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%lu", info->current_memkb);
> +    rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%"PRIu64, info->current_memkb);
>     if (rc < 0 || rc >= STR_MAX_LENGTH)
>         return rc;
>     rc = snprintf(ring_ref_str, STR_MAX_LENGTH, "%lld",
> -- 
> 2.17.1
>
Anthony PERARD July 5, 2022, 9:51 a.m. UTC | #2
On Mon, Jul 04, 2022 at 03:32:08PM +0000, Bertrand Marquis wrote:
> Hi Luca,
> 
> > On 29 Jun 2022, at 13:49, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
> > 
> > Fix snprintf argument in init-dom0less.c because two instances of
> > the function are using libxl_dominfo struct members that are uint64_t
> > types, so change "%lu" to "%"PRIu64 to handle it properly when
> > building on arm32 and arm64.
> > 
> > Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,
diff mbox series

Patch

diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c
index 4c90dd6a0c8f..fee93459c4b9 100644
--- a/tools/helpers/init-dom0less.c
+++ b/tools/helpers/init-dom0less.c
@@ -5,6 +5,7 @@ 
 #include <stdlib.h>
 #include <sys/mman.h>
 #include <sys/time.h>
+#include <inttypes.h>
 #include <xenstore.h>
 #include <xenctrl.h>
 #include <xenguest.h>
@@ -138,10 +139,10 @@  static int create_xenstore(struct xs_handle *xsh,
                   "vm/" LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
     if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
-    rc = snprintf(max_memkb_str, STR_MAX_LENGTH, "%lu", info->max_memkb);
+    rc = snprintf(max_memkb_str, STR_MAX_LENGTH, "%"PRIu64, info->max_memkb);
     if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
-    rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%lu", info->current_memkb);
+    rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%"PRIu64, info->current_memkb);
     if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
     rc = snprintf(ring_ref_str, STR_MAX_LENGTH, "%lld",