All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: aliguori@us.ibm.com, lersek@redhat.com, qemu-devel@nongnu.org,
	ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/7] smbios: Make multiple -smbios type= accumulate sanely
Date: Wed, 17 Jul 2013 22:31:36 +0200	[thread overview]
Message-ID: <87vc49dj2v.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <51E6EEB2.4060603@redhat.com> (Eric Blake's message of "Wed, 17 Jul 2013 13:21:22 -0600")

Eric Blake <eblake@redhat.com> writes:

> On 07/17/2013 11:16 AM, Markus Armbruster wrote:
>> Currently, -smbios type=T,NAME=VAL,... adds one field (T,NAME) with
>> value VAL to fw_cfg for each unique NAME.  If NAME occurs multiple
>> times, the last one's VAL is used (before the QemuOpts conversion, the
>> first one was used).
>> 
>> Multiple -smbios can add multiple fields with the same (T, NAME).
>> SeaBIOS reads all of them from fw_cfg, but uses only the first field
>> (T, NAME).  The others are ignored.
>> 
>> "First one wins, subsequent ones get ignored silently" isn't nice.  We
>> commonly let the last option win.  Useful, because it lets you
>> -readconfig first, then selectively override with command line
>> options.
>> 
>> Clean up -smbios to work the common way.  Accumulate the settings,
>> with later ones overwriting earlier ones.  Put the result into fw_cfg
>> (no more useless duplicates).
>> 
>> Bonus cleanup: qemu_uuid_parse() no longer sets SMBIOS system uuid by
>> side effect.
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>
>>      }
>> -    val = qemu_opt_get(opts, "release");
>> -    if (val) {
>> -        if (sscanf(val, "%hhu.%hhu", &major, &minor) != 2) {
>> -            error_report("Invalid release");
>> -            exit(1);
>
>> @@ -348,7 +353,18 @@ void smbios_entry_add(QemuOpts *opts)
>>                  error_report("%s", error_get_pretty(local_err));
>>                  exit(1);
>>              }
>> -            smbios_build_type_0_fields(opts);
>> +            save_opt(&type0.vendor, opts, "vendor");
>> +            save_opt(&type0.version, opts, "version");
>> +            save_opt(&type0.date, opts, "date");
>> +
>> +            val = qemu_opt_get(opts, "release");
>> +            if (val) {
>> +                if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != 2) {
>
> sscanf() is lousy at detecting overflow.  Since this is just code
> motion, you can get away without changing it now, but it would be nice
> if you at least considered switching this to use [a sane wrapper around]
> strtol() for proper overflow detection of user input at some point in
> your refactoring.

Correct use of strol() & friends is surprisingly involved, and a bit
more than I bargained for when moving this code around :)

>> +            val = qemu_opt_get(opts, "uuid");
>> +            if (val) {
>> +                if (qemu_uuid_parse(val, qemu_uuid) != 0) {
>> +                    error_report("Invalid UUID");
>> +                    exit(1);
>
> My comments from earlier in the series about preferring
> exit(EXIT_FAILURE) apply here as well.

I very much prefer all unsuccessful exits to look the same.  There are
eight instances of exit(1) in this file before my series, I'm removing
three, and adding six.

While I'm sympathetic to the general "symbols are nicer than magic
numbers" sentiment, exit(1) is as harmless as it gets.

> Neither issue is a show-stopper, so
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Thanks for the review!

  reply	other threads:[~2013-07-17 20:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 17:16 [Qemu-devel] [PATCH 0/7] smbios cleanup & nicer defaults for type 1 Markus Armbruster
2013-07-17 17:16 ` [Qemu-devel] [PATCH 1/7] smbios: Normalize smbios_entry_add()'s error handling to exit(1) Markus Armbruster
2013-07-17 17:53   ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 2/7] smbios: Convert to QemuOpts Markus Armbruster
2013-07-17 19:04   ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 3/7] smbios: Improve diagnostics for conflicting entries Markus Armbruster
2013-07-17 19:09   ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 4/7] smbios: Make multiple -smbios type= accumulate sanely Markus Armbruster
2013-07-17 19:21   ` Eric Blake
2013-07-17 20:31     ` Markus Armbruster [this message]
2013-07-17 17:16 ` [Qemu-devel] [PATCH 5/7] smbios: Factor out smbios_maybe_add_str() Markus Armbruster
2013-07-17 19:22   ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 6/7] vl: Set current_machine early Markus Armbruster
2013-07-17 19:23   ` Eric Blake
2013-07-17 17:16 ` [Qemu-devel] [PATCH 7/7] smbios: Set system manufacturer, product & version by default Markus Armbruster
2013-07-17 19:24   ` Eric Blake
2013-07-30  6:01 ` [Qemu-devel] [PATCH 0/7] smbios cleanup & nicer defaults for type 1 Markus Armbruster

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=87vc49dj2v.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=lersek@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.