From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MmBmX-0000tp-Gq for qemu-devel@nongnu.org; Fri, 11 Sep 2009 15:27:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MmBmT-0000rA-ON for qemu-devel@nongnu.org; Fri, 11 Sep 2009 15:27:41 -0400 Received: from [199.232.76.173] (port=39687 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MmBmT-0000r0-Hn for qemu-devel@nongnu.org; Fri, 11 Sep 2009 15:27:37 -0400 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:12485 helo=TX2EHSOBE005.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1MmBmT-0006rk-7g for qemu-devel@nongnu.org; Fri, 11 Sep 2009 15:27:37 -0400 Message-ID: <4AAAA56C.2050108@amd.com> Date: Fri, 11 Sep 2009 21:30:52 +0200 From: Andre Przywara MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 09/12] cpuid: simplify CPUID flag search function References: <1252621257-26364-1-git-send-email-andre.przywara@amd.com> <1252621257-26364-10-git-send-email-andre.przywara@amd.com> <20090911075500.GE31399@amit-x200.redhat.com> In-Reply-To: <20090911075500.GE31399@amit-x200.redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: qemu-devel@nongnu.org Amit Shah wrote: > On (Fri) Sep 11 2009 [00:20:54], Andre Przywara wrote: >> avoid code duplication and handle the CPUID flag name search in a >> loop. >> --- a/target-i386/cpuid.c >> +++ b/target-i386/cpuid.c >> @@ -71,29 +71,22 @@ static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features, >> uint32_t *ext2_features, >> uint32_t *ext3_features) >> { >>... >> + for (j = 0; j < 4; j++) { >> + for (i = 0; i < 32; i++) { >> + if (feature_names[j][i] && >> + !strcmp(flagname, feature_names[j][i])) { >> + *feature_flags[j] |= 1 << i; >> + found = 1; >> + } >> + } >> if (!found) { >> fprintf(stderr, "CPU feature %s not found\n", flagname); >> } > > This just reports the entire string, right? Not just the feature as the > printf suggests. What makes you think so? flagname is just the single flag (being returned by strtok in the caller, wich null-terminates its results). Otherwise the strcmp() above would not work either... Unknown flags will be reported, but do not abort QEMU (I checked this myself by accident ;-) Regards, Andre. -- Andre Przywara AMD-OSRC (Dresden) Tel: x29712