Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5916a22b authored by Eric Biggers's avatar Eric Biggers Committed by Mike Snitzer
Browse files

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: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 3f2e5393
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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"},
	};

+1 −1
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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"},
	};
+1 −1
Original line number Diff line number Diff line
@@ -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;
+5 −5
Original line number Diff line number Diff line
@@ -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 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
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"},
	};
Loading