From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuMRj-00047Z-OV for qemu-devel@nongnu.org; Mon, 18 May 2015 10:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuMRe-000253-Q5 for qemu-devel@nongnu.org; Mon, 18 May 2015 10:55:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuMRe-00022E-H4 for qemu-devel@nongnu.org; Mon, 18 May 2015 10:55:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4IEt5im012890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 18 May 2015 10:55:05 -0400 Message-ID: <5559FD48.9070405@redhat.com> Date: Mon, 18 May 2015 08:55:04 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431620920-19710-1-git-send-email-quintela@redhat.com> <1431620920-19710-5-git-send-email-quintela@redhat.com> <20150518095834.GC2201@work-vm> In-Reply-To: <20150518095834.GC2201@work-vm> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="L1jk9cn9eEgdWaDInRMpAPRjMETPiPdUe" Subject: Re: [Qemu-devel] [PATCH 4/9] runstate: create runstate_index function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" , Juan Quintela Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --L1jk9cn9eEgdWaDInRMpAPRjMETPiPdUe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/18/2015 03:58 AM, Dr. David Alan Gilbert wrote: > * Juan Quintela (quintela@redhat.com) wrote: >> Given a string state, we need a way to get the RunState for that strin= g. >> >> Signed-off-by: Juan Quintela >> --- >> include/sysemu/sysemu.h | 1 + >> vl.c | 13 +++++++++++++ >> 2 files changed, 14 insertions(+) >> >> >> +RunState runstate_index(char *str) >> +{ >> + RunState i =3D 0; >> + >> + while (i !=3D RUN_STATE_MAX) { >> + if (strcmp(str, RunState_lookup[i]) =3D=3D 0) { >> + return i; >> + } >> + i++; >> + } >> + return -1; >=20 > It doesn't seem right to return -1 for the value of an enum > (which is otherwise used as an index into an array of strings). >=20 > Make it return a bool and pass the RunState* as a parameter ? Why open-code this, when we already have qapi_enum_parse() in qapi/qapi-util.c? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --L1jk9cn9eEgdWaDInRMpAPRjMETPiPdUe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVWf1IAAoJEKeha0olJ0Nq2I0H/RnDkeicRwuuRG0DHp8IgQec iHBxZaq87LY71cqJEB4wYwozP6M1bREp6mmGi21VqYlauE0atODRxcnMIufpuBXN rLPfEKsT2tOzBeKhMR28bENvehhBJ6C7kqHvyEtzhgu9wcw8vxhPPdUqHCrf+7Pu IbiS0tu771dn+aRCsFP34bWuGetq1lLSDc21HcZgQyUVpjVXZcTs857zB4bxdJIE vkH3H4pnXF9EnuxjVUXo8FpS5OaNE/r1gv1CNq1/Y3rjVxej/XZ1XBbU/4iuL2W8 rGI9JKbEOEPcsSwYEwFQ+yKdmXHPMpC77Th5K8pbx8Oaj35L3pYGDbvzPHV6fT8= =jarO -----END PGP SIGNATURE----- --L1jk9cn9eEgdWaDInRMpAPRjMETPiPdUe--