From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RqkpP-0001EM-6J for mharc-qemu-trivial@gnu.org; Fri, 27 Jan 2012 07:22:51 -0500 Received: from eggs.gnu.org ([140.186.70.92]:43114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqkpJ-0000uQ-Tw for qemu-trivial@nongnu.org; Fri, 27 Jan 2012 07:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqkpF-0003Hs-U7 for qemu-trivial@nongnu.org; Fri, 27 Jan 2012 07:22:45 -0500 Received: from thoth.sbs.de ([192.35.17.2]:24630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqkpA-0003H4-HX; Fri, 27 Jan 2012 07:22:36 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id q0RCMVqL029805; Fri, 27 Jan 2012 13:22:31 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q0RCMSn5015964; Fri, 27 Jan 2012 13:22:28 +0100 Message-ID: <4F229704.9020003@siemens.com> Date: Fri, 27 Jan 2012 13:22:28 +0100 From: Jan Kiszka 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 MIME-Version: 1.0 To: "quintela@redhat.com" 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.2 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?= Subject: Re: [Qemu-trivial] [PATCH v8] qdev: Add support for property type bool X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2012 12:22:49 -0000 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 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