dm: constify argument arrays

The arrays of 'struct dm_arg' are never modified by the device-mapper
core, so constify them so that they are placed in .rodata.

(Exception: the args array in dm-raid cannot be constified because it is
allocated on the stack and modified.)

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

Eric Biggers and committed by
Mike Snitzer
5916a22b 3f2e5393

+20 -19
+2 -2
drivers/md/dm-cache-target.c
··· 2306 2306 static int parse_features(struct cache_args *ca, struct dm_arg_set *as, 2307 2307 char **error) 2308 2308 { 2309 - static struct dm_arg _args[] = { 2309 + static const struct dm_arg _args[] = { 2310 2310 {0, 2, "Invalid number of cache feature arguments"}, 2311 2311 }; 2312 2312 ··· 2348 2348 static int parse_policy(struct cache_args *ca, struct dm_arg_set *as, 2349 2349 char **error) 2350 2350 { 2351 - static struct dm_arg _args[] = { 2351 + static const struct dm_arg _args[] = { 2352 2352 {0, 1024, "Invalid number of policy arguments"}, 2353 2353 }; 2354 2354
+1 -1
drivers/md/dm-crypt.c
··· 2533 2533 { 2534 2534 struct crypt_config *cc = ti->private; 2535 2535 struct dm_arg_set as; 2536 - static struct dm_arg _args[] = { 2536 + static const struct dm_arg _args[] = { 2537 2537 {0, 6, "Invalid number of feature args"}, 2538 2538 }; 2539 2539 unsigned int opt_params, val;
+2 -2
drivers/md/dm-flakey.c
··· 51 51 unsigned argc; 52 52 const char *arg_name; 53 53 54 - static struct dm_arg _args[] = { 54 + static const struct dm_arg _args[] = { 55 55 {0, 6, "Invalid number of feature args"}, 56 56 {1, UINT_MAX, "Invalid corrupt bio byte"}, 57 57 {0, 255, "Invalid corrupt value to write into bio byte (0-255)"}, ··· 178 178 */ 179 179 static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv) 180 180 { 181 - static struct dm_arg _args[] = { 181 + static const struct dm_arg _args[] = { 182 182 {0, UINT_MAX, "Invalid up interval"}, 183 183 {0, UINT_MAX, "Invalid down interval"}, 184 184 };
+1 -1
drivers/md/dm-integrity.c
··· 2780 2780 int r; 2781 2781 unsigned extra_args; 2782 2782 struct dm_arg_set as; 2783 - static struct dm_arg _args[] = { 2783 + static const struct dm_arg _args[] = { 2784 2784 {0, 9, "Invalid number of feature args"}, 2785 2785 }; 2786 2786 unsigned journal_sectors, interleave_sectors, buffer_sectors, journal_watermark, sync_msec;
+5 -5
drivers/md/dm-mpath.c
··· 702 702 struct path_selector_type *pst; 703 703 unsigned ps_argc; 704 704 705 - static struct dm_arg _args[] = { 705 + static const struct dm_arg _args[] = { 706 706 {0, 1024, "invalid number of path selector args"}, 707 707 }; 708 708 ··· 826 826 static struct priority_group *parse_priority_group(struct dm_arg_set *as, 827 827 struct multipath *m) 828 828 { 829 - static struct dm_arg _args[] = { 829 + static const struct dm_arg _args[] = { 830 830 {1, 1024, "invalid number of paths"}, 831 831 {0, 1024, "invalid number of selector args"} 832 832 }; ··· 902 902 int ret; 903 903 struct dm_target *ti = m->ti; 904 904 905 - static struct dm_arg _args[] = { 905 + static const struct dm_arg _args[] = { 906 906 {0, 1024, "invalid number of hardware handler args"}, 907 907 }; 908 908 ··· 954 954 struct dm_target *ti = m->ti; 955 955 const char *arg_name; 956 956 957 - static struct dm_arg _args[] = { 957 + static const struct dm_arg _args[] = { 958 958 {0, 8, "invalid number of feature args"}, 959 959 {1, 50, "pg_init_retries must be between 1 and 50"}, 960 960 {0, 60000, "pg_init_delay_msecs must be between 0 and 60000"}, ··· 1023 1023 static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv) 1024 1024 { 1025 1025 /* target arguments */ 1026 - static struct dm_arg _args[] = { 1026 + static const struct dm_arg _args[] = { 1027 1027 {0, 1024, "invalid number of priority groups"}, 1028 1028 {0, 1024, "invalid initial priority group number"}, 1029 1029 };
+1 -1
drivers/md/dm-switch.c
··· 251 251 */ 252 252 static int switch_ctr(struct dm_target *ti, unsigned argc, char **argv) 253 253 { 254 - static struct dm_arg _args[] = { 254 + static const struct dm_arg _args[] = { 255 255 {1, (KMALLOC_MAX_SIZE - sizeof(struct switch_ctx)) / sizeof(struct switch_path), "Invalid number of paths"}, 256 256 {1, UINT_MAX, "Invalid region size"}, 257 257 {0, 0, "Invalid number of optional args"},
+4 -3
drivers/md/dm-table.c
··· 806 806 /* 807 807 * Target argument parsing helpers. 808 808 */ 809 - static int validate_next_arg(struct dm_arg *arg, struct dm_arg_set *arg_set, 809 + static int validate_next_arg(const struct dm_arg *arg, 810 + struct dm_arg_set *arg_set, 810 811 unsigned *value, char **error, unsigned grouped) 811 812 { 812 813 const char *arg_str = dm_shift_arg(arg_set); ··· 825 824 return 0; 826 825 } 827 826 828 - int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set, 827 + int dm_read_arg(const struct dm_arg *arg, struct dm_arg_set *arg_set, 829 828 unsigned *value, char **error) 830 829 { 831 830 return validate_next_arg(arg, arg_set, value, error, 0); 832 831 } 833 832 EXPORT_SYMBOL(dm_read_arg); 834 833 835 - int dm_read_arg_group(struct dm_arg *arg, struct dm_arg_set *arg_set, 834 + int dm_read_arg_group(const struct dm_arg *arg, struct dm_arg_set *arg_set, 836 835 unsigned *value, char **error) 837 836 { 838 837 return validate_next_arg(arg, arg_set, value, error, 1);
+1 -1
drivers/md/dm-thin.c
··· 3041 3041 unsigned argc; 3042 3042 const char *arg_name; 3043 3043 3044 - static struct dm_arg _args[] = { 3044 + static const struct dm_arg _args[] = { 3045 3045 {0, 4, "Invalid number of pool feature arguments"}, 3046 3046 }; 3047 3047
+1 -1
drivers/md/dm-verity-target.c
··· 839 839 struct dm_target *ti = v->ti; 840 840 const char *arg_name; 841 841 842 - static struct dm_arg _args[] = { 842 + static const struct dm_arg _args[] = { 843 843 {0, DM_VERITY_OPTS_MAX, "Invalid number of feature args"}, 844 844 }; 845 845
+2 -2
include/linux/device-mapper.h
··· 387 387 * Validate the next argument, either returning it as *value or, if invalid, 388 388 * returning -EINVAL and setting *error. 389 389 */ 390 - int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set, 390 + int dm_read_arg(const struct dm_arg *arg, struct dm_arg_set *arg_set, 391 391 unsigned *value, char **error); 392 392 393 393 /* ··· 395 395 * arg->min and arg->max further arguments. Either return the size as 396 396 * *num_args or, if invalid, return -EINVAL and set *error. 397 397 */ 398 - int dm_read_arg_group(struct dm_arg *arg, struct dm_arg_set *arg_set, 398 + int dm_read_arg_group(const struct dm_arg *arg, struct dm_arg_set *arg_set, 399 399 unsigned *num_args, char **error); 400 400 401 401 /*