[COMMITTED] support: Fix Hurd build of tst-support_readdir (was: Re: [PATCH v5] support: Add <support/readdir.h>)

Message ID 87ed5o3jq4.fsf_-_@oldenburg.str.redhat.com
State Committed
Commit c9154cad66aa0b11ede62cc9190d3485c5ef6941
Headers
Series [COMMITTED] support: Fix Hurd build of tst-support_readdir (was: Re: [PATCH v5] support: Add <support/readdir.h>) |

Commit Message

Florian Weimer Sept. 12, 2024, 4:44 p.m. UTC
  * Joseph Myers:

> This introduces a testsuite build failure for Hurd ("'struct dirent64' has 
> no member named 'd_off'").

Sorry about that.  I've pushed the fix below.

Thanks,
Florian

Subject: support: Fix Hurd build of tst-support_readdir

Check for the availability of the d_off member at compile time, not
run time.

Fixes commit 1251e9ea49fba9f53bbf4f290f3db90c01931fa7
("support: Add <support/readdir.h>").

---
 support/tst-support_readdir.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)


base-commit: 1251e9ea49fba9f53bbf4f290f3db90c01931fa7
  

Patch

diff --git a/support/tst-support_readdir.c b/support/tst-support_readdir.c
index c0639571c7..66be94fa80 100644
--- a/support/tst-support_readdir.c
+++ b/support/tst-support_readdir.c
@@ -39,10 +39,13 @@  do_test (void)
       e.d_name = NULL;
       TEST_VERIFY (support_readdir (stream, op, &e));
       TEST_COMPARE (e.d_ino, reference->d_ino);
-      if (support_readdir_offset_width (op) != 0)
-        TEST_COMPARE (e.d_off, reference->d_off);
-      else
-        TEST_COMPARE (e.d_off, 0);
+#ifdef _DIRENT_HAVE_D_OFF
+      TEST_VERIFY (support_readdir_offset_width (op) != 0);
+      TEST_COMPARE (e.d_off, reference->d_off);
+#else
+      TEST_COMPARE (support_readdir_offset_width (op), 0);
+      TEST_COMPARE (e.d_off, 0);
+#endif
       TEST_COMPARE (e.d_type, reference->d_type);
       TEST_COMPARE_STRING (e.d_name, reference->d_name);
       free (e.d_name);