[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: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22 |
Date: |
Mon, 25 Nov 2013 14:22:09 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 |
On 11/25/2013 02:15 PM, Laszlo Ersek wrote:
>>>>>> + char s[] = "XXXX";
>>>>>
>>>>> char s[5];
>>>>>
>>>>> Initializing it is a waste of time.
And storage - the string literal occupies space in the binary image.
>>> Then do something like
>>>
>>> char s[sizeof("XXXX")];
Not to mention we already have at least one example of that idiom:
disas/cris.c: char temp[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
> (Admittedly, EXAMPLE 4 in 6.7.5.2 Array declarators, p10, is informative
> (not normative), and 6.7.5.2 Array declarators, p2, speaks about an
> "identifier". We don't have an identifier for "XXXX", but I think we can
> still derive that static storage duration implies non-variable length
> for the array that holds the string.)
Yes, use of char s[sizeof("")] is a fairly common idiom in C
programming, when you want to size the array large enough for it's
worst-case contents without actually wasting initialization/storage to
those contents.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PULL for-1.7 v2 0/5] pc very last minute fixes for 1.7, Michael S. Tsirkin, 2013/11/25
- Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22, Michael S. Tsirkin, 2013/11/25
- Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22, Richard Henderson, 2013/11/25
- Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22, Michael S. Tsirkin, 2013/11/25
- Re: [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22, Laszlo Ersek, 2013/11/25
[Qemu-devel] [PULL for-1.7 v2 5/6] Revert "e1000/rtl8139: update HMP NIC when every bit is written", Michael S. Tsirkin, 2013/11/25
[Qemu-devel] [PULL for-1.7 v2 6/6] configure: make --iasl option actually work, Michael S. Tsirkin, 2013/11/25
[Qemu-devel] [PULL for-1.7 v2 4/6] acpi-build: fix build on glib < 2.14, Michael S. Tsirkin, 2013/11/25