From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH] libxl: Introduce LIBXL_DOMAIN_TYPE_INVALID to make gcc happy Date: Wed, 23 May 2012 15:12:32 +0200 Message-ID: <1337778752.27368.90.camel@Solace> References: <4FB63171.3020102@amd.com> <4FB63EB6.10803@amd.com> <1337351445.16815.19.camel@Solace> <1337351979.22316.123.camel@zakaz.uk.xensource.com> <1337352492.16815.22.camel@Solace> <1337352958.22316.126.camel@zakaz.uk.xensource.com> <20412.49592.945171.764646@mariner.uk.xensource.com> <1337771858.27368.72.camel@Solace> <20412.55808.555103.132979@mariner.uk.xensource.com> <1337777350.27368.82.camel@Solace> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7546928933463869765==" Return-path: In-Reply-To: <1337777350.27368.82.camel@Solace> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Christoph Egger , Ian Campbell , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org --===============7546928933463869765== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-rE6KcvyEUnG/1qA7AKOG" --=-rE6KcvyEUnG/1qA7AKOG Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2012-05-23 at 14:49 +0200, Dario Faggioli wrote: > Problem arises > with auto-generated code, e.g., in gentypes.py for build_info related > functions. In this case, in fact, the libxl_domain_type enum is the key > of the keyed-union. For those cases, I was thinking at something like > the below: >=20 > if isinstance(ty, idl.KeyedUnion): > if parent is None: > raise Exception("KeyedUnion type must have a parent") > s +=3D "switch (%s) {\n" % (parent + ty.keyvar.name) > for f in ty.fields: > (nparent,fexpr) =3D ty.member(v, f, parent is None) > s +=3D "case %s:\n" % f.enumname > s +=3D libxl_C_type_dispose(f.type, fexpr, indent + " ", n= parent) > s +=3D " break;\n" > + s +=3D "default:\n break;\n"; > s +=3D "}\n" >=20 > Would it make sense? >=20 Like this thing below. Christoph, this ended up extending what you sent at the very beginning of this thread, so I think we should both sign-off-by it (and thus it took the liberty going ahead and adding yours), do you agree? <----------------------- libxl: introduce LIBXL_DOMAIN_TYPE_INVALID To avoid recent gcc complaining about: libxl.c: In function =E2=80=98libxl_primary_console_exec=E2=80=99: libxl.c:1233:9: error: case value =E2=80=984294967295=E2=80=99 not in enume= rated type =E2=80=98libxl_domain_type=E2=80=99 [-Werror=3Dswitch] Adjust code pieces where -Wswitch makes it claim that LIBXL_DOMAIN_TYPE_INVALID is not handled. Signed-off-by: Dario Faggioli Signed-off-by: Christoph Egger diff -r 6dc80df50fa8 tools/libxl/gentest.py --- a/tools/libxl/gentest.py Tue May 22 16:30:11 2012 +0200 +++ b/tools/libxl/gentest.py Wed May 23 15:05:20 2012 +0200 @@ -37,6 +37,8 @@ def gen_rand_init(ty, v, indent =3D " " s +=3D "case %s:\n" % f.enumname s +=3D gen_rand_init(f.type, fexpr, indent + " ", nparent) s +=3D " break;\n" + s +=3D "default:\n"; + s +=3D " break;\n"; s +=3D "}\n" elif isinstance(ty, idl.Struct) \ and (parent is None or ty.json_fn is None): diff -r 6dc80df50fa8 tools/libxl/gentypes.py --- a/tools/libxl/gentypes.py Tue May 22 16:30:11 2012 +0200 +++ b/tools/libxl/gentypes.py Wed May 23 15:05:20 2012 +0200 @@ -65,6 +65,8 @@ def libxl_C_type_dispose(ty, v, indent =3D s +=3D "case %s:\n" % f.enumname s +=3D libxl_C_type_dispose(f.type, fexpr, indent + " ", np= arent) s +=3D " break;\n" + s +=3D "default:\n"; + s +=3D " break;\n"; s +=3D "}\n" elif isinstance(ty, idl.Struct) and (parent is None or ty.dispose_fn i= s None): for f in [f for f in ty.fields if not f.const]: @@ -98,6 +100,8 @@ def _libxl_C_type_init(ty, v, indent =3D " s +=3D "case %s:\n" % f.enumname s +=3D _libxl_C_type_init(f.type, fexpr, " ", nparent) s +=3D " break;\n" + s +=3D "default:\n"; + s +=3D " break;\n"; s +=3D "}\n" else: if ty.keyvar.init_val: @@ -177,6 +181,8 @@ def libxl_C_type_gen_json(ty, v, indent=20 s +=3D "case %s:\n" % f.enumname s +=3D libxl_C_type_gen_json(f.type, fexpr, indent + " ", n= parent) s +=3D " break;\n" + s +=3D "default:\n"; + s +=3D " break;\n"; s +=3D "}\n" elif isinstance(ty, idl.Struct) and (parent is None or ty.json_fn is N= one): s +=3D "s =3D yajl_gen_map_open(hand);\n" diff -r 6dc80df50fa8 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Tue May 22 16:30:11 2012 +0200 +++ b/tools/libxl/libxl.c Wed May 23 15:05:20 2012 +0200 @@ -1230,7 +1230,7 @@ int libxl_primary_console_exec(libxl_ctx case LIBXL_DOMAIN_TYPE_PV: rc =3D libxl_console_exec(ctx, domid_vm, 0, LIBXL_CONSOLE_TYPE= _PV); break; - case -1: + case LIBXL_DOMAIN_TYPE_INVALID: LOG(ERROR,"unable to get domain type for domid=3D%"PRIu32,domi= d_vm); rc =3D ERROR_FAIL; break; diff -r 6dc80df50fa8 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Tue May 22 16:30:11 2012 +0200 +++ b/tools/libxl/libxl_dm.c Wed May 23 15:05:20 2012 +0200 @@ -257,6 +257,8 @@ static char ** libxl__build_device_model for (i =3D 0; b_info->extra_hvm && b_info->extra_hvm[i] !=3D NULL;= i++) flexarray_append(dm_args, b_info->extra_hvm[i]); break; + case LIBXL_DOMAIN_TYPE_INVALID: + break; } flexarray_append(dm_args, NULL); return (char **) flexarray_contents(dm_args); @@ -505,6 +507,8 @@ static char ** libxl__build_device_model for (i =3D 0; b_info->extra_hvm && b_info->extra_hvm[i] !=3D NULL;= i++) flexarray_append(dm_args, b_info->extra_hvm[i]); break; + case LIBXL_DOMAIN_TYPE_INVALID: + break; } =20 ram_size =3D libxl__sizekb_to_mb(b_info->max_memkb - b_info->video_mem= kb); diff -r 6dc80df50fa8 tools/libxl/libxl_dom.c --- a/tools/libxl/libxl_dom.c Tue May 22 16:30:11 2012 +0200 +++ b/tools/libxl/libxl_dom.c Wed May 23 15:05:20 2012 +0200 @@ -33,9 +33,9 @@ libxl_domain_type libxl__domain_type(lib =20 ret =3D xc_domain_getinfolist(ctx->xch, domid, 1, &info); if (ret !=3D 1) - return -1; + return LIBXL_DOMAIN_TYPE_INVALID; if (info.domain !=3D domid) - return -1; + return LIBXL_DOMAIN_TYPE_INVALID; if (info.flags & XEN_DOMINF_hvm_guest) return LIBXL_DOMAIN_TYPE_HVM; else diff -r 6dc80df50fa8 tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Tue May 22 16:30:11 2012 +0200 +++ b/tools/libxl/libxl_types.idl Wed May 23 15:05:20 2012 +0200 @@ -30,6 +30,7 @@ MemKB =3D UInt(64, init_val =3D "LIBXL_MEMKB # =20 libxl_domain_type =3D Enumeration("domain_type", [ + (-1, "INVALID"), (1, "HVM"), (2, "PV"), ]) --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://retis.sssup.it/people/faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-rE6KcvyEUnG/1qA7AKOG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEABECAAYFAk+84kAACgkQk4XaBE3IOsQiegCeMchHOvSEhrNgOB14QkbBoj0B xWAAoJd/F0TAXjptq2gPw6qbzkMtEn/F =RABH -----END PGP SIGNATURE----- --=-rE6KcvyEUnG/1qA7AKOG-- --===============7546928933463869765== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============7546928933463869765==--