From: Jan Kiszka <jan.kiszka@siemens.com>
To: "quintela@redhat.com" <quintela@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Blue Swirl" <blauwirbel@gmail.com>,
"Anthony Liguori" <aliguori@us.ibm.com>,
"qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
"Markus Armbruster" <armbru@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Vasilis Liaskovitis" <vasilis.liaskovitis@profitbricks.com>,
"Andreas Färber" <andreas.faerber@web.de>,
"Amit Shah" <amit.shah@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-trivial] [PATCH v8] qdev: Add support for property type bool
Date: Fri, 27 Jan 2012 13:22:28 +0100 [thread overview]
Message-ID: <4F229704.9020003@siemens.com> (raw)
In-Reply-To: <8739b1pceg.fsf@elfo.elfo>
On 2012-01-27 13:17, Juan Quintela wrote:
>> +{
>> + bool *ptr = qdev_get_prop_ptr(dev, prop);
>> + if (strcmp(str, "true") == 0 || strcmp(str, "yes") == 0) {
>> + *ptr = true;
>> + } else if (strcmp(str, "false") == 0 || strcmp(str, "no") == 0) {
>> + *ptr = false;
>> + } else {
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int parse_bool_switch(DeviceState *dev, Property *prop,
>> + const char *str)
>> +{
>> + bool *ptr = qdev_get_prop_ptr(dev, prop);
>> + if (strcmp(str, "on") == 0) {
>> + *ptr = true;
>> + } else if (strcmp(str, "off") == 0) {
>> + *ptr = false;
>> + } else {
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> +}
>
> As I am joining late to this discussion, I am not going to point it very
> strong. But I think that it is an easy to have a single bool type that
> accept yes/on/true and no/off/false. Didn't really see a strong
> advantage with the split.
Accepting all this on input is a non-issue, but true/false as output is
suboptimal for quite a few existing and future switches.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@siemens.com>
To: "quintela@redhat.com" <quintela@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Blue Swirl" <blauwirbel@gmail.com>,
"Anthony Liguori" <aliguori@us.ibm.com>,
"qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
"Markus Armbruster" <armbru@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"Vasilis Liaskovitis" <vasilis.liaskovitis@profitbricks.com>,
"Andreas Färber" <andreas.faerber@web.de>,
"Amit Shah" <amit.shah@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH v8] qdev: Add support for property type bool
Date: Fri, 27 Jan 2012 13:22:28 +0100 [thread overview]
Message-ID: <4F229704.9020003@siemens.com> (raw)
In-Reply-To: <8739b1pceg.fsf@elfo.elfo>
On 2012-01-27 13:17, Juan Quintela wrote:
>> +{
>> + bool *ptr = qdev_get_prop_ptr(dev, prop);
>> + if (strcmp(str, "true") == 0 || strcmp(str, "yes") == 0) {
>> + *ptr = true;
>> + } else if (strcmp(str, "false") == 0 || strcmp(str, "no") == 0) {
>> + *ptr = false;
>> + } else {
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static int parse_bool_switch(DeviceState *dev, Property *prop,
>> + const char *str)
>> +{
>> + bool *ptr = qdev_get_prop_ptr(dev, prop);
>> + if (strcmp(str, "on") == 0) {
>> + *ptr = true;
>> + } else if (strcmp(str, "off") == 0) {
>> + *ptr = false;
>> + } else {
>> + return -EINVAL;
>> + }
>> +
>> + return 0;
>> +}
>
> As I am joining late to this discussion, I am not going to point it very
> strong. But I think that it is an easy to have a single bool type that
> accept yes/on/true and no/off/false. Didn't really see a strong
> advantage with the split.
Accepting all this on input is a non-issue, but true/false as output is
suboptimal for quite a few existing and future switches.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2012-01-27 12:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-26 15:54 [Qemu-trivial] [PATCH v8] qdev: Add support for property type bool Andreas Färber
2012-01-26 15:54 ` [Qemu-devel] " Andreas Färber
2012-01-27 11:06 ` Andreas Färber
2012-01-27 12:17 ` [Qemu-trivial] " Juan Quintela
2012-01-27 12:17 ` [Qemu-devel] " Juan Quintela
2012-01-27 12:22 ` Jan Kiszka [this message]
2012-01-27 12:22 ` Jan Kiszka
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=4F229704.9020003@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=amit.shah@redhat.com \
--cc=andreas.faerber@web.de \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=quintela@redhat.com \
--cc=vasilis.liaskovitis@profitbricks.com \
/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.