On 6/18/19 6:43 AM, Vladimir Sementsov-Ogievskiy wrote: > Signed-off-by: Vladimir Sementsov-Ogievskiy > --- > include/qemu/units.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/qemu/units.h b/include/qemu/units.h > index 692db3fbb2..52ccc7445c 100644 > --- a/include/qemu/units.h > +++ b/include/qemu/units.h > @@ -17,4 +17,11 @@ > #define PiB (INT64_C(1) << 50) > #define EiB (INT64_C(1) << 60) > > +#define SI_k 1000LL > +#define SI_M 1000000LL > +#define SI_G 1000000000LL > +#define SI_T 1000000000000LL > +#define SI_P 1000000000000000LL > +#define SI_E 1000000000000000000LL Looks correct; and it's the sort of thing that if we do once here, we don't have to repeat elsewhere. But bike-shedding a bit, would it be any easier to read as: #define SI_k 1000LL #define SI_M (1000LL * 1000) #define SI_G (1000LL * 1000 * 1000) ... or even: #define SI_k 1000LL #define SI_M (SI_k * 1000) #define SI_G (SI_M * 1000) ... Also, would it be worth swapping out existing constants in the code base that should instead be using these macros, so that they actually have a use and so that we can see whether using them adds legibility? For example, block/nvme.c, block/qapi.c, block/sheepdog.c, blockdev.c, util/async.c, util/oslib-win32.c, util/qemu-thread-posix.c, util/qemu-timer.c all seem to be dealing with conversions between seconds and subdivisions thereof, where constants 1000000 or larger are in use and could be rewritten with these. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org