All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@redhat.com>,
	qemu-devel@nongnu.org
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	[thread overview]
Message-ID: <5293BF81.1060008@redhat.com> (raw)
In-Reply-To: <5293BDFC.1020208@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

  reply	other threads:[~2013-11-25 21:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 11:48 [Qemu-devel] [PULL for-1.7 v2 0/5] pc very last minute fixes for 1.7 Michael S. Tsirkin
2013-11-25 11:48 ` [Qemu-devel] [PULL for-1.7 v2 1/6] s390x: fix flat file load on 32 bit systems Michael S. Tsirkin
2013-11-25 11:48 ` [Qemu-devel] [PULL for-1.7 v2 2/6] pci: unregister vmstate_pcibus on unplug Michael S. Tsirkin
2013-11-25 11:48 ` [Qemu-devel] [PULL for-1.7 v2 3/6] acpi-build: fix build on glib < 2.22 Michael S. Tsirkin
2013-11-25 20:24   ` Richard Henderson
2013-11-25 20:31     ` Michael S. Tsirkin
2013-11-25 20:37       ` Richard Henderson
2013-11-25 20:54         ` Michael S. Tsirkin
2013-11-25 21:15           ` Laszlo Ersek
2013-11-25 21:22             ` Eric Blake [this message]
2013-11-25 21:18           ` Richard Henderson
2013-11-25 21:26             ` Michael S. Tsirkin
2013-11-25 21:02         ` Michael S. Tsirkin
2013-11-25 21:21           ` Richard Henderson
2013-11-25 21:33             ` Michael S. Tsirkin
2013-11-25 21:57               ` Laszlo Ersek
2013-11-25 11:48 ` [Qemu-devel] [PULL for-1.7 v2 4/6] acpi-build: fix build on glib < 2.14 Michael S. Tsirkin
2013-11-25 20:14   ` Erik Rull
2013-11-25 20:59     ` Michael S. Tsirkin
2013-11-25 21:01     ` Michael S. Tsirkin
2013-11-25 21:47       ` Richard Henderson
2013-11-25 22:41         ` Erik Rull
2013-11-25 20:26   ` Richard Henderson
2013-11-25 11:48 ` [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 11:48 ` [Qemu-devel] [PULL for-1.7 v2 6/6] configure: make --iasl option actually work 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=5293BF81.1060008@redhat.com \
    --to=eblake@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.