Page MenuHomeFreeBSD

tests/fusefs: appease gcc -Wcast-qual
ClosedPublic

Authored by rlibby on Mon, Apr 13, 2:02 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 20, 4:29 AM
Unknown Object (File)
Mon, Apr 20, 12:54 AM
Unknown Object (File)
Sun, Apr 19, 2:44 AM
Unknown Object (File)
Sat, Apr 18, 5:21 AM
Unknown Object (File)
Sat, Apr 18, 5:17 AM
Unknown Object (File)
Sat, Apr 18, 4:38 AM
Unknown Object (File)
Sat, Apr 18, 4:37 AM
Unknown Object (File)
Sat, Apr 18, 4:37 AM
Subscribers

Details

Summary

Fix gcc build error.

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Wed, Apr 15, 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.Wed, Apr 15, 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.Wed, Apr 15, 4:01 PM
This revision was automatically updated to reflect the committed changes.