Constify a bunch of data structures that need not be writable. Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx> --- depmod.c | 10 +++++----- elfops.h | 4 ++-- elfops_core.c | 2 +- modindex.c | 2 +- modinfo.c | 2 +- modprobe.c | 2 +- rmmod.c | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/depmod.c b/depmod.c index 34aa67e..52fc241 100644 --- a/depmod.c +++ b/depmod.c @@ -222,7 +222,7 @@ static void load_module_symvers(const char *filename) add_fake_syms(); } -static struct option options[] = { { "all", 0, NULL, 'a' }, +static const struct option options[] = { { "all", 0, NULL, 'a' }, { "quick", 0, NULL, 'A' }, { "basedir", 1, NULL, 'b' }, { "config", 1, NULL, 'C' }, @@ -1030,12 +1030,12 @@ static int output_devname(struct module *modules, FILE *out, char *dirname) } struct depfile { - char *name; + const char *name; int (*func)(struct module *, FILE *, char *dirname); int map_file; }; -static struct depfile depfiles[] = { +static const struct depfile depfiles[] = { { "modules.dep", output_deps, 0 }, /* This is what we check for '-A'. */ { "modules.dep.bin", output_deps_bin, 0 }, { "modules.pcimap", output_pci_table, 1 }, @@ -1499,10 +1499,10 @@ int main(int argc, char *argv[]) list = sort_modules(dirname,list); list = parse_modules(list); - for (i = 0; i < sizeof(depfiles)/sizeof(depfiles[0]); i++) { + for (i = 0; i < ARRAY_SIZE(depfiles); i++) { FILE *out; int res; - struct depfile *d = &depfiles[i]; + const struct depfile *d = &depfiles[i]; char depname[strlen(dirname) + 1 + strlen(d->name) + 1]; char tmpname[strlen(dirname) + 1 + strlen(d->name) + strlen(".temp") + 1]; diff --git a/elfops.h b/elfops.h index 266c8cd..52c1fd7 100644 --- a/elfops.h +++ b/elfops.h @@ -23,7 +23,7 @@ struct elf_file char *pathname; /* File operations */ - struct module_ops *ops; + const struct module_ops *ops; /* Convert endian? */ int conv; @@ -76,7 +76,7 @@ struct module_ops int (*dump_modvers)(struct elf_file *module); }; -extern struct module_ops mod_ops32, mod_ops64; +extern const struct module_ops mod_ops32, mod_ops64; struct elf_file *grab_elf_file(const char *pathname); void release_elf_file(struct elf_file *file); diff --git a/elfops_core.c b/elfops_core.c index 58a7943..7150d39 100644 --- a/elfops_core.c +++ b/elfops_core.c @@ -439,7 +439,7 @@ static int PERBIT(dump_modversions)(struct elf_file *module) return n; } -struct module_ops PERBIT(mod_ops) = { +const struct module_ops PERBIT(mod_ops) = { .load_section = PERBIT(load_section), .load_strings = PERBIT(load_strings), .load_symbols = PERBIT(load_symbols), diff --git a/modindex.c b/modindex.c index da397d0..ef2e99e 100644 --- a/modindex.c +++ b/modindex.c @@ -104,7 +104,7 @@ static void print_usage(const char *progname) exit(1); } -static struct option options[] = { +static const struct option options[] = { { "output", 0, NULL, 'o' }, { "dump", 0, NULL, 'd' }, { "search", 1, NULL, 's' }, diff --git a/modinfo.c b/modinfo.c index 90e9ad3..1dd8469 100644 --- a/modinfo.c +++ b/modinfo.c @@ -122,7 +122,7 @@ static void print_all(struct string_table *tags, } } -static struct option options[] = +static const struct option options[] = { {"author", 0, 0, 'a'}, {"description", 0, 0, 'd'}, diff --git a/modprobe.c b/modprobe.c index 81e950d..4721253 100644 --- a/modprobe.c +++ b/modprobe.c @@ -1670,7 +1670,7 @@ out: return failed; } -static struct option options[] = { { "version", 0, NULL, 'V' }, +static const struct option options[] = { { "version", 0, NULL, 'V' }, { "verbose", 0, NULL, 'v' }, { "quiet", 0, NULL, 'q' }, { "syslog", 0, NULL, 's' }, diff --git a/rmmod.c b/rmmod.c index f317ed9..a384fa6 100644 --- a/rmmod.c +++ b/rmmod.c @@ -130,7 +130,7 @@ static int rmmod(const char *path, int flags) return ret; } -static struct option options[] = { { "all", 0, NULL, 'a' }, +static const struct option options[] = { { "all", 0, NULL, 'a' }, { "force", 0, NULL, 'f' }, { "help", 0, NULL, 'h' }, { "syslog", 0, NULL, 's' }, -- 1.7.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html