From: Eric Blake <eblake@redhat.com>
To: "Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Thomas Huth" <thuth@redhat.com>, "Stefan Weil" <sw@weilnetz.de>
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Eduardo Habkost <ehabkost@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
Max Reitz <mreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Anthony Perard <anthony.perard@citrix.com>,
"open list:X86" <xen-devel@lists.xenproject.org>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v4 11/40] hw/xen: Use the IEC binary prefix definitions
Date: Tue, 12 Jun 2018 16:04:33 -0500 [thread overview]
Message-ID: <76aa5170-1d18-8799-6ff1-a7c0dba0b489@redhat.com> (raw)
In-Reply-To: <15d222dd-d2e9-4855-62c6-f89f2ee59c52@linaro.org>
On 06/12/2018 03:51 PM, Richard Henderson wrote:
> On 06/10/2018 03:14 PM, Philippe Mathieu-Daudé wrote:
>> xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
>> - " size %" PRId64 " (%" PRId64 " MB)\n",
>> + " size %" PRId64 " (%llu MB)\n",
>> blkdev->type, blkdev->fileproto, blkdev->filename,
>> - blkdev->file_size, blkdev->file_size >> 20);
>> + blkdev->file_size, blkdev->file_size / MiB);
>
> Having to change printf markup is exactly why you shouldn't use ULL in MiB.
Conversely, M_BYTE was already ULL, so if you don't use it in MiB,
you'll have to change other printf markup where you were changing those
uses.
One benefit of using the widest possible type: we avoid risk of silent
truncation. Potential downsides: wasted processing time (when 32 bits
was sufficient), and compilers might start warning when we narrow a
64-bit value into a 32-bit variable (but I think we already ignore that).
One benefit of using the natural type that holds the value: use of
64-bit math is explicit based on the type of what else is being
multiplied by the macro. Potential downside: 32*32 assigned to a 64-bit
result may be botched (but hopefully Coverity will flag it).
So there's tradeoffs either way, and you at least need to document in
your commit messages what auditing you have done that any type changes
introduced by your changes are safe.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2018-06-12 21:04 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-11 1:14 [Qemu-devel] [PATCH v4 00/40] Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 01/40] include: Add IEC binary prefixes in "qemu/units.h" Philippe Mathieu-Daudé
2018-06-12 20:42 ` Richard Henderson
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 02/40] vdi: Use definitions from "qemu/units.h" Philippe Mathieu-Daudé
2018-06-11 19:27 ` Stefan Weil
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 03/40] x86/cpu: " Philippe Mathieu-Daudé
2018-06-11 18:42 ` Eduardo Habkost
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 04/40] checkpatch: Recognize IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-13 19:54 ` Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 05/40] hw: Use IEC binary prefix definitions from "qemu/units.h" Philippe Mathieu-Daudé
2018-06-11 2:11 ` David Gibson
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 06/40] hw: Directly use "qemu/units.h" instead of "qemu/cutils.h" Philippe Mathieu-Daudé
2018-06-11 2:16 ` David Gibson
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 07/40] hw/ivshmem: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 08/40] hw/ipack: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 09/40] hw/scsi: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 10/40] hw/smbios: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 11/40] hw/xen: " Philippe Mathieu-Daudé
2018-06-12 20:51 ` Richard Henderson
2018-06-12 21:04 ` Eric Blake [this message]
2018-06-12 21:10 ` Richard Henderson
2018-06-13 12:13 ` Eric Blake
2018-06-13 19:31 ` Richard Henderson
2018-06-13 20:02 ` Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 12/40] hw/tpm: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 13/40] hw/block: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 14/40] hw/display: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 15/40] hw/misc: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 16/40] hw/riscv: " Philippe Mathieu-Daudé
2018-06-11 1:22 ` Michael Clark
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 17/40] hw/m68k: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 18/40] hw/sparc: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 19/40] hw/s390x: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 20/40] hw/hppa: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 21/40] hw/xtensa: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 22/40] hw/alpha: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 23/40] hw/tricore: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 24/40] hw/microblaze: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 25/40] hw/nios2: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 26/40] hw/cris: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 27/40] hw/lm32: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 28/40] hw/sh4: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 29/40] hw/mips/r4k: Constify params_size Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 30/40] hw/mips: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 32/40] hw/ppc: " Philippe Mathieu-Daudé
2018-06-11 8:09 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan
2018-06-11 15:44 ` Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 34/40] hw/net: " Philippe Mathieu-Daudé
2018-06-11 19:20 ` Stefan Weil
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 35/40] hw/usb: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 36/40] hw/sd: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 37/40] hw/vfio: " Philippe Mathieu-Daudé
2018-06-11 1:14 ` [Qemu-devel] [PATCH v4 38/40] hw/virtio: " Philippe Mathieu-Daudé
2018-06-11 1:15 ` [Qemu-devel] [PATCH v4 39/40] hw/rdma: " Philippe Mathieu-Daudé
2018-06-11 1:15 ` [Qemu-devel] [PATCH v4 40/40] cutils: Do not include "qemu/units.h" directly Philippe Mathieu-Daudé
[not found] ` <20180611011501.10235-34-f4bug@amsat.org>
2018-06-11 2:18 ` [Qemu-devel] [PATCH v4 33/40] hw/i386: Use the IEC binary prefix definitions Michael S. Tsirkin
2018-06-11 2:29 ` Philippe Mathieu-Daudé
2018-06-11 2:22 ` [Qemu-devel] [PATCH v4 00/40] " Michael S. Tsirkin
2018-06-11 2:32 ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2018-06-11 15:55 ` [Qemu-devel] " Eric Blake
2018-06-11 16:11 ` Peter Maydell
2018-06-11 16:27 ` Michael S. Tsirkin
2018-06-11 16:18 ` Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=76aa5170-1d18-8799-6ff1-a7c0dba0b489@redhat.com \
--to=eblake@redhat.com \
--cc=anthony.perard@citrix.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=rth@twiddle.net \
--cc=sstabellini@kernel.org \
--cc=sw@weilnetz.de \
--cc=thuth@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).