]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
dm: constify argument arrays
authorEric Biggers <ebiggers@google.com>
Thu, 22 Jun 2017 18:32:45 +0000 (11:32 -0700)
committerMike Snitzer <snitzer@redhat.com>
Mon, 28 Aug 2017 15:47:18 +0000 (11:47 -0400)
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>
drivers/md/dm-cache-target.c
drivers/md/dm-crypt.c
drivers/md/dm-flakey.c
drivers/md/dm-integrity.c
drivers/md/dm-mpath.c
drivers/md/dm-switch.c
drivers/md/dm-table.c
drivers/md/dm-thin.c
drivers/md/dm-verity-target.c
include/linux/device-mapper.h

index c5ea03fc7ee1537914f222753b5018bf34e4a169..b0a5503a2fd318567d9302848646ee40eef64341 100644 (file)
@@ -2306,7 +2306,7 @@ static void init_features(struct cache_features *cf)
 static int parse_features(struct cache_args *ca, struct dm_arg_set *as,
                          char **error)
 {
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 2, "Invalid number of cache feature arguments"},
        };
 
@@ -2348,7 +2348,7 @@ static int parse_features(struct cache_args *ca, struct dm_arg_set *as,
 static int parse_policy(struct cache_args *ca, struct dm_arg_set *as,
                        char **error)
 {
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 1024, "Invalid number of policy arguments"},
        };
 
index cdf6b1e124604b7bd5e2fee7743a9435f1e79032..abf16559ed49543a728f793dfd9d244b272c7374 100644 (file)
@@ -2533,7 +2533,7 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
 {
        struct crypt_config *cc = ti->private;
        struct dm_arg_set as;
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 6, "Invalid number of feature args"},
        };
        unsigned int opt_params, val;
index e2c7234931bc1fda713f8d12db1918f7efcc5b5c..d8bb371e63d7c0dfde61234e7e0e28a97abe3b21 100644 (file)
@@ -51,7 +51,7 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
        unsigned argc;
        const char *arg_name;
 
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 6, "Invalid number of feature args"},
                {1, UINT_MAX, "Invalid corrupt bio byte"},
                {0, 255, "Invalid corrupt value to write into bio byte (0-255)"},
@@ -178,7 +178,7 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
  */
 static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 {
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, UINT_MAX, "Invalid up interval"},
                {0, UINT_MAX, "Invalid down interval"},
        };
index 47fd409b2e2ae40b12d4788c0f6e8e2ede9a31a1..293a19652d5549a4ba494b0748a8fd8ebf463090 100644 (file)
@@ -2780,7 +2780,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
        int r;
        unsigned extra_args;
        struct dm_arg_set as;
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 9, "Invalid number of feature args"},
        };
        unsigned journal_sectors, interleave_sectors, buffer_sectors, journal_watermark, sync_msec;
index 7406ededf875a242f4204846fab78f0f113d5fe1..bf280a99fa81f63b58d9c6f8bf828297df39745c 100644 (file)
@@ -702,7 +702,7 @@ static int parse_path_selector(struct dm_arg_set *as, struct priority_group *pg,
        struct path_selector_type *pst;
        unsigned ps_argc;
 
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 1024, "invalid number of path selector args"},
        };
 
@@ -826,7 +826,7 @@ retain:
 static struct priority_group *parse_priority_group(struct dm_arg_set *as,
                                                   struct multipath *m)
 {
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {1, 1024, "invalid number of paths"},
                {0, 1024, "invalid number of selector args"}
        };
@@ -902,7 +902,7 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)
        int ret;
        struct dm_target *ti = m->ti;
 
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 1024, "invalid number of hardware handler args"},
        };
 
@@ -954,7 +954,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
        struct dm_target *ti = m->ti;
        const char *arg_name;
 
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 8, "invalid number of feature args"},
                {1, 50, "pg_init_retries must be between 1 and 50"},
                {0, 60000, "pg_init_delay_msecs must be between 0 and 60000"},
@@ -1023,7 +1023,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
 static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv)
 {
        /* target arguments */
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 1024, "invalid number of priority groups"},
                {0, 1024, "invalid initial priority group number"},
        };
index 871c18fe000dfae2ef016ad64a5d8c4e0fc04e66..83a371d544124fbf21a3762bbd5201485bdc76c9 100644 (file)
@@ -251,7 +251,7 @@ static void switch_dtr(struct dm_target *ti)
  */
 static int switch_ctr(struct dm_target *ti, unsigned argc, char **argv)
 {
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {1, (KMALLOC_MAX_SIZE - sizeof(struct switch_ctx)) / sizeof(struct switch_path), "Invalid number of paths"},
                {1, UINT_MAX, "Invalid region size"},
                {0, 0, "Invalid number of optional args"},
index 28a4071cdf85e8ae15e8741d8770199a689de6b2..ef7b8f201f73ad9777cf336344fe59b11914cc73 100644 (file)
@@ -806,7 +806,8 @@ int dm_table_add_target(struct dm_table *t, const char *type,
 /*
  * Target argument parsing helpers.
  */
-static int validate_next_arg(struct dm_arg *arg, struct dm_arg_set *arg_set,
+static int validate_next_arg(const struct dm_arg *arg,
+                            struct dm_arg_set *arg_set,
                             unsigned *value, char **error, unsigned grouped)
 {
        const char *arg_str = dm_shift_arg(arg_set);
@@ -824,14 +825,14 @@ static int validate_next_arg(struct dm_arg *arg, struct dm_arg_set *arg_set,
        return 0;
 }
 
-int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set,
+int dm_read_arg(const struct dm_arg *arg, struct dm_arg_set *arg_set,
                unsigned *value, char **error)
 {
        return validate_next_arg(arg, arg_set, value, error, 0);
 }
 EXPORT_SYMBOL(dm_read_arg);
 
-int dm_read_arg_group(struct dm_arg *arg, struct dm_arg_set *arg_set,
+int dm_read_arg_group(const struct dm_arg *arg, struct dm_arg_set *arg_set,
                      unsigned *value, char **error)
 {
        return validate_next_arg(arg, arg_set, value, error, 1);
index 9dec2f8cc739393e9f2e97124bd0e85125eb1406..9736621c2963e281d7c471cb6da6d746587d16ae 100644 (file)
@@ -3041,7 +3041,7 @@ static int parse_pool_features(struct dm_arg_set *as, struct pool_features *pf,
        unsigned argc;
        const char *arg_name;
 
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, 4, "Invalid number of pool feature arguments"},
        };
 
index b46705ebf01f6d55cfeb0cff8327d767d4fc7572..79f18d4d7f021190e523f5a36127a9b95d2adf85 100644 (file)
@@ -839,7 +839,7 @@ static int verity_parse_opt_args(struct dm_arg_set *as, struct dm_verity *v)
        struct dm_target *ti = v->ti;
        const char *arg_name;
 
-       static struct dm_arg _args[] = {
+       static const struct dm_arg _args[] = {
                {0, DM_VERITY_OPTS_MAX, "Invalid number of feature args"},
        };
 
index 4f2b3b2076c42556da4d7d244ba786c2d0c045c3..3b5fdf308148410fd684da30b30cc7c215c3b47c 100644 (file)
@@ -387,7 +387,7 @@ struct dm_arg {
  * Validate the next argument, either returning it as *value or, if invalid,
  * returning -EINVAL and setting *error.
  */
-int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set,
+int dm_read_arg(const struct dm_arg *arg, struct dm_arg_set *arg_set,
                unsigned *value, char **error);
 
 /*
@@ -395,7 +395,7 @@ int dm_read_arg(struct dm_arg *arg, struct dm_arg_set *arg_set,
  * arg->min and arg->max further arguments. Either return the size as
  * *num_args or, if invalid, return -EINVAL and set *error.
  */
-int dm_read_arg_group(struct dm_arg *arg, struct dm_arg_set *arg_set,
+int dm_read_arg_group(const struct dm_arg *arg, struct dm_arg_set *arg_set,
                      unsigned *num_args, char **error);
 
 /*