Page MenuHomeFreeBSD

tests/fusefs: appease gcc -Wcast-qual
ClosedPublic

Authored by rlibby on Apr 13 2026, 2:02 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jun 10, 9:56 AM
Unknown Object (File)
Sun, May 31, 10:02 PM
Unknown Object (File)
Sat, May 30, 7:32 AM
Unknown Object (File)
Sat, May 30, 4:52 AM
Unknown Object (File)
Thu, May 28, 10:18 AM
Unknown Object (File)
Wed, May 27, 12:18 PM
Unknown Object (File)
Wed, May 27, 7:25 AM
Unknown Object (File)
Tue, May 26, 4:11 PM
Subscribers

Details

Summary

Fix gcc build error.

Fixes: 7e68af7ce2c1 ("fusefs: redo vnode attribute locking")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 72166
Build 69049: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Apr 15 2026, 9:41 AM

Instead of relying on casting, how about we fix the problem more robustly, like this?

diff --git a/tests/sys/fs/fusefs/rename.cc b/tests/sys/fs/fusefs/rename.cc
index 385f26953aae..ae57469f2665 100644
--- a/tests/sys/fs/fusefs/rename.cc
+++ b/tests/sys/fs/fusefs/rename.cc
@@ -166,7 +166,7 @@ TEST_F(Rename, entry_cache_negative_purge)
 static volatile int stopit = 0;
 
 static void* setattr_th(void* arg) {
-       char *path = (char*)arg;
+       const char *path = *(const char**)arg;
 
        while (stopit == 0)
                 chmod(path, 0777);
@@ -239,7 +239,7 @@ TEST_F(Rename, erelookup)
                _)
        ).WillRepeatedly(Invoke(ReturnErrno(EIO)));
 
-       ASSERT_EQ(0, pthread_create(&th0, NULL, setattr_th, (void*)FULLSRC))
+       ASSERT_EQ(0, pthread_create(&th0, NULL, setattr_th, (void*)&FULLSRC))
                << strerror(errno);
 
        ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, &timeout));
This revision now requires changes to proceed.Apr 15 2026, 12:58 PM
-       ASSERT_EQ(0, pthread_create(&th0, NULL, setattr_th, (void*)FULLSRC))
+       ASSERT_EQ(0, pthread_create(&th0, NULL, setattr_th, (void*)&FULLSRC))
                << strerror(errno);

This leads to essentially the same complaint from gcc:

/usr/src/freebsd/tests/sys/fs/fusefs/rename.cc:242:61: error: cast from type 'const char (*)[15]' to type 'void*' casts away qualifiers [-Werror=cast-qual]
  242 |         ASSERT_EQ(0, pthread_create(&th0, NULL, setattr_th, (void*)&FULLSRC))
      |                                                             ^~~~~~~~~~~~~~~

Ooh pooh. I guess you should do it your way, then.

This revision is now accepted and ready to land.Apr 15 2026, 4:01 PM
This revision was automatically updated to reflect the committed changes.