This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [review] slotinfo in struct dtv_slotinfo_list should be flexible array [BZ #25...
- From: Szabolcs Nagy <Szabolcs dot Nagy at arm dot com>
- To: "fweimer at redhat dot com" <fweimer at redhat dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, "Florian Weimer (Code Review)" <gerrit at gnutoolchain-gerrit dot osci dot io>
- Cc: nd <nd at arm dot com>
- Date: Wed, 6 Nov 2019 16:12:11 +0000
- Subject: Re: [review] slotinfo in struct dtv_slotinfo_list should be flexible array [BZ #25...
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TgvUNdnld1ctAP5byWfH3w1m8u3RdPM4DyRSgQPQGUE=; b=SbfdsmNL4Iqjjp5KYdj8Xd0qMVOhRfNO+ec5rxfWydVz3XSeFBWxN3+87mw6o8Cxzt7nngojKr+AYQ+7jKMDWXJXvNh0Bfah9jgmy/pAuglEoeFzgavF08y7PVjAjZg16dlYaKmHQzT9p0JeABIqISkzp4dC6i5qbNMFpvJhP2K5qWOV8JW1e8K6r1fsu1BvsNiHi7mjmp4/lwUmirZP738WE7B/wEW9LbaP2s0jDfRsquX9sHkzfD/dd+XzSi+SxuS79DaLJMq1rsYNUUDWpKS376V2M27niEKSaxN4XI1ridNKopWTV/WuzBXsTocgu13tuC9sMjFVL3WVKMCmyg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UiHuyHa28Xc3YY9LkfmEjwkoGjHEinZyIMFEtcoM7RgMHkh17CM+Hm/nO5dx0bzEfQRlhqgOi07rDjjx0jAUiDXgBKsVefTgp7DqyaVDlgcc/y4hUXMglpG1veJsgp7bqXnm2mV9DFrF1arGOGiTVNJn+v6/tkHheEs95F9gsioEZe5IVC/Lb8FrqGnxTkQ4zPmMax6aEebOtebZbTeKKApLq5XY85MB4XSNpyMfHC4ktwje++uq6hSf2RgEjI/SfO0PHhc6tu1NMYdDmfs3WM5eCY4B178CxU2PsZjnft7VCchrJvbr2kTGN1fDJKwBmOXKukPlk85UZbP3FFSDfg==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
- References: <gerrit.1572801105000.I51be146a7857186a4ede0bb40b332509487bdde8@gnutoolchain-gerrit.osci.io> <gerrit.1572801105000.I51be146a7857186a4ede0bb40b332509487bdde8@gnutoolchain-gerrit.osci.io>
On 03/11/2019 17:11, Florian Weimer (Code Review) wrote:
> Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/489
i can't login to gerrit. is there something special i need to do?
> slotinfo in struct dtv_slotinfo_list should be flexible array [BZ #25097]
>
> GCC 10 will warn about subscribing inner length zero arrays. Use a GCC
> extension in csu/libc-tls.c to allocate space for the static_slotinfo
> variable. Adjust nptl_db so that the type description machinery does
> not attempt to determine the size of the flexible array member slotinfo.
the patch looks ok to me.
> -static struct
> -{
> - struct dtv_slotinfo_list si;
> - /* The dtv_slotinfo_list data structure does not include the actual
> - information since it is defined as an array of size zero. We define
> - here the necessary entries. Note that it is not important whether
> - there is padding or not since we will always access the information
> - through the 'si' element. */
> - struct dtv_slotinfo info[2 + TLS_SLOTINFO_SURPLUS];
> -} static_slotinfo;
> -
> +static struct dtv_slotinfo_list static_slotinfo =
> + {
> + /* Allocate an array of 2 + TLS_SLOTINFO_SURPLUS elements. */
> + .slotinfo = { [array_length (_dl_static_dtv) - 1] = { } },
> + };
i'd use {0} instead of {} as that's the universal initializer in c.
(to me the original code looked more obvious)
> static void
> init_slotinfo (void)
> {
> - /* Create the slotinfo list. */
> - static_slotinfo.si.len = (((char *) (&static_slotinfo + 1)
> - - (char *) &static_slotinfo.si.slotinfo[0])
> - / sizeof static_slotinfo.si.slotinfo[0]);
> - // static_slotinfo.si.next = NULL; already zero
> + /* Create the slotinfo list. Note that the type of static_slotinfo
> + has effectively a zero-length array, so we cannot use the size of
> + static_slotinfo to determine the array length. */
> + static_slotinfo.len = array_length (_dl_static_dtv);
> + /* static_slotinfo.si.next = NULL; -- Already zero. */
i'd remove the .si in the comment (or remove that comment)