Skip to content

Commit 37b2b3f

Browse files
committed
misc: constify some fields
Signed-off-by: Thomas Weißschuh <[email protected]>
1 parent 90b1259 commit 37b2b3f

File tree

13 files changed

+49
-49
lines changed

13 files changed

+49
-49
lines changed

disk-utils/partx.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ enum {
7575

7676
/* column names */
7777
struct colinfo {
78-
const char *name; /* header */
79-
double whint; /* width hint (N < 1 is in percent of termwidth) */
80-
int flags; /* SCOLS_FL_* */
81-
const char *help;
78+
const char * const name; /* header */
79+
double whint; /* width hint (N < 1 is in percent of termwidth) */
80+
int flags; /* SCOLS_FL_* */
81+
const char *help;
8282
};
8383

8484
/* columns descriptions */
85-
static struct colinfo infos[] = {
85+
static const struct colinfo infos[] = {
8686
[COL_PARTNO] = { "NR", 0.25, SCOLS_FL_RIGHT, N_("partition number") },
8787
[COL_START] = { "START", 0.30, SCOLS_FL_RIGHT, N_("start of the partition in sectors") },
8888
[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)
141141
return columns[num];
142142
}
143143

144-
static inline struct colinfo *get_column_info(int num)
144+
static inline const struct colinfo *get_column_info(int num)
145145
{
146146
return &infos[ get_column_id(num) ];
147147
}
@@ -674,7 +674,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
674674
scols_table_enable_noheadings(table, !!(scols_flags & PARTX_NOHEADINGS));
675675

676676
for (i = 0; (size_t)i < ncolumns; i++) {
677-
struct colinfo *col = get_column_info(i);
677+
const struct colinfo *col = get_column_info(i);
678678

679679
if (!scols_table_new_column(table, col->name, col->whint, col->flags)) {
680680
warnx(_("failed to allocate output column"));

libblkid/src/topology/sysfs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
static const struct topology_val {
2727

2828
/* /sys/dev/block/<maj>:<min>/<ATTR> */
29-
const char *attr;
29+
const char * const attr;
3030

3131
/* functions to set probing result */
3232
int (*set_ulong)(blkid_probe, unsigned long);

libfdisk/src/bsd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
*/
3232

33-
static const char *bsd_dktypenames[] = {
33+
static const char * const bsd_dktypenames[] = {
3434
"unknown",
3535
"SMD",
3636
"MSCP",

login-utils/lslogins.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
* column description
6565
*/
6666
struct lslogins_coldesc {
67-
const char *name;
67+
const char * const name;
6868
const char *help;
6969
const char *pretty_name;
7070

misc-utils/fincore.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545

4646
struct colinfo {
47-
const char *name;
47+
const char * const name;
4848
double whint;
4949
int flags;
5050
const char *help;
@@ -57,7 +57,7 @@ enum {
5757
COL_RES
5858
};
5959

60-
static struct colinfo infos[] = {
60+
static const struct colinfo infos[] = {
6161
[COL_PAGES] = { "PAGES", 1, SCOLS_FL_RIGHT, N_("file data resident in memory in pages")},
6262
[COL_RES] = { "RES", 5, SCOLS_FL_RIGHT, N_("file data resident in memory in bytes")},
6363
[COL_SIZE] = { "SIZE", 5, SCOLS_FL_RIGHT, N_("size of the file")},

misc-utils/findmnt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ enum {
9090

9191
/* column names */
9292
struct colinfo {
93-
const char *name; /* header */
93+
const char * const name; /* header */
9494
double whint; /* width hint (N < 1 is in percent of termwidth) */
9595
int flags; /* libsmartcols flags */
9696
const char *help; /* column description */

misc-utils/lsblk.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ enum {
158158

159159
/* column names */
160160
struct colinfo {
161-
const char *name; /* header */
161+
const char * const name; /* header */
162162
double whint; /* width hint (N < 1 is in percent of termwidth) */
163163
int flags; /* SCOLS_FL_* */
164164
const char *help;
165165
int type; /* COLTYPE_* */
166166
};
167167

168168
/* columns descriptions */
169-
static struct colinfo infos[] = {
169+
static const struct colinfo infos[] = {
170170
[COL_ALIOFF] = { "ALIGNMENT", 6, SCOLS_FL_RIGHT, N_("alignment offset"), COLTYPE_NUM },
171171
[COL_ID] = { "ID", 0.1, SCOLS_FL_NOEXTREMES, N_("udev ID (based on ID-LINK)") },
172172
[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)
324324
}
325325

326326
/* Returns column description for the column sequential number */
327-
static struct colinfo *get_column_info(int num)
327+
static const struct colinfo *get_column_info(int num)
328328
{
329329
return &infos[ get_column_id(num) ];
330330
}
@@ -2364,7 +2364,7 @@ int main(int argc, char *argv[])
23642364
}
23652365

23662366
for (i = 0; i < ncolumns; i++) {
2367-
struct colinfo *ci = get_column_info(i);
2367+
const struct colinfo *ci = get_column_info(i);
23682368
struct libscols_column *cl;
23692369
int id = get_column_id(i), fl = ci->flags;
23702370

misc-utils/lslocks.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ enum {
6464

6565
/* column names */
6666
struct colinfo {
67-
const char *name; /* header */
68-
double whint; /* width hint (N < 1 is in percent of termwidth) */
69-
int flags; /* SCOLS_FL_* */
70-
const char *help;
67+
const char * const name; /* header */
68+
double whint; /* width hint (N < 1 is in percent of termwidth) */
69+
int flags; /* SCOLS_FL_* */
70+
const char *help;
7171
};
7272

7373
/* columns descriptions */
@@ -362,7 +362,7 @@ static inline int get_column_id(int num)
362362
}
363363

364364

365-
static inline struct colinfo *get_column_info(unsigned num)
365+
static inline const struct colinfo *get_column_info(unsigned num)
366366
{
367367
return &infos[ get_column_id(num) ];
368368
}
@@ -480,7 +480,7 @@ static int show_locks(struct list_head *locks)
480480

481481
for (i = 0; i < ncolumns; i++) {
482482
struct libscols_column *cl;
483-
struct colinfo *col = get_column_info(i);
483+
const struct colinfo *col = get_column_info(i);
484484

485485
cl = scols_table_new_column(table, col->name, col->whint, col->flags);
486486
if (!cl)

sys-utils/losetup.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ static int raw;
6060
static int json;
6161

6262
struct colinfo {
63-
const char *name;
63+
const char * const name;
6464
double whint;
6565
int flags;
6666
const char *help;
6767

6868
int json_type; /* default is string */
6969
};
7070

71-
static struct colinfo infos[] = {
71+
static const struct colinfo infos[] = {
7272
[COL_AUTOCLR] = { "AUTOCLEAR", 1, SCOLS_FL_RIGHT, N_("autoclear flag set"), SCOLS_JSON_BOOLEAN},
7373
[COL_BACK_FILE] = { "BACK-FILE", 0.3, SCOLS_FL_NOEXTREMES, N_("device backing file")},
7474
[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)
9494
return columns[num];
9595
}
9696

97-
static struct colinfo *get_column_info(int num)
97+
static const struct colinfo *get_column_info(int num)
9898
{
9999
return &infos[ get_column_id(num) ];
100100
}
@@ -331,7 +331,7 @@ static int show_table(struct loopdev_cxt *lc,
331331
scols_table_set_name(tb, "loopdevices");
332332

333333
for (i = 0; i < ncolumns; i++) {
334-
struct colinfo *ci = get_column_info(i);
334+
const struct colinfo *ci = get_column_info(i);
335335
struct libscols_column *cl;
336336

337337
cl = scols_table_new_column(tb, ci->name, ci->whint, ci->flags);

sys-utils/lsipc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct lsipc_control {
136136
};
137137

138138
struct lsipc_coldesc {
139-
const char *name;
139+
const char * const name;
140140
const char *help;
141141
const char *pretty_name;
142142

sys-utils/prlimit.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ enum {
114114

115115
/* column names */
116116
struct colinfo {
117-
const char *name; /* header */
118-
double whint; /* width hint (N < 1 is in percent of termwidth) */
119-
int flags; /* SCOLS_FL_* */
120-
const char *help;
117+
const char * const name; /* header */
118+
double whint; /* width hint (N < 1 is in percent of termwidth) */
119+
int flags; /* SCOLS_FL_* */
120+
const char *help;
121121
};
122122

123123
/* columns descriptions */
124-
static struct colinfo infos[] = {
124+
static const struct colinfo infos[] = {
125125
[COL_RES] = { "RESOURCE", 0.25, SCOLS_FL_TRUNC, N_("resource name") },
126126
[COL_HELP] = { "DESCRIPTION", 0.1, SCOLS_FL_TRUNC, N_("resource description")},
127127
[COL_SOFT] = { "SOFT", 0.1, SCOLS_FL_RIGHT, N_("soft limit")},
@@ -222,7 +222,7 @@ static inline int get_column_id(int num)
222222
return columns[num];
223223
}
224224

225-
static inline struct colinfo *get_column_info(unsigned num)
225+
static inline const struct colinfo *get_column_info(unsigned num)
226226
{
227227
return &infos[ get_column_id(num) ];
228228
}
@@ -314,7 +314,7 @@ static int show_limits(struct list_head *lims)
314314
scols_table_enable_noheadings(table, no_headings);
315315

316316
for (i = 0; i < ncolumns; i++) {
317-
struct colinfo *col = get_column_info(i);
317+
const struct colinfo *col = get_column_info(i);
318318

319319
if (!scols_table_new_column(table, col->name, col->whint, col->flags))
320320
err(EXIT_FAILURE, _("failed to allocate output column"));

sys-utils/swapon.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ enum {
7777

7878
/* column names */
7979
struct colinfo {
80-
const char *name; /* header */
81-
double whint; /* width hint (N < 1 is in percent of termwidth) */
82-
int flags; /* SCOLS_FL_* */
83-
const char *help;
80+
const char * const name; /* header */
81+
double whint; /* width hint (N < 1 is in percent of termwidth) */
82+
int flags; /* SCOLS_FL_* */
83+
const char *help;
8484
};
8585

8686
enum {
@@ -92,7 +92,7 @@ enum {
9292
COL_UUID,
9393
COL_LABEL
9494
};
95-
static struct colinfo infos[] = {
95+
static const struct colinfo infos[] = {
9696
[COL_PATH] = { "NAME", 0.20, 0, N_("device file or partition path") },
9797
[COL_TYPE] = { "TYPE", 0.20, SCOLS_FL_TRUNC, N_("type of the device")},
9898
[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)
159159
return ctl->columns[num];
160160
}
161161

162-
static inline struct colinfo *get_column_info(const struct swapon_ctl *ctl, unsigned num)
162+
static inline const struct colinfo *get_column_info(const struct swapon_ctl *ctl, unsigned num)
163163
{
164164
return &infos[get_column_id(ctl, num)];
165165
}
@@ -299,7 +299,7 @@ static int show_table(struct swapon_ctl *ctl)
299299
scols_table_enable_noheadings(table, ctl->no_heading);
300300

301301
for (i = 0; i < ctl->ncolumns; i++) {
302-
struct colinfo *col = get_column_info(ctl, i);
302+
const struct colinfo *col = get_column_info(ctl, i);
303303

304304
if (!scols_table_new_column(table, col->name, col->whint, col->flags))
305305
err(EXIT_FAILURE, _("failed to allocate output column"));

sys-utils/wdctl.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,16 @@ static const struct wdflag wdflags[] = {
8787

8888
/* column names */
8989
struct colinfo {
90-
const char *name; /* header */
91-
double whint; /* width hint (N < 1 is in percent of termwidth) */
92-
int flags; /* SCOLS_FL_* */
93-
const char *help;
90+
const char * const name; /* header */
91+
double whint; /* width hint (N < 1 is in percent of termwidth) */
92+
int flags; /* SCOLS_FL_* */
93+
const char *help;
9494
};
9595

9696
enum { COL_FLAG, COL_DESC, COL_STATUS, COL_BSTATUS, COL_DEVICE };
9797

9898
/* columns descriptions */
99-
static struct colinfo infos[] = {
99+
static const struct colinfo infos[] = {
100100
[COL_FLAG] = { "FLAG", 14, 0, N_("flag name") },
101101
[COL_DESC] = { "DESCRIPTION", 0.1, SCOLS_FL_TRUNC, N_("flag description") },
102102
[COL_STATUS] = { "STATUS", 1, SCOLS_FL_RIGHT, N_("flag status") },
@@ -188,7 +188,7 @@ static int get_column_id(int num)
188188
return columns[num];
189189
}
190190

191-
static struct colinfo *get_column_info(unsigned num)
191+
static const struct colinfo *get_column_info(unsigned num)
192192
{
193193
return &infos[ get_column_id(num) ];
194194
}
@@ -354,7 +354,7 @@ static int show_flags(struct wd_control *ctl, struct wd_device *wd, uint32_t wan
354354

355355
/* define columns */
356356
for (i = 0; i < (size_t) ncolumns; i++) {
357-
struct colinfo *col = get_column_info(i);
357+
const struct colinfo *col = get_column_info(i);
358358

359359
if (!scols_table_new_column(table, col->name, col->whint, col->flags)) {
360360
warnx(_("failed to allocate output column"));

0 commit comments

Comments
 (0)