On 06/27/2018 06:27 AM, Igor Mammedov wrote:
On Mon, 25 Jun 2018 09:41:53 -0300
Philippe Mathieu-Daudé <f4...@amsat.org> wrote:

Loosely based on 076b35b5a56.

Suggested-by: Stefan Weil <s...@weilnetz.de>
Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
---

+#ifndef QEMU_UNITS_H
+#define QEMU_UNITS_H
+
+#define KiB     (INT64_C(1) << 10)
+#define MiB     (INT64_C(1) << 20)
+#define GiB     (INT64_C(1) << 30)
+#define TiB     (INT64_C(1) << 40)
+#define PiB     (INT64_C(1) << 50)
+#define EiB     (INT64_C(1) << 60)
Shouldn't above use UINT64_C()

Since the decision of signed vs. unsigned was intentional based on review on earlier versions, it may be worth a comment in this file that these constants are intentionally signed (in usage patterns, these tend to be multiplied by another value; and while it is easy to go to unsigned by doing '1U * KiB', you can't go in the opposite direction if you want a signed number for '1 * KiB' unless KiB is signed).

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to