public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
Date: Fri, 28 Oct 2022 17:44:48 +0000 (GMT)	[thread overview]
Message-ID: <20221028174448.2E8333858C2C@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e24e83ef45222b722f54ec0d7ffa11653fd62b4d

commit e24e83ef45222b722f54ec0d7ffa11653fd62b4d
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 25 09:03:03 2022 -0300

    dirent: Remove variable lenght array structure for tst-getdents64.c
    
    Clang emits the following warnings:
    
      ../sysdeps/unix/sysv/linux/tst-getdents64.c:111:18: error: fields must
      have a constant size: 'variable length array in structure' extension
      will never be supported
                  char buffer[buffer_size];
                       ^

Diff:
---
 sysdeps/unix/sysv/linux/tst-getdents64.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/tst-getdents64.c b/sysdeps/unix/sysv/linux/tst-getdents64.c
index 62cfa97d06..9546a03944 100644
--- a/sysdeps/unix/sysv/linux/tst-getdents64.c
+++ b/sysdeps/unix/sysv/linux/tst-getdents64.c
@@ -96,6 +96,8 @@ do_test_by_size (size_t buffer_size)
   int fd = xopen (".", O_RDONLY | O_DIRECTORY, 0);
   TEST_VERIFY (fd >= 0);
 
+  char *data = xposix_memalign (_Alignof (struct dirent64), buffer_size);
+
   /* Perform two passes, with a rewind operating between passes.  */
   for (int pass = 0; pass < 2; ++pass)
     {
@@ -104,23 +106,15 @@ do_test_by_size (size_t buffer_size)
 
       while (true)
         {
-          /* Simple way to make sure that the memcpy below does not read
-             non-existing data.  */
-          struct
-          {
-            char buffer[buffer_size];
-            struct dirent64 pad;
-          } data;
-
-          ssize_t ret = getdents64 (fd, &data.buffer, sizeof (data.buffer));
+          ssize_t ret = getdents64 (fd, data, buffer_size);
           if (ret < 0)
             FAIL_EXIT1 ("getdents64: %m");
           if (ret == 0)
             break;
           ++read_count;
 
-          char *current = data.buffer;
-          char *end = data.buffer + ret;
+          char *current = data;
+          char *end = data + ret;
           while (current != end)
             {
               struct dirent64 entry;

             reply	other threads:[~2022-10-28 17:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 17:44 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-02 15:56 Adhemerval Zanella
2024-02-09 17:34 Adhemerval Zanella
2024-02-07 14:10 Adhemerval Zanella
2024-01-29 18:00 Adhemerval Zanella
2023-12-21 18:57 Adhemerval Zanella
2023-09-28 17:55 Adhemerval Zanella
2023-08-30 12:39 Adhemerval Zanella
2023-02-09 19:51 Adhemerval Zanella
2022-10-04 13:02 Adhemerval Zanella

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=20221028174448.2E8333858C2C@sourceware.org \
    --to=azanella@sourceware.org \
    --cc=glibc-cvs@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).