From: zhang.guodong@linux.dev
To: smfrench@gmail.com, chenxiaosong@chenxiaosong.com
Cc: linux-cifs@vger.kernel.org,
ZhangGuoDong <zhangguodong@kylinos.cn>,
ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH] smb/client: move smb2maperror declarations to smb2proto.h
Date: Fri, 3 Apr 2026 15:38:52 +0000 [thread overview]
Message-ID: <20260403153852.582746-1-zhang.guodong@linux.dev> (raw)
From: ZhangGuoDong <zhangguodong@kylinos.cn>
For `smb2_error_map_table_test` and `smb2_error_map_num`, if their types
are changed in `smb2maperror.c` but the corresponding extern declarations
in `smb2maperror_test.c` are not updated, the compiler will not report an
error. Moving them to a common header file allows the compiler to catch
type mismatches.
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2maperror.c | 3 ---
fs/smb/client/smb2maperror_test.c | 6 ++----
fs/smb/client/smb2proto.h | 7 ++++++-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/smb/client/smb2maperror.c b/fs/smb/client/smb2maperror.c
index 2b8782c4f684..9ed21f7b618c 100644
--- a/fs/smb/client/smb2maperror.c
+++ b/fs/smb/client/smb2maperror.c
@@ -112,9 +112,6 @@ int __init smb2_init_maperror(void)
#define EXPORT_SYMBOL_FOR_SMB_TEST(sym) \
EXPORT_SYMBOL_FOR_MODULES(sym, "smb2maperror_test")
-/* Previous prototype for eliminating the build warning. */
-const struct status_to_posix_error *smb2_get_err_map_test(__u32 smb2_status);
-
const struct status_to_posix_error *smb2_get_err_map_test(__u32 smb2_status)
{
return smb2_get_err_map(smb2_status);
diff --git a/fs/smb/client/smb2maperror_test.c b/fs/smb/client/smb2maperror_test.c
index 8c47dea7a2c1..f2dce23daa3d 100644
--- a/fs/smb/client/smb2maperror_test.c
+++ b/fs/smb/client/smb2maperror_test.c
@@ -9,11 +9,9 @@
*/
#include <kunit/test.h>
+#include "cifsglob.h"
#include "smb2glob.h"
-
-const struct status_to_posix_error *smb2_get_err_map_test(__u32 smb2_status);
-extern const struct status_to_posix_error *smb2_error_map_table_test;
-extern unsigned int smb2_error_map_num;
+#include "smb2proto.h"
static void
test_cmp_map(struct kunit *test, const struct status_to_posix_error *expect)
diff --git a/fs/smb/client/smb2proto.h b/fs/smb/client/smb2proto.h
index 230bb1e9f4e1..5f74475ba9d1 100644
--- a/fs/smb/client/smb2proto.h
+++ b/fs/smb/client/smb2proto.h
@@ -14,7 +14,6 @@
#include <linux/key-type.h>
#include "cached_dir.h"
-struct statfs;
struct smb_rqst;
/*
@@ -24,6 +23,12 @@ struct smb_rqst;
*/
int map_smb2_to_linux_error(char *buf, bool log_err);
int smb2_init_maperror(void);
+#if IS_ENABLED(CONFIG_SMB_KUNIT_TESTS)
+const struct status_to_posix_error *smb2_get_err_map_test(__u32 smb2_status);
+extern const struct status_to_posix_error *smb2_error_map_table_test;
+extern unsigned int smb2_error_map_num;
+#endif
+
int smb2_check_message(char *buf, unsigned int pdu_len, unsigned int len,
struct TCP_Server_Info *server);
unsigned int smb2_calc_size(void *buf);
--
2.53.0
reply other threads:[~2026-04-03 15:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260403153852.582746-1-zhang.guodong@linux.dev \
--to=zhang.guodong@linux.dev \
--cc=chenxiaosong@chenxiaosong.com \
--cc=chenxiaosong@kylinos.cn \
--cc=linux-cifs@vger.kernel.org \
--cc=smfrench@gmail.com \
--cc=zhangguodong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox