From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqkpB-0000jt-Qr for qemu-devel@nongnu.org; Fri, 27 Jan 2012 07:22:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqkpA-0003HN-Sg for qemu-devel@nongnu.org; Fri, 27 Jan 2012 07:22:37 -0500 Message-ID: <4F229704.9020003@siemens.com> Date: Fri, 27 Jan 2012 13:22:28 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <1327593288-22521-1-git-send-email-afaerber@suse.de> <8739b1pceg.fsf@elfo.elfo> In-Reply-To: <8739b1pceg.fsf@elfo.elfo> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v8] qdev: Add support for property type bool List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "quintela@redhat.com" Cc: Kevin Wolf , Blue Swirl , Anthony Liguori , "qemu-trivial@nongnu.org" , Markus Armbruster , "qemu-devel@nongnu.org" , Vasilis Liaskovitis , =?UTF-8?B?QW5kcmVhcw==?= =?UTF-8?B?IEbDpHJiZXI=?= , Amit Shah , Paolo Bonzini , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= 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