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
Date: Mon,  4 Apr 2022 12:57:36 +0000 (GMT)	[thread overview]
Message-ID: <20220404125736.0EABA3858405@sourceware.org> (raw)

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

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

    dirent: Remove variable lenght array structure

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-04-04 12:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 12:57 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-06-09 21:23 Adhemerval Zanella
2022-06-09 13:19 Adhemerval Zanella
2022-06-03 14:09 Adhemerval Zanella
2022-05-13 14:23 Adhemerval Zanella
2022-05-12 19:36 Adhemerval Zanella
2022-05-10 18:27 Adhemerval Zanella
2022-04-29 14:07 Adhemerval Zanella
2022-03-31 19:09 Adhemerval Zanella
2022-03-29 20:33 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=20220404125736.0EABA3858405@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).