qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH v8] qdev: Add support for property type bool


From: Jan Kiszka
Subject: Re: [Qemu-trivial] [PATCH v8] qdev: Add support for property type bool
Date: Fri, 27 Jan 2012 13:22:28 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]