Whamcloud - gitweb
LU-6142 lustre: mark strings in char arrays as const 42/39742/2
authorMr NeilBrown <neilb@suse.de>
Thu, 27 Aug 2020 04:34:25 +0000 (14:34 +1000)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 21:43:19 +0000 (21:43 +0000)
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.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I93b627e646e446fc48d9b76f1d5e9da9d12b4395
Reviewed-on: https://review.whamcloud.com/39742
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
15 files changed:
lustre/include/obd_cksum.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/lfsck/lfsck_internal.h
lustre/lfsck/lfsck_lib.c
lustre/llite/lproc_llite.c
lustre/mgs/mgs_nids.c
lustre/obdclass/cl_object.c
lustre/obdclass/lprocfs_status.c
lustre/obdclass/scrub.c
lustre/osc/osc_cache.c
lustre/target/out_lib.c
lustre/utils/debug.c
lustre/utils/gss/lgss_utils.c
lustre/utils/gss/lsupport.c
lustre/utils/liblustreapi_layout.c

index 15353a3..103905f 100644 (file)
@@ -129,7 +129,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);
index ac8a3d6..e67db9f 100644 (file)
@@ -1533,7 +1533,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", "MIGRT",
index 7217c60..a8bf4df 100644 (file)
@@ -948,7 +948,7 @@ void lfsck_component_cleanup(const struct lu_env *env,
                             struct lfsck_component *com);
 void lfsck_instance_cleanup(const struct lu_env *env,
                            struct lfsck_instance *lfsck);
-void lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
+void lfsck_bits_dump(struct seq_file *m, int bits, const char *const names[],
                     const char *prefix);
 void lfsck_time_dump(struct seq_file *m, time64_t time, const char *name);
 void lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos,
@@ -1103,8 +1103,8 @@ int lfsck_layout_setup(const struct lu_env *env, struct lfsck_instance *lfsck);
 
 extern const char dot[];
 extern const char dotdot[];
-extern const char *lfsck_flags_names[];
-extern const char *lfsck_param_names[];
+extern const char *const lfsck_flags_names[];
+extern const char *const lfsck_param_names[];
 extern struct lu_context_key lfsck_thread_key;
 
 static inline struct dt_device *lfsck_obj2dev(struct dt_object *obj)
index 8efdfce..01ea411 100644 (file)
@@ -68,7 +68,7 @@ static LIST_HEAD(lfsck_ost_orphan_list);
 static LIST_HEAD(lfsck_mdt_orphan_list);
 static DEFINE_SPINLOCK(lfsck_instance_lock);
 
-const char *lfsck_flags_names[] = {
+const char *const lfsck_flags_names[] = {
        "scanned-once",
        "inconsistent",
        "upgrade",
@@ -77,7 +77,7 @@ const char *lfsck_flags_names[] = {
        NULL
 };
 
-const char *lfsck_param_names[] = {
+const char *const lfsck_param_names[] = {
        NULL,
        "failout",
        "dryrun",
@@ -1778,7 +1778,7 @@ static inline int lfsck_instance_add(struct lfsck_instance *lfsck)
        return 0;
 }
 
-void lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
+void lfsck_bits_dump(struct seq_file *m, int bits, const char *const names[],
                     const char *prefix)
 {
        int flag;
index bd13eed..110ca6a 100644 (file)
@@ -989,7 +989,7 @@ LUSTRE_RW_ATTR(default_easize);
 
 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;
@@ -1647,7 +1647,7 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, long count)
 }
 EXPORT_SYMBOL(ll_stats_ops_tally);
 
-static const char *ra_stat_string[] = {
+static const char *const ra_stat_string[] = {
        [RA_STAT_HIT] = "hits",
        [RA_STAT_MISS] = "misses",
        [RA_STAT_DISTANT_READPAGE] = "readpage not consecutive",
index 0d00403..94149c5 100644 (file)
@@ -693,7 +693,7 @@ out:
 
 static int lprocfs_ir_set_state(struct fs_db *fsdb, const char *buf)
 {
-       const char *strings[] = IR_STRINGS;
+       const char *const strings[] = IR_STRINGS;
        int state = -1;
        int i;
 
@@ -805,7 +805,7 @@ int lprocfs_rd_ir_state(struct seq_file *seq, void *data)
 {
        struct fs_db *fsdb = data;
        struct mgs_nidtbl *tbl = &fsdb->fsdb_nidtbl;
-       const char *ir_strings[] = IR_STRINGS;
+       const char *const ir_strings[] = IR_STRINGS;
        struct timespec64 ts_max;
        struct timespec64 ts;
 
index 8ff2281..ca989fa 100644 (file)
@@ -521,7 +521,7 @@ static struct cache_stats cl_env_stats = {
  */
 int cl_site_stats_print(const struct cl_site *site, struct seq_file *m)
 {
-       static const char *pstate[] = {
+       static const char *const pstate[] = {
                [CPS_CACHED]    = "c",
                [CPS_OWNED]     = "o",
                [CPS_PAGEOUT]   = "w",
index f9caa1b..8948f19 100644 (file)
@@ -550,7 +550,7 @@ static void obd_import_flags2str(struct obd_import *imp, struct seq_file *m)
        flag2str(imp, connect_tried);
 }
 
-static const char *obd_connect_names[] = {
+static const char *const obd_connect_names[] = {
        /* flags names  */
        "read_only",
        "lov_index",
index adcffa9..3cd0b53 100644 (file)
@@ -329,7 +329,7 @@ void scrub_stop(struct lustre_scrub *scrub)
 }
 EXPORT_SYMBOL(scrub_stop);
 
-const char *scrub_status_names[] = {
+const char *const scrub_status_names[] = {
        "init",
        "scanning",
        "completed",
@@ -340,7 +340,7 @@ const char *scrub_status_names[] = {
        NULL
 };
 
-const char *scrub_flags_names[] = {
+const char *const scrub_flags_names[] = {
        "recreated",
        "inconsistent",
        "auto",
@@ -348,13 +348,14 @@ const char *scrub_flags_names[] = {
        NULL
 };
 
-const char *scrub_param_names[] = {
+const char *const scrub_param_names[] = {
        "failout",
        "dryrun",
        NULL
 };
 
-static void scrub_bits_dump(struct seq_file *m, int bits, const char *names[],
+static void scrub_bits_dump(struct seq_file *m, int bits,
+                           const char *const names[],
                            const char *prefix)
 {
        int flag;
index 2d864f7..f1be465 100644 (file)
@@ -97,7 +97,7 @@ static inline char *ext_flags(struct osc_extent *ext, char *flags)
 
 #define EXTSTR       "[%lu -> %lu/%lu]"
 #define EXTPARA(ext) (ext)->oe_start, (ext)->oe_end, (ext)->oe_max_end
-static const char *oes_strings[] = {
+static const char *const oes_strings[] = {
        "inv", "active", "cache", "locking", "lockdone", "rpc", "trunc", NULL };
 
 #define OSC_EXTENT_DUMP_WITH_LOC(file, func, line, mask, extent, fmt, ...) do {\
index cf0cb2f..56d16fa 100644 (file)
@@ -43,7 +43,7 @@
 
 const char *update_op_str(__u16 opc)
 {
-       static const char *opc_str[] = {
+       static const char *const opc_str[] = {
                [OUT_START] = "start",
                [OUT_CREATE] = "create",
                [OUT_DESTROY] = "destroy",
index 5681870..2f70540 100644 (file)
@@ -69,8 +69,8 @@ static int debug_mask = ~0;
 
 #define MAX_MARK_SIZE 256
 
-static const char *libcfs_debug_subsystems[] = LIBCFS_DEBUG_SUBSYS_NAMES;
-static const char *libcfs_debug_masks[] = LIBCFS_DEBUG_MASKS_NAMES;
+static const char *const libcfs_debug_subsystems[] = LIBCFS_DEBUG_SUBSYS_NAMES;
+static const char *const libcfs_debug_masks[] = LIBCFS_DEBUG_MASKS_NAMES;
 
 #define DAEMON_CTL_NAME                "daemon_file"
 #define SUBSYS_DEBUG_CTL_NAME  "subsystem_debug"
index 825c421..1a077fe 100644 (file)
@@ -251,7 +251,7 @@ gss_OID_desc skoid = {
 
 loglevel_t g_log_level = LL_WARN;
 
-static const char *log_prefix[] = {
+static const char *const log_prefix[] = {
        [LL_ERR]        = "ERROR",
        [LL_WARN]       = "WARNING",
        [LL_INFO]       = "INFO",
index 15eaa7c..5c1458f 100644 (file)
@@ -69,9 +69,9 @@
 
 const char * lustre_svc_name[] =
 {
-        [LUSTRE_GSS_SVC_MGS]    = "MGS",
-        [LUSTRE_GSS_SVC_MDS]    = "MDS",
-        [LUSTRE_GSS_SVC_OSS]    = "OSS",
+       [LUSTRE_GSS_SVC_MGS]    = "MGS",
+       [LUSTRE_GSS_SVC_MDS]    = "MDS",
+       [LUSTRE_GSS_SVC_OSS]    = "OSS",
 };
 
 /****************************************
index 3f85197..123a491 100644 (file)
@@ -3068,7 +3068,7 @@ enum llapi_layout_comp_sanity_error {
        LSE_LAST,
 };
 
-const char *llapi_layout_strerror[] =
+const char *const llapi_layout_strerror[] =
 {
        [LSE_OK] = "",
        [LSE_INCOMPLETE_MIRROR] =