block/vhdx: Use IEC binary prefixes from "qemu/units.h"
PATCH 1/1 block/vhdx: Use IEC binary prefixes from "qemu/units.h"
IEC binary prefixes are defined in "qemu/units.h", so we can remove redundant definitions in "block/vhdx.h".
--- block/vhdx-log.c | 1 + block/vhdx.c | 4 +++- block/vhdx.h | 5 ----- 3 files changed, 4 insertions(+), 6 deletions(-)
block/vhdx-log.c +1 -0
@@ -18,6 +18,7 @@* */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" #include "block/block_int.h"
block/vhdx.c +3 -1
@@ -16,6 +16,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h"
@@ -1889,7 +1890,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,return -EINVAL ; }if (block_size >VHDX_BLOCK_SIZE_MAX ) { -error_setg (errp,"Block size must not exceed %d" ,VHDX_BLOCK_SIZE_MAX ); +error_setg (errp,"Block size must not exceed %" PRId64, +VHDX_BLOCK_SIZE_MAX );return -EINVAL ; }
block/vhdx.h +0 -5
@@ -18,11 +18,6 @@#ifndef BLOCK_VHDX_H #define BLOCK_VHDX_H -#define KiB (1 * 1024) -#define MiB (KiB * 1024) -#define GiB (MiB * 1024) -#define TiB ((uint64_t) GiB * 1024) -#define DEFAULT_LOG_SIZE 1048576/* 1MiB */ /* Structures and fields present in the VHDX file */
Signature · 1 line
2.20.1
Quoted 35 lines · Stefano Garzarella
IEC binary prefixes are defined in "
qemu/units.h", so we can remove redundant definitions in "block/vhdx.h".Signed-off-by Stefano Garzarella <[email protected]>--- block/vhdx-log.c | 1 + block/vhdx.c | 4 +++- block/vhdx.h | 5 ----- 3 files changed, 4 insertions(+), 6 deletions(-)block/vhdx-log.c +1
-0@@ -18,6 +18,7 @@* */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" #include "block/block_int.h" block/vhdx.c +1
-0@@ -16,6 +16,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h"
block/vhdx.c static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, · line 1894
Quoted 6 lines
block/vhdx.c +2
-1@@ -1889,7 +1890,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,return -EINVAL ; }if (block_size >VHDX_BLOCK_SIZE_MAX ) { -error_setg (errp,"Block size must not exceed %d" ,VHDX_BLOCK_SIZE_MAX ); +error_setg (errp,"Block size must not exceed %" PRId64, +VHDX_BLOCK_SIZE_MAX );
Oh, changing the constants changes the inferred type of this constant, correct?
Quoted 8 lines
block/vhdx.c +0
-0return -EINVAL ; }block/vhdx.h +0
-0
block/vhdx.h line 25
Quoted 8 lines
block/vhdx.h +0
-5@@ -18,11 +18,6 @@#ifndef BLOCK_VHDX_H #define BLOCK_VHDX_H -#define KiB (1 * 1024) -#define MiB (KiB * 1024) -#define GiB (MiB * 1024) -#define TiB ((uint64_t) GiB * 1024) -
I'd include units.h here because there are other references to KiB/MiB/GiB and so on throughout the rest of this header file.
I think it's bad form to have a header that cannot be included unless you include other headers manually alongside it.
Quoted 4 lines
block/vhdx.h +0
-0#define DEFAULT_LOG_SIZE 1048576/* 1MiB */ /* Structures and fields present in the VHDX file */
Quoted 43 lines · John Snow
block/vhdx.c static int coroutine_fn
Quoted 35 lines · Stefano Garzarella
IEC binary prefixes are defined in "
qemu/units.h", so we can remove redundant definitions in "block/vhdx.h".Signed-off-by Stefano Garzarella <[email protected]>--- block/vhdx-log.c | 1 + block/vhdx.c | 4 +++- block/vhdx.h | 5 ----- 3 files changed, 4 insertions(+), 6 deletions(-)block/vhdx-log.c +1
-0@@ -18,6 +18,7 @@* */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" #include "block/block_int.h" block/vhdx.c +1
-0@@ -16,6 +16,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h" @@ -1889,7 +1890,8 @@ static int coroutine_fnvhdx_co_create(BlockdevCreateOptions *opts,
block/vhdx.c static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
Quoted 4 lines
block/vhdx.c +0
-1return -EINVAL ; }if (block_size >VHDX_BLOCK_SIZE_MAX ) { - error_setg(errp, "Block size must not exceed %d",
Quoted 7 lines
VHDX_BLOCK_SIZE_MAX);block/vhdx.c static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, · line 1894
Quoted 2 lines
block/vhdx.c +2
-0+error_setg (errp,"Block size must not exceed %" PRId64, +VHDX_BLOCK_SIZE_MAX );Oh, changing the constants changes the inferred type of this constant, correct?
Yes.
Quoted 20 lines
Quoted 8 lines
block/vhdx.c +0
-0return -EINVAL ; }block/vhdx.h +0
-0block/vhdx.h line 25
Quoted 8 lines
block/vhdx.h +0
-5@@ -18,11 +18,6 @@#ifndef BLOCK_VHDX_H #define BLOCK_VHDX_H -#define KiB (1 * 1024) -#define MiB (KiB * 1024) -#define GiB (MiB * 1024) -#define TiB ((uint64_t) GiB * 1024) -I'd include
units.hhere because there are other references to KiB/MiB/GiB and so on throughout the rest of this header file.
Quoted 3 lines
I think it's bad form to have a header that cannot be included unless you include other headers manually alongside it.
Agreed.
Quoted 2 lines
block/vhdx.h line 21
Quoted 1 line
block/vhdx.h +0
-0#define DEFAULT_LOG_SIZE 1048576/* 1MiB */
Can we also update this definition?
Quoted 6 lines
/* Structures and fields present in the VHDX file */
Quoted 2 lines
Quoted 42 lines · Philippe Mathieu-Daudé
Quoted 41 lines · John Snow
block/vhdx.c static int coroutine_fn
Quoted 35 lines · Stefano Garzarella
IEC binary prefixes are defined in "
qemu/units.h", so we can remove redundant definitions in "block/vhdx.h".Signed-off-by Stefano Garzarella <[email protected]>--- block/vhdx-log.c | 1 + block/vhdx.c | 4 +++- block/vhdx.h | 5 ----- 3 files changed, 4 insertions(+), 6 deletions(-)block/vhdx-log.c +1
-0@@ -18,6 +18,7 @@* */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" #include "block/block_int.h" block/vhdx.c +1
-0@@ -16,6 +16,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h" @@ -1889,7 +1890,8 @@ static int coroutine_fnvhdx_co_create(BlockdevCreateOptions *opts,
Quoted 4 lines
block/vhdx.c +0
-1return -EINVAL ; }if (block_size >VHDX_BLOCK_SIZE_MAX ) { - error_setg(errp, "Block size must not exceed %d",
Quoted 8 lines
Quoted 7 lines
VHDX_BLOCK_SIZE_MAX);block/vhdx.c static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, · line 1894
Quoted 2 lines
block/vhdx.c +2
-0+error_setg (errp,"Block size must not exceed %" PRId64, +VHDX_BLOCK_SIZE_MAX );Oh, changing the constants changes the inferred type of this constant, correct?
Yes, in "units.h" all the constants are int64_t.
Quoted 23 lines
Yes.
Quoted 20 lines
Quoted 8 lines
block/vhdx.c +0
-0return -EINVAL ; }block/vhdx.h +0
-0block/vhdx.h line 25
Quoted 8 lines
block/vhdx.h +0
-5@@ -18,11 +18,6 @@#ifndef BLOCK_VHDX_H #define BLOCK_VHDX_H -#define KiB (1 * 1024) -#define MiB (KiB * 1024) -#define GiB (MiB * 1024) -#define TiB ((uint64_t) GiB * 1024) -I'd include
units.hhere because there are other references to KiB/MiB/GiB and so on throughout the rest of this header file.
Quoted 5 lines
Quoted 3 lines
I think it's bad form to have a header that cannot be included unless you include other headers manually alongside it.
Agreed.
Okay, I'll include units.h here.
Quoted 7 lines
Quoted 4 lines
block/vhdx.h line 21
Quoted 3 lines
block/vhdx.h +0
-0#define DEFAULT_LOG_SIZE 1048576/* 1MiB */ Can we also update this definition?
Sure, I'll update it in v2.
Thanks for the review,
Stefano
Am 26.03.2019 um 08:55 hat Stefano Garzarella geschrieben:
Quoted 87 lines · Philippe Mathieu-Daudé
Quoted 42 lines · John Snow
Quoted 41 lines · Stefano Garzarella
block/vhdx.c static int coroutine_fn
Quoted 35 lines
IEC binary prefixes are defined in "
qemu/units.h", so we can remove redundant definitions in "block/vhdx.h".Signed-off-by Stefano Garzarella <[email protected]>--- block/vhdx-log.c | 1 + block/vhdx.c | 4 +++- block/vhdx.h | 5 ----- 3 files changed, 4 insertions(+), 6 deletions(-)block/vhdx-log.c +1
-0@@ -18,6 +18,7 @@* */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" #include "block/block_int.h" block/vhdx.c +1
-0@@ -16,6 +16,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h" @@ -1889,7 +1890,8 @@ static int coroutine_fnvhdx_co_create(BlockdevCreateOptions *opts,
Quoted 4 lines
block/vhdx.c +0
-1return -EINVAL ; }if (block_size >VHDX_BLOCK_SIZE_MAX ) { - error_setg(errp, "Block size must not exceed %d",Quoted 8 lines
Quoted 7 lines
VHDX_BLOCK_SIZE_MAX);block/vhdx.c static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, · line 1894
Quoted 2 lines
block/vhdx.c +2
-0+error_setg (errp,"Block size must not exceed %" PRId64, +VHDX_BLOCK_SIZE_MAX );Oh, changing the constants changes the inferred type of this constant, correct?
Yes, in "
units.h" all the constants areint64_t.Quoted 23 lines
Yes.
Quoted 20 lines
Quoted 8 lines
block/vhdx.c +0
-0return -EINVAL ; }block/vhdx.h +0
-0block/vhdx.h line 25
Quoted 8 lines
block/vhdx.h +0
-5@@ -18,11 +18,6 @@#ifndef BLOCK_VHDX_H #define BLOCK_VHDX_H -#define KiB (1 * 1024) -#define MiB (KiB * 1024) -#define GiB (MiB * 1024) -#define TiB ((uint64_t) GiB * 1024) -I'd include
units.hhere because there are other references to KiB/MiB/GiB and so on throughout the rest of this header file.Quoted 5 lines
Quoted 3 lines
I think it's bad form to have a header that cannot be included unless you include other headers manually alongside it.
Agreed.
Okay, I'll include
units.hhere.Quoted 2 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
block/vhdx.h line 21
Quoted 1 line
block/vhdx.h +0
-0#define DEFAULT_LOG_SIZE 1048576/* 1MiB */ Can we also update this definition?
Sure, I'll update it in v2.
This is used in vhdx_create_opts:
.def_value_str = stringify(DEFAULT_LOG_SIZE),
You want the default size to be a number, not an expression, so you'd have to change the default string to retain the number. Probably better to just leave the #define alone.
We could, however, put a comment next to the define lik vdi.c has:
/* Note: can't use 1 * MiB, because it's passed to stringify() */
Kevin
Quoted 97 lines · Kevin Wolf
Am 26.03.2019 um 08:55 hat Stefano Garzarella geschrieben:
Quoted 43 lines · Philippe Mathieu-Daudé
Quoted 42 lines · John Snow
Quoted 41 lines · Stefano Garzarella
block/vhdx.c static int coroutine_fn
Quoted 35 lines
IEC binary prefixes are defined in "
qemu/units.h", so we can remove redundant definitions in "block/vhdx.h".Signed-off-by Stefano Garzarella <[email protected]>--- block/vhdx-log.c | 1 + block/vhdx.c | 4 +++- block/vhdx.h | 5 ----- 3 files changed, 4 insertions(+), 6 deletions(-)block/vhdx-log.c +1
-0@@ -18,6 +18,7 @@* */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" #include "block/block_int.h" block/vhdx.c +1
-0@@ -16,6 +16,7 @@*/ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h" @@ -1889,7 +1890,8 @@ static int coroutine_fnvhdx_co_create(BlockdevCreateOptions *opts,
Quoted 4 lines
block/vhdx.c +0
-1return -EINVAL ; }if (block_size >VHDX_BLOCK_SIZE_MAX ) { - error_setg(errp, "Block size must not exceed %d",Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
VHDX_BLOCK_SIZE_MAX);block/vhdx.c static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, · line 1894
Quoted 2 lines
block/vhdx.c +2
-0+error_setg (errp,"Block size must not exceed %" PRId64, +VHDX_BLOCK_SIZE_MAX );Oh, changing the constants changes the inferred type of this
constant,
Quoted 39 lines
Quoted 3 lines
Quoted 2 lines
correct?
Yes, in "
units.h" all the constants areint64_t.Quoted 23 lines
Yes.
Quoted 20 lines
Quoted 8 lines
block/vhdx.c +0
-0return -EINVAL ; }block/vhdx.h +0
-0block/vhdx.h line 25
Quoted 8 lines
block/vhdx.h +0
-5@@ -18,11 +18,6 @@#ifndef BLOCK_VHDX_H #define BLOCK_VHDX_H -#define KiB (1 * 1024) -#define MiB (KiB * 1024) -#define GiB (MiB * 1024) -#define TiB ((uint64_t) GiB * 1024) -I'd include
units.hhere because there are other references to KiB/MiB/GiB and so on throughout the rest of this header file.Quoted 5 lines
Quoted 3 lines
I think it's bad form to have a header that cannot be included unless you include other headers manually alongside it.
Agreed.
Okay, I'll include
units.hhere.Quoted 2 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
block/vhdx.h line 21
Quoted 1 line
block/vhdx.h +0
-0#define DEFAULT_LOG_SIZE 1048576/* 1MiB */ Can we also update this definition?
Sure, I'll update it in v2.
Quoted 8 lines
This is used in
vhdx_create_opts:.def_value_str =
stringify(DEFAULT_LOG_SIZE),You want the default size to be a number, not an expression, so you'd have to change the default string to retain the number. Probably better to just leave the #define alone.
Oops I guess remember we had the same discussion 1 year ago...
Quoted 6 lines
We could, however, put a comment next to the define lik
vdi.chas:/* Note: can't use 1 * MiB, because it's passed to stringify() */Kevin
Quoted 16 lines · Kevin Wolf
Am 26.03.2019 um 08:55 hat Stefano Garzarella geschrieben:
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 7 lines · John Snow
Quoted 3 lines · Stefano Garzarella
Quoted 1 line
#define
DEFAULT_LOG_SIZE1048576 /* 1MiB */Can we also update this definition?
Sure, I'll update it in v2.
This is used in
vhdx_create_opts:.def_value_str =
stringify(DEFAULT_LOG_SIZE),
Quoted 7 lines
You want the default size to be a number, not an expression, so you'd have to change the default string to retain the number. Probably better to just leave the #define alone.
We could, however, put a comment next to the define lik
vdi.chas:/* Note: can't use 1 * MiB, because it's passed to stringify() */
Many thanks for this suggestion!
I'll put the comment next to the define.
Thanks,
Stefano