diff mbox series

[v2] smb: server: Fix building with GCC 15

Message ID 20241126061135.2762074-1-brahmajit.xyz@gmail.com (mailing list archive)
State New
Headers show
Series [v2] smb: server: Fix building with GCC 15 | expand

Commit Message

Brahmajit Das Nov. 26, 2024, 6:11 a.m. UTC
GCC 15 introduces -Werror=unterminated-string-initialization by default,
this results in the following build error

fs/smb/server/smb_common.c:21:35: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-ini
tialization]
   21 | static const char basechars[43] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

To this we are replacing char basechars[43] with a character pointer
and then using strlen to get the length.

Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
---
 fs/smb/server/smb_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Namjae Jeon Nov. 27, 2024, 2:24 p.m. UTC | #1
On Tue, Nov 26, 2024 at 3:12 PM Brahmajit Das <brahmajit.xyz@gmail.com> wrote:
>
> GCC 15 introduces -Werror=unterminated-string-initialization by default,
> this results in the following build error
>
> fs/smb/server/smb_common.c:21:35: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-ini
> tialization]
>    21 | static const char basechars[43] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
>       |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> To this we are replacing char basechars[43] with a character pointer
> and then using strlen to get the length.
>
> Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
Applied it to #ksmbd-for-next-next.
Thanks!
diff mbox series

Patch

diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
index 75b4eb856d32..af8e24163bf2 100644
--- a/fs/smb/server/smb_common.c
+++ b/fs/smb/server/smb_common.c
@@ -18,8 +18,8 @@ 
 #include "mgmt/share_config.h"
 
 /*for shortname implementation */
-static const char basechars[43] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
-#define MANGLE_BASE (sizeof(basechars) / sizeof(char) - 1)
+static const char *basechars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
+#define MANGLE_BASE (strlen(basechars) - 1)
 #define MAGIC_CHAR '~'
 #define PERIOD '.'
 #define mangle(V) ((char)(basechars[(V) % MANGLE_BASE]))