]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc: constify some fields
authorThomas Weißschuh <thomas@t-8ch.de>
Mon, 29 May 2023 07:23:53 +0000 (09:23 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 3 Jun 2023 08:13:59 +0000 (10:13 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
13 files changed:
disk-utils/partx.c
libblkid/src/topology/sysfs.c
libfdisk/src/bsd.c
login-utils/lslogins.c
misc-utils/fincore.c
misc-utils/findmnt.c
misc-utils/lsblk.c
misc-utils/lslocks.c
sys-utils/losetup.c
sys-utils/lsipc.c
sys-utils/prlimit.c
sys-utils/swapon.c
sys-utils/wdctl.c

index 76872907fe74012dbc058069ce12202db906a355..ac3ef14706e0c1620dcaad88e57b1d925f5e9684 100644 (file)
@@ -75,14 +75,14 @@ enum {
 
 /* column names */
 struct colinfo {
-       const char      *name;  /* header */
-       double          whint;  /* width hint (N < 1 is in percent of termwidth) */
-       int             flags;  /* SCOLS_FL_* */
-       const char      *help;
+       const char * const      name;   /* header */
+       double                  whint;  /* width hint (N < 1 is in percent of termwidth) */
+       int                     flags;  /* SCOLS_FL_* */
+       const char              *help;
 };
 
 /* columns descriptions */
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
        [COL_PARTNO]   = { "NR",    0.25, SCOLS_FL_RIGHT, N_("partition number") },
        [COL_START]    = { "START",   0.30, SCOLS_FL_RIGHT, N_("start of the partition in sectors") },
        [COL_END]      = { "END",     0.30, SCOLS_FL_RIGHT, N_("end of the partition in sectors") },
@@ -141,7 +141,7 @@ static inline int get_column_id(int num)
        return columns[num];
 }
 
-static inline struct colinfo *get_column_info(int num)
+static inline const struct colinfo *get_column_info(int num)
 {
        return &infos[ get_column_id(num) ];
 }
@@ -674,7 +674,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
        scols_table_enable_noheadings(table, !!(scols_flags & PARTX_NOHEADINGS));
 
        for (i = 0; (size_t)i < ncolumns; i++) {
-               struct colinfo *col = get_column_info(i);
+               const struct colinfo *col = get_column_info(i);
 
                if (!scols_table_new_column(table, col->name, col->whint, col->flags)) {
                        warnx(_("failed to allocate output column"));
index 25debd073dcd18a8ac9dd143fef0f761b7b4bbb2..d216cfccbfab228d72a2711b67f42b8499b62aec 100644 (file)
@@ -26,7 +26,7 @@
 static const struct topology_val {
 
        /* /sys/dev/block/<maj>:<min>/<ATTR> */
-       const char *attr;
+       const char * const attr;
 
        /* functions to set probing result */
        int (*set_ulong)(blkid_probe, unsigned long);
index 313ae5ae0fe4732fac13330fb591732f53d9b8c9..c138d54b98ec05531771c4624430fabe630ef4f9 100644 (file)
@@ -30,7 +30,7 @@
  *
  */
 
-static const char *bsd_dktypenames[] = {
+static const char * const bsd_dktypenames[] = {
        "unknown",
        "SMD",
        "MSCP",
index 76d28125c90a03d96a05659ec51f7080a6797bc3..ea5afb5ba6b1605fae15c51ddc510cbc8d9a0eed 100644 (file)
@@ -64,7 +64,7 @@
  * column description
  */
 struct lslogins_coldesc {
-       const char *name;
+       const char * const name;
        const char *help;
        const char *pretty_name;
 
index ead6f7aaf529af1fa6ae871a4cca332c31ba451e..e5e25e5c772fa4298185eec08c2d7c6ee06de682 100644 (file)
@@ -44,7 +44,7 @@
 
 
 struct colinfo {
-       const char *name;
+       const char * const name;
        double whint;
        int flags;
        const char *help;
@@ -57,7 +57,7 @@ enum {
        COL_RES
 };
 
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
        [COL_PAGES]  = { "PAGES",    1, SCOLS_FL_RIGHT, N_("file data resident in memory in pages")},
        [COL_RES]    = { "RES",      5, SCOLS_FL_RIGHT, N_("file data resident in memory in bytes")},
        [COL_SIZE]   = { "SIZE",     5, SCOLS_FL_RIGHT, N_("size of the file")},
index 733bbc13d23ace02d3457256186bc5ec51370140..5a8da5dd653fd649b581b7663adb4a2d50e13dfe 100644 (file)
@@ -90,7 +90,7 @@ enum {
 
 /* column names */
 struct colinfo {
-       const char      *name;          /* header */
+       const char      * const name;   /* header */
        double          whint;          /* width hint (N < 1 is in percent of termwidth) */
        int             flags;          /* libsmartcols flags */
        const char      *help;          /* column description */
index fae918bd3f4fc5e37559f36590875db115dff7d8..96d118189a7dc5f2647d2f80ba2e91c9736acf3e 100644 (file)
@@ -158,7 +158,7 @@ enum {
 
 /* column names */
 struct colinfo {
-       const char      *name;          /* header */
+       const char      * const name;   /* header */
        double          whint;          /* width hint (N < 1 is in percent of termwidth) */
        int             flags;          /* SCOLS_FL_* */
        const char      *help;
@@ -166,7 +166,7 @@ struct colinfo {
 };
 
 /* columns descriptions */
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
        [COL_ALIOFF] = { "ALIGNMENT", 6, SCOLS_FL_RIGHT, N_("alignment offset"), COLTYPE_NUM },
        [COL_ID] = { "ID", 0.1, SCOLS_FL_NOEXTREMES, N_("udev ID (based on ID-LINK)") },
        [COL_IDLINK] = { "ID-LINK", 0.1, SCOLS_FL_NOEXTREMES, N_("the shortest udev /dev/disk/by-id link name") },
@@ -324,7 +324,7 @@ static int get_column_id(int num)
 }
 
 /* Returns column description for the column sequential number */
-static struct colinfo *get_column_info(int num)
+static const struct colinfo *get_column_info(int num)
 {
        return &infos[ get_column_id(num) ];
 }
@@ -2364,7 +2364,7 @@ int main(int argc, char *argv[])
        }
 
        for (i = 0; i < ncolumns; i++) {
-               struct colinfo *ci = get_column_info(i);
+               const struct colinfo *ci = get_column_info(i);
                struct libscols_column *cl;
                int id = get_column_id(i), fl = ci->flags;
 
index caca13f9a9c3c5e40fd8d7b5077ef98fe73867c9..ba837d51ad44cc5a0d7deeb69f5bc8a3aa9e9614 100644 (file)
@@ -64,10 +64,10 @@ enum {
 
 /* column names */
 struct colinfo {
-       const char *name; /* header */
-       double     whint; /* width hint (N < 1 is in percent of termwidth) */
-       int        flags; /* SCOLS_FL_* */
-       const char *help;
+       const char * const      name; /* header */
+       double                  whint; /* width hint (N < 1 is in percent of termwidth) */
+       int                     flags; /* SCOLS_FL_* */
+       const char              *help;
 };
 
 /* columns descriptions */
@@ -362,7 +362,7 @@ static inline int get_column_id(int num)
 }
 
 
-static inline struct colinfo *get_column_info(unsigned num)
+static inline const struct colinfo *get_column_info(unsigned num)
 {
        return &infos[ get_column_id(num) ];
 }
@@ -480,7 +480,7 @@ static int show_locks(struct list_head *locks)
 
        for (i = 0; i < ncolumns; i++) {
                struct libscols_column *cl;
-               struct colinfo *col = get_column_info(i);
+               const struct colinfo *col = get_column_info(i);
 
                cl = scols_table_new_column(table, col->name, col->whint, col->flags);
                if (!cl)
index 82ecee75fab544cf29967385365598df514f0a2a..7b19436b487bed6e0db5defa483b49edc9c614c4 100644 (file)
@@ -60,7 +60,7 @@ static int raw;
 static int json;
 
 struct colinfo {
-       const char *name;
+       const char * const name;
        double whint;
        int flags;
        const char *help;
@@ -68,7 +68,7 @@ struct colinfo {
        int json_type;  /* default is string */
 };
 
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
        [COL_AUTOCLR]     = { "AUTOCLEAR",    1, SCOLS_FL_RIGHT, N_("autoclear flag set"), SCOLS_JSON_BOOLEAN},
        [COL_BACK_FILE]   = { "BACK-FILE",  0.3, SCOLS_FL_NOEXTREMES, N_("device backing file")},
        [COL_BACK_INO]    = { "BACK-INO",     4, SCOLS_FL_RIGHT, N_("backing file inode number"), SCOLS_JSON_NUMBER},
@@ -94,7 +94,7 @@ static int get_column_id(int num)
        return columns[num];
 }
 
-static struct colinfo *get_column_info(int num)
+static const struct colinfo *get_column_info(int num)
 {
        return &infos[ get_column_id(num) ];
 }
@@ -331,7 +331,7 @@ static int show_table(struct loopdev_cxt *lc,
                scols_table_set_name(tb, "loopdevices");
 
        for (i = 0; i < ncolumns; i++) {
-               struct colinfo *ci = get_column_info(i);
+               const struct colinfo *ci = get_column_info(i);
                struct libscols_column *cl;
 
                cl = scols_table_new_column(tb, ci->name, ci->whint, ci->flags);
index 0f3cd94bbc6578e7e0fc722246c0e01b9719387e..9ad7b19002be416ce3004c81c8b2d3bd402d69f8 100644 (file)
@@ -136,7 +136,7 @@ struct lsipc_control {
 };
 
 struct lsipc_coldesc {
-       const char *name;
+       const char * const name;
        const char *help;
        const char *pretty_name;
 
index ca69ccf98e3633747dfde69a38b3789903921a94..e067c8cd76591fc454581f2583fa40aa9987c898 100644 (file)
@@ -114,14 +114,14 @@ enum {
 
 /* column names */
 struct colinfo {
-       const char      *name;  /* header */
-       double          whint;  /* width hint (N < 1 is in percent of termwidth) */
-       int             flags;  /* SCOLS_FL_* */
-       const char      *help;
+       const char * const      name; /* header */
+       double                  whint;  /* width hint (N < 1 is in percent of termwidth) */
+       int                     flags;  /* SCOLS_FL_* */
+       const char              *help;
 };
 
 /* columns descriptions */
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
        [COL_RES]     = { "RESOURCE",    0.25, SCOLS_FL_TRUNC, N_("resource name") },
        [COL_HELP]    = { "DESCRIPTION", 0.1,  SCOLS_FL_TRUNC, N_("resource description")},
        [COL_SOFT]    = { "SOFT",        0.1,  SCOLS_FL_RIGHT, N_("soft limit")},
@@ -222,7 +222,7 @@ static inline int get_column_id(int num)
        return columns[num];
 }
 
-static inline struct colinfo *get_column_info(unsigned num)
+static inline const struct colinfo *get_column_info(unsigned num)
 {
        return &infos[ get_column_id(num) ];
 }
@@ -314,7 +314,7 @@ static int show_limits(struct list_head *lims)
        scols_table_enable_noheadings(table, no_headings);
 
        for (i = 0; i < ncolumns; i++) {
-               struct colinfo *col = get_column_info(i);
+               const struct colinfo *col = get_column_info(i);
 
                if (!scols_table_new_column(table, col->name, col->whint, col->flags))
                        err(EXIT_FAILURE, _("failed to allocate output column"));
index 87355491d5cd2408f1d6f7f24612e851706ebf25..81c383a299c970661d67610a5f707e83a7532d70 100644 (file)
@@ -77,10 +77,10 @@ enum {
 
 /* column names */
 struct colinfo {
-        const char *name; /* header */
-        double     whint; /* width hint (N < 1 is in percent of termwidth) */
-       int        flags; /* SCOLS_FL_* */
-        const char *help;
+        const char * const     name; /* header */
+        double                 whint; /* width hint (N < 1 is in percent of termwidth) */
+       int                     flags; /* SCOLS_FL_* */
+        const char             *help;
 };
 
 enum {
@@ -92,7 +92,7 @@ enum {
        COL_UUID,
        COL_LABEL
 };
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
        [COL_PATH]     = { "NAME",      0.20, 0, N_("device file or partition path") },
        [COL_TYPE]     = { "TYPE",      0.20, SCOLS_FL_TRUNC, N_("type of the device")},
        [COL_SIZE]     = { "SIZE",      0.20, SCOLS_FL_RIGHT, N_("size of the swap area")},
@@ -159,7 +159,7 @@ static inline int get_column_id(const struct swapon_ctl *ctl, int num)
        return ctl->columns[num];
 }
 
-static inline struct colinfo *get_column_info(const struct swapon_ctl *ctl, unsigned num)
+static inline const struct colinfo *get_column_info(const struct swapon_ctl *ctl, unsigned num)
 {
        return &infos[get_column_id(ctl, num)];
 }
@@ -299,7 +299,7 @@ static int show_table(struct swapon_ctl *ctl)
        scols_table_enable_noheadings(table, ctl->no_heading);
 
        for (i = 0; i < ctl->ncolumns; i++) {
-               struct colinfo *col = get_column_info(ctl, i);
+               const struct colinfo *col = get_column_info(ctl, i);
 
                if (!scols_table_new_column(table, col->name, col->whint, col->flags))
                        err(EXIT_FAILURE, _("failed to allocate output column"));
index 2a656b85b77dc56f844117ba773d8d4cd8946092..a5fdeaeb22412f596261028dfd3edf8c24faa73c 100644 (file)
@@ -87,16 +87,16 @@ static const struct wdflag wdflags[] = {
 
 /* column names */
 struct colinfo {
-       const char *name; /* header */
-       double     whint; /* width hint (N < 1 is in percent of termwidth) */
-       int        flags; /* SCOLS_FL_* */
-       const char *help;
+       const char * const      name; /* header */
+       double                  whint; /* width hint (N < 1 is in percent of termwidth) */
+       int                     flags; /* SCOLS_FL_* */
+       const char              *help;
 };
 
 enum { COL_FLAG, COL_DESC, COL_STATUS, COL_BSTATUS, COL_DEVICE };
 
 /* columns descriptions */
-static struct colinfo infos[] = {
+static const struct colinfo infos[] = {
        [COL_FLAG]    = { "FLAG",        14,  0, N_("flag name") },
        [COL_DESC]    = { "DESCRIPTION", 0.1, SCOLS_FL_TRUNC, N_("flag description") },
        [COL_STATUS]  = { "STATUS",      1,   SCOLS_FL_RIGHT, N_("flag status") },
@@ -188,7 +188,7 @@ static int get_column_id(int num)
        return columns[num];
 }
 
-static struct colinfo *get_column_info(unsigned num)
+static const struct colinfo *get_column_info(unsigned num)
 {
        return &infos[ get_column_id(num) ];
 }
@@ -354,7 +354,7 @@ static int show_flags(struct wd_control *ctl, struct wd_device *wd, uint32_t wan
 
        /* define columns */
        for (i = 0; i < (size_t) ncolumns; i++) {
-               struct colinfo *col = get_column_info(i);
+               const struct colinfo *col = get_column_info(i);
 
                if (!scols_table_new_column(table, col->name, col->whint, col->flags)) {
                        warnx(_("failed to allocate output column"));