From: Eric Blake <eblake@redhat.com>
To: "Leonid Bloch" <lbloch@janustech.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Alberto Garcia <berto@igalia.com>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] include: Add a comment to explain the origin of sizes' lookup table
Date: Mon, 5 Nov 2018 09:45:11 -0600 [thread overview]
Message-ID: <4d264678-088e-76d6-fa37-3613c89bbd86@redhat.com> (raw)
In-Reply-To: <20181103015821.30074-1-lbloch@janustech.com>
On 11/2/18 8:58 PM, Leonid Bloch wrote:
> The lookup table for power-of-two sizes was added in commit 540b8492618eb
> for the purpose of having convenient shortcuts for these sizes in cases
> when the literal number has to be present at compile time, and
> expressions as '(1 * KiB)' can not be used. One such case is the
> stringification of sizes. Beyond that, it is convenient to use these
> shortcuts for all power-of-two sizes, even if they don't have to be
> literal numbers.
>
> Despite its convenience, this table introduced 55 lines of "dumb" code,
> the purpose and origin of which are obscure without reading the message
> of the commit which introduced it. This patch fixes that by adding a
> comment to the code itself with a brief explanation for the reasoning
> behind this table. This comment includes the short AWK script that
> generated the table, so that anyone who's interested could make sure
> that the values in it are correct (otherwise these values look as if
> they were typed manually).
>
> Signed-off-by: Leonid Bloch <lbloch@janustech.com>
> ---
> include/qemu/units.h | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
I'm still not completely sold that we can't come up with a more elegant
runtime solution that avoids the need for hard-coding stringified
defaults at compile time; but if we keep these S_* constants, this
comment definitely helps.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2018-11-05 15:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-03 1:58 [Qemu-devel] [PATCH] include: Add a comment to explain the origin of sizes' lookup table Leonid Bloch
2018-11-04 11:19 ` no-reply
2018-11-05 15:45 ` Eric Blake [this message]
2018-11-05 23:05 ` no-reply
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=4d264678-088e-76d6-fa37-3613c89bbd86@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=lbloch@janustech.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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).