[lustre-devel] [PATCH 32/41] lustre: mark strings in char arrays as const

James Simmons jsimmons at infradead.org
Mon Apr 5 00:51:01 PST 2021


From: Mr NeilBrown <neilb at suse.de>

Most array of strings are marked 'const', but the strings within the
arrays often aren't.
This patch mark all strings in const arrays of strings as const.
This allows them to be placed in read-only memory.

WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: 734d6eb11b572a9a ("LU-6142 lustre: mark strings in char arrays as const")
Signed-off-by: Mr NeilBrown <neilb at suse.de>
Reviewed-on: https://review.whamcloud.com/39742
Reviewed-by: James Simmons <jsimmons at infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff at hpe.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/include/obd_cksum.h           | 2 +-
 fs/lustre/llite/lproc_llite.c           | 2 +-
 include/uapi/linux/lustre/lustre_user.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/lustre/include/obd_cksum.h b/fs/lustre/include/obd_cksum.h
index f7d316b..08c1cb9 100644
--- a/fs/lustre/include/obd_cksum.h
+++ b/fs/lustre/include/obd_cksum.h
@@ -127,7 +127,7 @@ enum cksum_types obd_cksum_type_select(const char *obd_name,
 /* Checksum algorithm names. Must be defined in the same order as the
  * OBD_CKSUM_* flags.
  */
-#define DECLARE_CKSUM_NAME const char *cksum_name[] = {"crc32", "adler", \
+#define DECLARE_CKSUM_NAME const char *const cksum_name[] = {"crc32", "adler", \
 	"crc32c", "reserved", "t10ip512", "t10ip4K", "t10crc512", "t10crc4K"}
 
 typedef u16 (obd_dif_csum_fn) (void *, unsigned int);
diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c
index 5d1e2f4..a2e61e1 100644
--- a/fs/lustre/llite/lproc_llite.c
+++ b/fs/lustre/llite/lproc_llite.c
@@ -995,7 +995,7 @@ static ssize_t default_easize_store(struct kobject *kobj,
 
 static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
 {
-	const char *str[] = LL_SBI_FLAGS;
+	const char *const str[] = LL_SBI_FLAGS;
 	struct super_block *sb = m->private;
 	int flags = ll_s2sbi(sb)->ll_flags;
 	int i = 0;
diff --git a/include/uapi/linux/lustre/lustre_user.h b/include/uapi/linux/lustre/lustre_user.h
index 0f195a4..7d4a9e9 100644
--- a/include/uapi/linux/lustre/lustre_user.h
+++ b/include/uapi/linux/lustre/lustre_user.h
@@ -1213,7 +1213,7 @@ enum changelog_rec_type {
 
 static inline const char *changelog_type2str(int type)
 {
-	static const char *changelog_str[] = {
+	static const char *const changelog_str[] = {
 		"MARK",  "CREAT", "MKDIR", "HLINK", "SLINK", "MKNOD", "UNLNK",
 		"RMDIR", "RENME", "RNMTO", "OPEN",  "CLOSE", "LYOUT", "TRUNC",
 		"SATTR", "XATTR", "HSM",   "MTIME", "CTIME", "ATIME", "",
-- 
1.8.3.1



More information about the lustre-devel mailing list