Skip to content

Commit

Permalink
smb: server: Fix building with GCC 15
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
listout authored and namjaejeon committed Dec 2, 2024
1 parent ef3efb4 commit c4db9bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions smb_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,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]))
Expand Down

0 comments on commit c4db9bb

Please sign in to comment.