[PATCH] smb3: Fix complilation for gcc9

From: Uwe Kleine-König
Date: Tue Sep 10 2024 - 11:14:47 EST


Compiling an x86_64 allmodconfig on Ubuntu 20.04.6 using gcc Ubuntu
9.4.0-1ubuntu1~20.04.2) 9.4.0 fails as follows:

$ make fs/smb/client/compress/lz77.o
...
CC [M] fs/smb/client/compress/lz77.o
In file included from fs/smb/client/compress/lz77.c:10:
fs/smb/client/compress/lz77.h: In function ‘__count_common_bytes’:
fs/smb/client/compress/lz77.h:220:1: error: no return statement in function returning non-void [-Werror=return-type]
220 | }
| ^
cc1: all warnings being treated as errors
make[5]: *** [scripts/Makefile.build:244: fs/smb/client/compress/lz77.o] Error 1
make[4]: *** [scripts/Makefile.build:485: fs/smb/client] Error 2
make[3]: *** [scripts/Makefile.build:485: fs/smb] Error 2
make[2]: *** [scripts/Makefile.build:485: fs] Error 2
make[1]: *** [Makefile:1926: .] Error 2
make: *** [Makefile:224: __sub-make] Error 2

That compiler seems to know about __has_builtin but not to have
__builtin_ctzll. In that case fall back to the implementation that is
also active in the #ifndef __has_builtin case.

Fixes: 0fa8d04ff36d ("smb3: mark compression as CONFIG_EXPERIMENTAL and fix missing compression operation")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
---
Hello,

feel free to squash this into the original commit.

Best regards
Uwe

fs/smb/client/compress/lz77.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/smb/client/compress/lz77.h b/fs/smb/client/compress/lz77.h
index 3d0d3eaa8ffb..4fb939296f39 100644
--- a/fs/smb/client/compress/lz77.h
+++ b/fs/smb/client/compress/lz77.h
@@ -200,10 +200,8 @@ static __always_inline long lz77_copy(u8 *dst, const u8 *src, size_t count)

static __always_inline unsigned int __count_common_bytes(const unsigned long diff)
{
-#ifdef __has_builtin
-# if __has_builtin(__builtin_ctzll)
+#if defined(__has_builtin) && __has_builtin(__builtin_ctzll)
return (unsigned int)__builtin_ctzll(diff) >> 3;
-# endif
#else
/* count trailing zeroes */
unsigned long bits = 0, i, z = 0;

base-commit: 6708132e80a2ced620bde9b9c36e426183544a23
--
2.45.2