qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22
Date: Mon, 25 Nov 2013 22:54:04 +0200

On Tue, Nov 26, 2013 at 06:37:43AM +1000, Richard Henderson wrote:
> On 11/26/2013 06:31 AM, Michael S. Tsirkin wrote:
> > On Tue, Nov 26, 2013 at 06:24:53AM +1000, Richard Henderson wrote:
> >> On 11/25/2013 09:48 PM, Michael S. Tsirkin wrote:
> >>> g_string_vprintf was only introduced in 2.24 so switch to vsnprintf
> >>> instead.  A bit uglier but name size is fixed at 4 bytes here so it's
> >>> easy.
> >>
> >> You list 2.24 here,
> >>
> >>> -    GString *s = g_string_new("");
> >>> +    /* It would be nicer to use g_string_vprintf but it's only there in 
> >>> 2.22 */
> >>
> >> ... 2.22 here.
> >>
> >> But 
> >> https://developer.gnome.org/glib/2.28/glib-Strings.html#g-string-vprintf
> >>
> >> says "since 2.14".
> >>
> >>> +    char s[] = "XXXX";
> >>
> >> char s[5];
> >>
> >> Initializing it is a waste of time.
> >>
> >>
> >> r~
> > 
> > It's sets the length in a nice way.
> > 
> 
> Then do something like
> 
>   char s[sizeof("XXXX")];
> 
> so that the actual initialization doesn't happen.
> 
> 
> r~

Why? As an optimization?
I'm not quite sure this doesn't mean we are using VLA which I'd rather not.
Would need to look at language spec ... simple initialization is shorter
and more obviously correct.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]