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