public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2023-08-30 12:39 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2023-08-30 12:39 UTC (permalink / raw)
  To: glibc-cvs

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

commit f60321baf6872a8ee3964dff1f73091729ffe701
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 39cf34cd4d..b177956ca6 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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2024-04-02 15:56 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 15:56 UTC (permalink / raw)
  To: glibc-cvs

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

commit 2eee91a4d704b811168649955a7210b8cccea165
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 3dd22a4e03..458627bac1 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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2024-02-09 17:34 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2024-02-09 17:34 UTC (permalink / raw)
  To: glibc-cvs

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

commit e295575a073fb0105f8bc3053566c0274aee67c9
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 3dd22a4e03..458627bac1 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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2024-02-07 14:10 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2024-02-07 14:10 UTC (permalink / raw)
  To: glibc-cvs

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

commit 56cd19161315921f3a35768b7116dd4a2aab62f1
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 3dd22a4e03..458627bac1 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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2024-01-29 18:00 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2024-01-29 18:00 UTC (permalink / raw)
  To: glibc-cvs

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

commit 00af0f69bf7e832cef031293e2b5134b36656a5b
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 3dd22a4e03..458627bac1 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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2023-12-21 18:57 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2023-12-21 18:57 UTC (permalink / raw)
  To: glibc-cvs

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

commit bd1d349c8b2c443bc7a2927ddb8952df5d2ee3a8
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 39cf34cd4d..b177956ca6 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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2023-09-28 17:55 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2023-09-28 17:55 UTC (permalink / raw)
  To: glibc-cvs

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

commit 7438bae37bc2678b200eaa9366dfcbbd8fd5b7c7
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 39cf34cd4d..b177956ca6 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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2023-02-09 19:51 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2023-02-09 19:51 UTC (permalink / raw)
  To: glibc-cvs

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

commit 9c4af6e72887b35516e3b864af196ddf8971f9b8
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 39cf34cd4d..b177956ca6 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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2022-10-28 17:44 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2022-10-28 17:44 UTC (permalink / raw)
  To: glibc-cvs

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;

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c
@ 2022-10-04 13:02 Adhemerval Zanella
  0 siblings, 0 replies; 10+ messages in thread
From: Adhemerval Zanella @ 2022-10-04 13:02 UTC (permalink / raw)
  To: glibc-cvs

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

commit a816e0a4b236c11b8c21890c5af0a21c0e902237
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;

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-04-02 15:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-30 12:39 [glibc/azanella/clang] dirent: Remove variable lenght array structure for tst-getdents64.c Adhemerval Zanella
  -- 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-02-09 19:51 Adhemerval Zanella
2022-10-28 17:44 Adhemerval Zanella
2022-10-04 13:02 Adhemerval Zanella

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).