unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] dlfcn: Avoid one-element flexible array in Dl_serinfo
Date: Fri, 24 May 2019 16:47:44 -0700	[thread overview]
Message-ID: <d8732d23-4ebc-1530-bc37-1945778d05fe@cs.ucla.edu> (raw)
In-Reply-To: <8736l4utui.fsf@oldenburg2.str.redhat.com>

On 5/24/19 1:42 AM, Florian Weimer wrote:
> This changes the size of the type and is not source-code-compatible.  I
> have not investigated whether the change is still reasonably safe, but
> usually, wo do not make such changes.

OK, in that case I suggest adding a comment explaining the situation, 
since it is a bit of a sore thumb. Something like the following perhaps? 
Or if this problem is likely to occur elsewhere, we could package the 
situation up into a macro and just use the macro here.

     /* An array of dls_cnt elements, each of type Dl_serpath.  */
   #if 0
     /* With no backward-compatibility concerns we’d use the following
        C99 flexible array member.  However, as this data structure
        predates C99 it had to contain a one-element array here, and we
        don't want to change the struct's size now.  */
     Dl_serpath dls_serpath[];
   #elif defined __GNUC__
     /* Avoid an unwanted array subscript check by the compiler, while
        preserving the size of the type.  */
     __extension__ union
     {
       Dl_serpath dls_serpath[0]; /* Actually longer, dls_cnt elements.  */
       Dl_serpath __dls_serpath_pad[1];
     };
   #else
     Dl_serpath dls_serpath[1];
   #endif


  reply	other threads:[~2019-05-24 23:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  9:34 [PATCH] dlfcn: Avoid one-element flexible array in Dl_serinfo Florian Weimer
2019-05-23 22:42 ` Paul Eggert
2019-05-23 22:50   ` Joseph Myers
2019-05-24  8:42   ` Florian Weimer
2019-05-24 23:47     ` Paul Eggert [this message]
2019-05-27 19:04       ` Florian Weimer
2019-06-01  8:48         ` Paul Eggert
2019-06-03  7:59         ` Florian Weimer
  -- strict thread matches above, loose matches on Subject: below --
2019-06-03 15:37 Florian Weimer
2019-06-18 14:27 ` Florian Weimer
2019-06-18 22:17   ` Paul Eggert

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

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d8732d23-4ebc-1530-bc37-1945778d05fe@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).