Skip to contentSkip to conversation

vdi: Use a literal number of bytes for

PATCH Applied Leonid Bloch 3 participants 4 messages Nov 4, 2018 – Nov 5, 2018 Block layer

lore
Share & tools
lore
#0 lore raw

v2 cover vdi: Use a literal number of bytes for

Please see the commit message for the rationale.

Difference from v1:
* Format string is fixed.

Leonid Bloch (1):
vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE

 block/vdi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE

If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled, it will be embedded as a literal expression in the binary (as the default value) because it is stringified to mark the size of the default value. Now this is fixed by using a defined number to define this value.

---
 block/vdi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/vdi.c +2 -2
index 6555cffb88..d996793f1c 100644
@@ -85,7 +85,7 @@
 #define BLOCK_OPT_STATIC "static"
 
 #define SECTOR_SIZE 512
-#define DEFAULT_CLUSTER_SIZE (1 * MiB)
+#define DEFAULT_CLUSTER_SIZE S_1MiB
 
 #if defined(CONFIG_VDI_DEBUG)
 #define VDI_DEBUG 1
@@ -432,7 +432,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
         goto fail;
     } else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
         error_setg(errp, "unsupported VDI image (block size %" PRIu32
-                         " is not %" PRIu64 ")",
+                         " is not %" PRIu32 ")",
                    header.block_size, DEFAULT_CLUSTER_SIZE);
         ret = -ENOTSUP;
         goto fail;
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] vdi: Use a literal number of bytes for DEFAULT_CLUSTER_SIZE

Quoted 25 lines · Leonid Bloch

If an expression is used to define DEFAULT_CLUSTER_SIZE, when compiled, it will be embedded as a literal expression in the binary (as the default value) because it is stringified to mark the size of the default value. Now this is fixed by using a defined number to define this value.

---
 block/vdi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/vdi.c +1 -1
index 6555cffb88..d996793f1c 100644
@@ -85,7 +85,7 @@
 #define BLOCK_OPT_STATIC "static"
 
 #define SECTOR_SIZE 512
-#define DEFAULT_CLUSTER_SIZE (1 * MiB)
+#define DEFAULT_CLUSTER_SIZE S_1MiB
 
 #if defined(CONFIG_VDI_DEBUG)
 #define VDI_DEBUG 1

block/vdi.c static int vdi_open(BlockDriverState *bs, QDict *options, int flags, · line 438

Quoted 8 lines
block/vdi.c +1 -1
@@ -432,7 +432,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
         goto fail;
     } else if (header.block_size != DEFAULT_CLUSTER_SIZE) {
         error_setg(errp, "unsupported VDI image (block size %" PRIu32
-                         " is not %" PRIu64 ")",
+                         " is not %" PRIu32 ")",
                    header.block_size, DEFAULT_CLUSTER_SIZE);
         ret = -ENOTSUP;
         goto fail;

"%u" would have be sufficient for printing the DEFAULT_CLUSTER_SIZE (maybe this can be changed when merging this commit), but PRIu32 also works.

Thank you,
Stefan

Applied
#3 lore raw
In reply to Leonid Bloch

Am 04.11.2018 um 19:09 hat Leonid Bloch geschrieben:

Quoted 4 lines

Please see the commit message for the rationale.

Difference from v1:
* Format string is fixed.

Thanks, applied to the block branch.

Kevin