misc: constify some fields

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
This commit is contained in:
Thomas Weißschuh 2023-05-29 09:23:53 +02:00
parent 90b12595bb
commit 37b2b3fa46
13 changed files with 49 additions and 49 deletions

View 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"));

View 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);

View file

@ -30,7 +30,7 @@
*
*/
static const char *bsd_dktypenames[] = {
static const char * const bsd_dktypenames[] = {
"unknown",
"SMD",
"MSCP",

View file

@ -64,7 +64,7 @@
* column description
*/
struct lslogins_coldesc {
const char *name;
const char * const name;
const char *help;
const char *pretty_name;

View 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")},

View 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 */

View 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;

View 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)

View 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);

View 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;

View 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"));

View 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"));

View 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"));