From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUaaw-0003UD-Q1 for qemu-devel@nongnu.org; Tue, 02 Aug 2016 10:23:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUaar-00013q-0t for qemu-devel@nongnu.org; Tue, 02 Aug 2016 10:22:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUaaq-00013c-RD for qemu-devel@nongnu.org; Tue, 02 Aug 2016 10:22:52 -0400 Date: Tue, 2 Aug 2016 11:22:50 -0300 From: Eduardo Habkost Message-ID: <20160802142250.GG3337@thinpad.lan.raisama.net> References: <1470139155-53900-1-git-send-email-dahi@linux.vnet.ibm.com> <1470139155-53900-28-git-send-email-dahi@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1470139155-53900-28-git-send-email-dahi@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [Patch v1 27/29] s390x/cpumodel: implement QMP interface "query-cpu-model-expansion" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Hildenbrand Cc: qemu-devel@nongnu.org, jdenemar@redhat.com, imammedo@redhat.com, cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, fiuczy@linux.vnet.ibm.com, mimu@linux.vnet.ibm.com On Tue, Aug 02, 2016 at 01:59:13PM +0200, David Hildenbrand wrote: [...] > +CpuModelExpansionInfo *arch_query_cpu_model_expansion(CpuModelExpansionType type, > + CpuModelInfo *model, > + Error **errp) > +{ > + CpuModelExpansionInfo *expansion_info = NULL; > + S390CPUModel s390_model; > + bool delta_changes = false; > + > + /* convert it to our internal representation */ > + cpu_model_from_info(&s390_model, model, errp); > + if (*errp) { > + return NULL; > + } > + > + if (type == CPU_MODEL_EXPANSION_TYPE_STATIC) { > + delta_changes = true; > + } This assumes the only valid values for type will always be "static" and "full". I would check explicitly for CPU_MODEL_EXPANSION_TYPE_STATIC and CPU_MODEL_EXPANSION_TYPE_FULL and return an error otherwise, just in case CpuModelExpansionType is extended to include other expansion modes in the future. > + > + /* convert it back to a static representation */ > + expansion_info = g_malloc0(sizeof(*expansion_info)); > + expansion_info->model = g_malloc0(sizeof(*expansion_info->model)); > + cpu_info_from_model(expansion_info->model, &s390_model, delta_changes); > + return expansion_info; > +} > #endif > > static void check_consistency(const S390CPUModel *model) > -- > 2.6.6 > -- Eduardo