From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YhxtB-0002bQ-S4 for qemu-devel@nongnu.org; Tue, 14 Apr 2015 06:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yhxt7-0004Nh-HV for qemu-devel@nongnu.org; Tue, 14 Apr 2015 06:16:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yhxt7-0004NX-AA for qemu-devel@nongnu.org; Tue, 14 Apr 2015 06:16:13 -0400 Date: Tue, 14 Apr 2015 12:15:56 +0200 From: Igor Mammedov Message-ID: <20150414121556.064b4ed8@igors-macbook-pro.local> In-Reply-To: <552CB5DA.4080303@huawei.com> References: <1428055432-12120-1-git-send-email-zhaoshenglong@huawei.com> <1428055432-12120-17-git-send-email-zhaoshenglong@huawei.com> <87sic4ja5a.fsf@linaro.org> <20150414075457-mutt-send-email-mst@redhat.com> <552CB5DA.4080303@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 16/20] hw/acpi/aml-build: Add aml_else() term List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Shannon Zhao Cc: peter.maydell@linaro.org, hangaohuai@huawei.com, lersek@redhat.com, "Michael S. Tsirkin" , a.spyridakis@virtualopensystems.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com, hanjun.guo@linaro.org, msalter@redhat.com, pbonzini@redhat.com, Alex =?UTF-8?Q?Benn=C3=A9e?= , christoffer.dall@linaro.org, shannon.zhao@linaro.org On Tue, 14 Apr 2015 14:38:18 +0800 Shannon Zhao wrote: > On 2015/4/14 13:56, Michael S. Tsirkin wrote: > > On Mon, Apr 13, 2015 at 04:55:13PM +0100, Alex Benn=C3=A9e wrote: > >> > >> Shannon Zhao writes: > >> > >>> From: Shannon Zhao > >>> > >>> Signed-off-by: Shannon Zhao > >>> Signed-off-by: Shannon Zhao > >> > >> I was considering if the magic numbers should be defined somewhere > >> but I guess that is the point of the stub functions. > >=20 > > I don't think so: wrappers make sure each is used > > only once. enums would just obfuscate code. > > comments are better in that they match the language > > used in the acpi spec, exactly. > >=20 >=20 > I think this has nothing to do with the Opcode used once or other. > Maybe the Opcodes should be defined at one place, then have a whole > scope of the Opcodes and drop the magic numbers. I agree with Michael, With one off usage, It's easier to read code with magic numbers and comments, without having to jump around to find out what define or enum equals. =20 >=20 > >> Reviewed-by: Alex Benn=C3=A9e > >=20 > >> > >>> --- > >>> hw/acpi/aml-build.c | 7 +++++++ > >>> include/hw/acpi/aml-build.h | 1 + > >>> 2 files changed, 8 insertions(+) > >>> > >>> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c > >>> index 4f936f7..9b8b422 100644 > >>> --- a/hw/acpi/aml-build.c > >>> +++ b/hw/acpi/aml-build.c > >>> @@ -626,6 +626,13 @@ Aml *aml_if(Aml *predicate) > >>> return var; > >>> } > >>> =20 > >>> +/* ACPI 1.0: 16.2.3 Operators: DefElse */ > >>> +Aml *aml_else(void) > >>> +{ > >>> + Aml *var =3D aml_bundle(0xA1 /* ElseOp */, AML_PACKAGE); > >>> + return var; > >>> +} > >>> + > >>> /* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMethod */ > >>> Aml *aml_method(const char *name, int arg_count) > >>> { > >>> diff --git a/include/hw/acpi/aml-build.h > >>> b/include/hw/acpi/aml-build.h index 6b407d5..3901515 100644 > >>> --- a/include/hw/acpi/aml-build.h > >>> +++ b/include/hw/acpi/aml-build.h > >>> @@ -206,6 +206,7 @@ Aml *aml_scope(const char *name_format, ...) > >>> GCC_FMT_ATTR(1, 2); Aml *aml_device(const char *name_format, ...) > >>> GCC_FMT_ATTR(1, 2); Aml *aml_method(const char *name, int > >>> arg_count); Aml *aml_if(Aml *predicate); > >>> +Aml *aml_else(void); > >>> Aml *aml_package(uint8_t num_elements); > >>> Aml *aml_buffer(void); > >>> Aml *aml_resource_template(void); > >> > >> --=20 > >> Alex Benn=C3=A9e > >=20 > >=20 > > . > >=20 >=20 >=20 >=20