From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mn5ue-0001Yy-Ub for qemu-devel@nongnu.org; Mon, 14 Sep 2009 03:23:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mn5ub-0001Ud-0F for qemu-devel@nongnu.org; Mon, 14 Sep 2009 03:23:48 -0400 Received: from [199.232.76.173] (port=52708 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mn5uZ-0001UX-Vi for qemu-devel@nongnu.org; Mon, 14 Sep 2009 03:23:44 -0400 Received: from mx20.gnu.org ([199.232.41.8]:29896) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mn5uZ-0007uG-CM for qemu-devel@nongnu.org; Mon, 14 Sep 2009 03:23:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mn5uX-0001WY-T0 for qemu-devel@nongnu.org; Mon, 14 Sep 2009 03:23:42 -0400 Date: Mon, 14 Sep 2009 12:53:11 +0530 From: Amit Shah Subject: Re: [Qemu-devel] [PATCH 09/12] cpuid: simplify CPUID flag search function Message-ID: <20090914072311.GC13280@amit-x200.redhat.com> 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> <4AAAA56C.2050108@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4AAAA56C.2050108@amd.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andre Przywara Cc: qemu-devel@nongnu.org On (Fri) Sep 11 2009 [21:30:52], Andre Przywara wrote: > 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 ;-) strtok, right. It'd be good to remove that. Esp with QemuOpts it would be easier Amit