Received: from eggs.gnu.org ([208.118.235.92]:35364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToIQg-0002me-3T for qemu-devel@nongnu.org; Thu, 27 Dec 2012 13:43:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ToIQe-000120-SP for qemu-devel@nongnu.org; Thu, 27 Dec 2012 13:43:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToIQe-00011s-JF for qemu-devel@nongnu.org; Thu, 27 Dec 2012 13:43:40 -0500 Date: Thu, 27 Dec 2012 16:45:19 -0200 From: Eduardo Habkost Message-ID: <20121227184519.GK18372@otherpad.lan.raisama.net> References: <1356620376-23501-1-git-send-email-imammedo@redhat.com> <1356620376-23501-8-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1356620376-23501-8-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH 07/20] target-i386: cpu_x86_register() consolidate freeing resources List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, afaerber@suse.de On Thu, Dec 27, 2012 at 03:59:23PM +0100, Igor Mammedov wrote: > freeing resources in one place would require setting 'error' > to not NULL, so add some more error reporting before jumping to > exit branch. > > Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost > --- > v2: > - add missing 'return -1' on exit if error is not NULL, > Spotted-By: Eduardo Habkost > v3: > - set error if cpu_model is empty > --- > target-i386/cpu.c | 18 +++++++++--------- > 1 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 3b9bbfe..97cce89 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -1550,13 +1550,15 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model) > > model_pieces = g_strsplit(cpu_model, ",", 2); > if (!model_pieces[0]) { > - goto error; > + error_setg(&error, "Invalid/empty CPU model name"); > + goto out; > } > name = model_pieces[0]; > features = model_pieces[1]; > > if (cpu_x86_find_by_name(def, name) < 0) { > - goto error; > + error_setg(&error, "Unable to find CPU definition: %s", name); > + goto out; > } > > def->kvm_features |= kvm_default_features; > @@ -1566,22 +1568,20 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model) > &def->svm_features, &def->cpuid_7_0_ebx_features); > > if (cpu_x86_parse_featurestr(def, features) < 0) { > - goto error; > + error_setg(&error, "Invalid cpu_model string format: %s", cpu_model); > + goto out; > } > > cpudef_2_x86_cpu(cpu, def, &error); > > +out: > + g_strfreev(model_pieces); > if (error) { > fprintf(stderr, "%s\n", error_get_pretty(error)); > error_free(error); > - goto error; > + return -1; > } > - > - g_strfreev(model_pieces); > return 0; > -error: > - g_strfreev(model_pieces); > - return -1; > } > > #if !defined(CONFIG_USER_ONLY) > -- > 1.7.1 > -- Eduardo