Skip to contentSkip to conversation

xen: Fix format string

PATCH In review Philippe Mathieu-Daudé 2 participants 3 messages Jan 16, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Fix format string

Trivial format string fix to solve:

hw/block/xen-block.c: In function 'xen_block_realize':
hw/block/xen-block.c:218:53: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'int64_t {aka long long int}' [-Werror=format=]

      xen_device_backend_printf(xendev, "sectors", "%lu",
                                                      ^
                                blk_getlength(conf->blk) /
                                conf->logical_block_size);

blk_getlength() returns an int64_t.

---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen-block.c +1 -1
index be28b63442..3cf215b730 100644
@@ -215,7 +215,7 @@ static void xen_block_realize(XenDevice *xendev, Error **errp)
 
     xen_device_backend_printf(xendev, "sector-size", "%u",
                               conf->logical_block_size);
-    xen_device_backend_printf(xendev, "sectors", "%lu",
+    xen_device_backend_printf(xendev, "sectors", "%lld",
                               blk_getlength(conf->blk) /
                               conf->logical_block_size);
 
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: 16 January 2019 12:01
To: [email protected]
Cc: Paul Durrant <[email protected]>; Anthony Perard <[email protected]>; Max Reitz <[email protected]>; qemu- [email protected]; Stefano Stabellini <[email protected]>; xen- [email protected]; Kevin Wolf <[email protected]>; Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH] xen: Fix format string

Trivial format string fix to solve:

hw/block/xen-block.c: In function 'xen_block_realize':
hw/block/xen-block.c:218:53: error: format '%lu' expects argument of
type 'long unsigned int', but argument 4 has type 'int64_t {aka long long int}' [-Werror=format=]

Quoted 8 lines
      xen_device_backend_printf(xendev, "sectors", "%lu",
                                                      ^
                                blk_getlength(conf->blk) /
                                conf->logical_block_size);

blk_getlength() returns an int64_t.

Quoted 19 lines
---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen-block.c +1 -2
index be28b63442..3cf215b730 100644
@@ -215,7 +215,7 @@ static void xen_block_realize(XenDevice *xendev, Error
 **errp)
 
     xen_device_backend_printf(xendev, "sector-size", "%u",
                               conf->logical_block_size);
-    xen_device_backend_printf(xendev, "sectors", "%lu",
+    xen_device_backend_printf(xendev, "sectors", "%lld",
                               blk_getlength(conf->blk) /
                               conf->logical_block_size);
 
--
Quoted 1 line

2.17.2

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 34 lines

-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 16 January 2019 12:04
To: 'Philippe Mathieu-Daudé' <[email protected]>; [email protected]
Cc: Kevin Wolf <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Max Reitz <[email protected]>; Anthony Perard <[email protected]>; xen- [email protected]
Subject: Re: [Xen-devel] [PATCH] xen: Fix format string

Quoted 11 lines

-----Original Message-----
From: Philippe Mathieu-Daudé [mailto:[email protected]]
Sent: 16 January 2019 12:01
To: [email protected]
Cc: Paul Durrant <[email protected]>; Anthony Perard <[email protected]>; Max Reitz <[email protected]>; qemu- [email protected]; Stefano Stabellini <[email protected]>; xen- [email protected]; Kevin Wolf <[email protected]>; Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH] xen: Fix format string

Quoted 5 lines

Trivial format string fix to solve:

hw/block/xen-block.c: In function 'xen_block_realize':
hw/block/xen-block.c:218:53: error: format '%lu' expects argument of
type 'long unsigned int', but argument 4 has type 'int64_t {aka long

long

Quoted 6 lines

int}' [-Werror=format=]

      xen_device_backend_printf(xendev, "sectors", "%lu",
                                                      ^
                                blk_getlength(conf->blk) /
                                conf->logical_block_size);
Quoted 5 lines
Quoted 3 lines

blk_getlength() returns an int64_t.

Actually, the alternative patch from Alex is better as it will work in the case where longs are not 64-bit.

Paul

Quoted 20 lines

hw/block/xen-block.c static void xen_block_realize(XenDevice *xendev,

Quoted 10 lines
---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen-block.c +0 -0
index be28b63442..3cf215b730 100644
@@ -215,7 +215,7 @@ static void xen_block_realize(XenDevice *xendev,

Error

Quoted 9 lines
hw/block/xen-block.c +1 -1
 **errp)
 
     xen_device_backend_printf(xendev, "sector-size", "%u",
                               conf->logical_block_size);
-    xen_device_backend_printf(xendev, "sectors", "%lu",
+    xen_device_backend_printf(xendev, "sectors", "%lld",
                               blk_getlength(conf->blk) /
                               conf->logical_block_size);
Quoted 7 lines
Quoted 2 lines

--
2.17.2

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel