From: Igor Mammedov <imammedo@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v6 3/5] acpi: add build_append_namestring() helper
Date: Mon, 2 Feb 2015 09:31:58 +0100 [thread overview]
Message-ID: <20150202093158.715ede07@nial.brq.redhat.com> (raw)
In-Reply-To: <20150131170547.GA31871@redhat.com>
On Sat, 31 Jan 2015 19:05:47 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Fri, Jan 30, 2015 at 12:46:41PM +0100, Igor Mammedov wrote:
> > On Wed, 28 Jan 2015 17:16:17 +0200
> > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> >
> > > On Wed, Jan 28, 2015 at 02:34:48PM +0000, Igor Mammedov wrote:
> > > > Use build_append_namestring() instead of build_append_nameseg()
> > > > So user won't have to care whether name is NameSeg, NamePath or
> > > > NameString.
> > > >
> > > > See for refernce ACPI 5.0: 20.2.2 Name Objects Encoding
> > > >
> > >
> > > typo
> > >
> > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > > Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
> > > > Acked-by: Marcel Apfelbaum <marcel@redhat.com>
> > > > ---
> > > > v4:
> > > > * fix codding style of ACPI_DualNamePrefix & ACPI_MultiNamePrefix
> > > > it's imposible to use literals as suggested due to
> > > > g_array_append_val() requiring reference value
> > > >
> > > > v3:
> > > > assert on wrong Segcount earlier and extend condition to
> > > > seg_count > 0 && seg_count <= 255
> > > > as suggested by Claudio Fontana <claudio.fontana@huawei.com>
> > > > ---
> > > > hw/acpi/aml-build.c | 92
> > > > ++++++++++++++++++++++++++++++++++++++++++++-
> > > > hw/i386/acpi-build.c | 35 ++++++++---------
> > > > include/hw/acpi/aml-build.h | 2 +- 3 files changed, 108
> > > > insertions(+), 21 deletions(-)
> > > >
> > > > diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> > > > index b28c1f4..ed4ab56 100644
> > > > --- a/hw/acpi/aml-build.c
> > > > +++ b/hw/acpi/aml-build.c
> > > > @@ -52,7 +52,7 @@ void build_append_array(GArray *array, GArray
> > > > *val)
> > > > #define ACPI_NAMESEG_LEN 4
> > > >
> > > > -void GCC_FMT_ATTR(2, 3)
> > > > +static void GCC_FMT_ATTR(2, 3)
> > > > build_append_nameseg(GArray *array, const char *format, ...)
> > > > {
> > > > /* It would be nicer to use g_string_vprintf but it's only
> > > > there in 2.22 */ @@ -71,6 +71,96 @@ build_append_nameseg(GArray
> > > > *array, const char *format, ...) g_array_append_vals(array, "____",
> > > > ACPI_NAMESEG_LEN - len); }
> > > >
> > > > +static void
> > > > +build_append_namestringv(GArray *array, const char *format,
> > > > va_list ap) +{
> > > > + /* It would be nicer to use g_string_vprintf but it's only
> > > > there in 2.22 */
> > > > + char *s;
> > > > + int len;
> > > > + va_list va_len;
> > > > + char **segs;
> > > > + char **segs_iter;
> > > > + int seg_count = 0;
> > > > +
> > > > + va_copy(va_len, ap);
> > > > + len = vsnprintf(NULL, 0, format, va_len);
> > > > + va_end(va_len);
> > > > + len += 1;
> > > > + s = g_new(typeof(*s), len);
> > > > +
> > > > + len = vsnprintf(s, len, format, ap);
> > > > +
> > > > + segs = g_strsplit(s, ".", 0);
> > > > + g_free(s);
> > > > +
> > > > + /* count segments */
> > > > + segs_iter = segs;
> > > > + while (*segs_iter) {
> > > > + ++segs_iter;
> > > > + ++seg_count;
> > > >
> > > How about we split out formatting?
> > > Make +build_append_namestringv acceptconst char **segs, int nsegs,
> > > put all code above to build_append_namestring.
> > Can't do this, AML API calls which accept format string will
> > use build_append_namestringv()
>
> OK but I still think it's a good idea to split this out,
> and have a static function that accepts an array of segments.
It would be a static function with a single call site from another
static function. I see no point is doing it, on contrary it would be
confusing why do we have function if we do not reuse it.
I'd split out the moment we actually need it.
>
>
next prev parent reply other threads:[~2015-02-02 8:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-28 14:34 [Qemu-devel] [PATCH v6 0/5] pc: acpi: various fixes and cleanups Igor Mammedov
2015-01-28 14:34 ` [Qemu-devel] [PATCH v6 1/5] pc: acpi-build: cleanup AcpiPmInfo initialization Igor Mammedov
2015-01-28 15:22 ` Michael S. Tsirkin
2015-01-28 14:34 ` [Qemu-devel] [PATCH v6 2/5] acpi: move generic aml building helpers into dedictated file Igor Mammedov
2015-01-28 14:34 ` [Qemu-devel] [PATCH v6 3/5] acpi: add build_append_namestring() helper Igor Mammedov
2015-01-28 15:16 ` Michael S. Tsirkin
2015-01-28 15:44 ` Igor Mammedov
2015-01-28 16:07 ` Michael S. Tsirkin
2015-01-30 11:46 ` Igor Mammedov
2015-01-31 17:05 ` Michael S. Tsirkin
2015-02-02 8:31 ` Igor Mammedov [this message]
2015-01-28 14:34 ` [Qemu-devel] [PATCH v6 4/5] acpi: drop min-bytes in build_package() Igor Mammedov
2015-01-28 14:34 ` [Qemu-devel] [PATCH v6 5/5] pc: acpi-build: simplify PCI bus tree generation Igor Mammedov
2015-01-28 15:21 ` Michael S. Tsirkin
2015-01-28 15:53 ` Igor Mammedov
2015-01-28 16:02 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150202093158.715ede07@nial.brq.redhat.com \
--to=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).