qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH trivial] acpi: actually require either data= or file= for -acpitable
Date: Mon, 03 Jun 2013 06:34:00 -0600	[thread overview]
Message-ID: <51AC8D38.90205@redhat.com> (raw)
In-Reply-To: <1370251243-20352-1-git-send-email-mjt@msgid.tls.msk.ru>

[-- Attachment #1: Type: text/plain, Size: 1506 bytes --]

On 06/03/2013 03:20 AM, Michael Tokarev wrote:
> Initially the code ensured that we have exactly one of
> data= or file= option for -acpitable.  But after some
> transformations, the condition becomes
> 
>   if (has_data == has_file) { error }
> 
> to mean, probably, that both should not be set at the same
> time.  But this condition does not cover the case when
> neither is set, and we generate bogus acpi table in this
> case.
> 
> Instead, check if sum of the two is exactly 1.
> 
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  hw/acpi/core.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/acpi/core.c b/hw/acpi/core.c
> index 42eeace..2815d8c 100644
> --- a/hw/acpi/core.c
> +++ b/hw/acpi/core.c
> @@ -249,7 +249,7 @@ void acpi_table_add(const QemuOpts *opts, Error **errp)
>      if (err) {
>          goto out;
>      }
> -    if (hdrs->has_file == hdrs->has_data) {

NACK.

hdrs->has_file and hdrs->has_data are both bool.  Pre-patch, the table
of possible combinations is:

false == false => error message, zero given
false == true => okay, exactly one given
true == false => okay, exactly one given
true == true => error message, two given

which is already what you want.

> +    if (!hdrs->has_file + !hdrs->has_data != 1) {

Meanwhile, the post-patch logic is harder to read, in my opinion.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

  reply	other threads:[~2013-06-03 12:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-03  9:20 [Qemu-devel] [PATCH trivial] acpi: actually require either data= or file= for -acpitable Michael Tokarev
2013-06-03 12:34 ` Eric Blake [this message]
2013-06-03 12:42   ` Michael Tokarev
2013-06-03 18:19     ` Laszlo Ersek
2013-06-04  3:36       ` Michael Tokarev

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=51AC8D38.90205@redhat.com \
    --to=eblake@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).