Skip to contentSkip to conversation

hw/block/xen: use proper format string for printing sectors

PATCH In review Alex Bennée 5 participants 9 messages Jan 16, 2019 – Jan 21, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/block/xen: use proper format string for printing sectors

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen-block.c +1 -1
index be28b63442..a636487b3e 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", "%"PRIi64,
                               blk_getlength(conf->blk) /
                               conf->logical_block_size);
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines

-----Original Message-----
From: Alex Bennée [mailto:[email protected]]
Sent: 16 January 2019 12:14
To: [email protected]
Cc: [email protected]; Alex Bennée <[email protected]>; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>; Paul Durrant <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; open list:X86 <[email protected]>; open list:Block layer core <qemu- [email protected]>
Subject: [PATCH] hw/block/xen: use proper format string for printing sectors

Quoted 5 lines

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

This does the same thing as "xen: Fix format string" from Philippe, but this variant is better...

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..a636487b3e 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", "%"PRIi64,
                               blk_getlength(conf->blk) /
                               conf->logical_block_size);
 
--
Quoted 1 line

2.17.1

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

#2 lore raw
Quoted 13 lines · Paul Durrant
Quoted 13 lines

-----Original Message-----
From: Alex Bennée [mailto:[email protected]]
Sent: 16 January 2019 12:14
To: [email protected]
Cc: [email protected]; Alex Bennée <[email protected]>; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>; Paul Durrant <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; open list:X86 <[email protected]>; open list:Block layer core <qemu- [email protected]>
Subject: [PATCH] hw/block/xen: use proper format string for printing sectors

Quoted 7 lines
Quoted 5 lines

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

This does the same thing as "xen: Fix format string" from Philippe, but this variant is better...

OK.

Quoted 21 lines
Quoted 18 lines
---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen-block.c +1 -1
index be28b63442..a636487b3e 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", "%"PRIi64,
                               blk_getlength(conf->blk) /
                               conf->logical_block_size);
Quoted 3 lines
Quoted 2 lines

--
2.17.1

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

#3 lore raw
In reply to Paul Durrant
Quoted 13 lines · Paul Durrant
Quoted 13 lines

-----Original Message-----
From: Alex Bennée [mailto:[email protected]]
Sent: 16 January 2019 12:14
To: [email protected]
Cc: [email protected]; Alex Bennée <[email protected]>; Stefano Stabellini <[email protected]>; Anthony Perard <[email protected]>; Paul Durrant <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; open list:X86 <[email protected]>; open list:Block layer core <qemu- [email protected]>
Subject: [PATCH] hw/block/xen: use proper format string for printing sectors

Quoted 7 lines
Quoted 5 lines

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

This does the same thing as "xen: Fix format string" from Philippe, but this variant is better...

OK.

Quoted 24 lines
Quoted 20 lines
---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen-block.c +1 -2
index be28b63442..a636487b3e 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", "%"PRIi64,
                               blk_getlength(conf->blk) /
                               conf->logical_block_size);
 
--

2.17.1

#4 lore raw
In reply to Alex Bennée
Quoted 14 lines · Alex Bennée

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen-block.c +0 -0
index be28b63442..a636487b3e 100644

hw/block/xen-block.c static void xen_block_realize(XenDevice *xendev, Error **errp) · line 218

Quoted 5 lines
hw/block/xen-block.c +1 -1
@@ -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", "%"PRIi64,

PRIu64.

You've changed the signed-ness of what gets printed.

~Andrew

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

#5 lore raw
Quoted 16 lines · Andrew Cooper
Quoted 15 lines · Alex Bennée

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

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

hw/block/xen-block.c static void xen_block_realize(XenDevice *xendev, Error **errp) · line 218

Quoted 4 lines
hw/block/xen-block.c +1 -1
     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", "%"PRIi64,

PRIu64.

You've changed the signed-ness of what gets printed.

I was deliberate as:
int64_t blk_getlength(BlockBackend *blk);

although I have to admit a signed block length doesn't make much sense to me. At least it isn't going to overflow and will show-up if the block length is ever negative.

Quoted 2 lines

~Andrew

--
Alex Bennée

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

#6 lore raw
In reply to Andrew Cooper
Quoted 16 lines · Andrew Cooper
Quoted 15 lines · Alex Bennée

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

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

hw/block/xen-block.c static void xen_block_realize(XenDevice *xendev, Error **errp) · line 218

Quoted 4 lines
hw/block/xen-block.c +1 -1
     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", "%"PRIi64,

PRIu64.

You've changed the signed-ness of what gets printed.

I was deliberate as:
int64_t blk_getlength(BlockBackend *blk);

although I have to admit a signed block length doesn't make much sense to me. At least it isn't going to overflow and will show-up if the block length is ever negative.

Quoted 2 lines

~Andrew

--
Alex Bennée

#7 lore raw
Quoted 40 lines

-----Original Message-----
From: Alex Bennée [mailto:[email protected]]
Sent: 17 January 2019 08:21
To: Andrew Cooper <[email protected]>
Cc: [email protected]; Kevin Wolf <[email protected]>; Stefano Stabellini <[email protected]>; open list:Block layer core <qemu- [email protected]>; [email protected]; Max Reitz <[email protected]>; Paul Durrant <[email protected]>; Anthony Perard <[email protected]>; open list:X86 <xen- [email protected]>
Subject: Re: [Xen-devel] [PATCH] hw/block/xen: use proper format string for printing sectors

Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Alex Bennée

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines

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

Quoted 5 lines
hw/block/xen-block.c +0 -0
index be28b63442..a636487b3e 100644
@@ -215,7 +215,7 @@ static void xen_block_realize(XenDevice *xendev,

Error **errp)

Quoted 8 lines

hw/block/xen-block.c static void xen_block_realize(XenDevice *xendev, Error **errp) · line 218

Quoted 5 lines
hw/block/xen-block.c +1 -1
     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", "%"PRIi64,

PRIu64.

Quoted 8 lines
Quoted 1 line

You've changed the signed-ness of what gets printed.

I was deliberate as:
int64_t blk_getlength(BlockBackend *blk);

although I have to admit a signed block length doesn't make much sense to me. At least it isn't going to overflow and will show-up if the block length is ever negative.

Yes, that's a much better failure mode than some weird huge number of sectors.

Paul

Quoted 7 lines
Quoted 3 lines

~Andrew

--
Alex Bennée

#8 lore raw
In reply to Alex Bennée
Quoted 15 lines · Alex Bennée

The %lu format string is different depending on the host architecture which causes builds like the debian-armhf-cross build to fail. Use the correct PRi64 format string.

---
 hw/block/xen-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/xen-block.c +0 -0
index be28b63442..a636487b3e 100644

hw/block/xen-block.c static void xen_block_realize(XenDevice *xendev, Error **errp) · line 221

Quoted 8 lines
hw/block/xen-block.c +1 -1
@@ -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", "%"PRIi64,
                               blk_getlength(conf->blk) /
                               conf->logical_block_size);
 

Applied to master as a build fix, thanks.

-- PMM

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