[PATCH 1/4] treewide: add some static const notations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Emil Velikov <emil.velikov@xxxxxxxxxxxxx>

Signed-off-by: Emil Velikov <emil.velikov@xxxxxxxxxxxxx>
---
 libkmod/libkmod-module.c    | 4 ++--
 libkmod/libkmod.c           | 4 ++--
 testsuite/test-new-module.c | 8 ++++----
 testsuite/test-util.c       | 4 ++--
 testsuite/testsuite.c       | 2 +-
 tools/depmod.c              | 2 +-
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 12d8ed1..c7232e0 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -551,7 +551,7 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
 						const char *given_alias,
 						struct kmod_list **list)
 {
-	const lookup_func lookup[] = {
+	static const lookup_func lookup[] = {
 		kmod_lookup_alias_from_config,
 		kmod_lookup_alias_from_moddep_file,
 		kmod_lookup_alias_from_symbols_file,
@@ -619,7 +619,7 @@ KMOD_EXPORT int kmod_module_new_from_name_lookup(struct kmod_ctx *ctx,
 						 const char *modname,
 						 struct kmod_module **mod)
 {
-	const lookup_func lookup[] = {
+	static const lookup_func lookup[] = {
 		kmod_lookup_alias_from_moddep_file,
 		kmod_lookup_alias_from_builtin_file,
 		kmod_lookup_alias_from_kernel_builtin_file,
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 7c2b889..2670f9a 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -50,7 +50,7 @@
  * and is passed to all library operations.
  */
 
-static struct _index_files {
+static const struct {
 	const char *fn;
 	const char *prefix;
 } index_files[] = {
@@ -61,7 +61,7 @@ static struct _index_files {
 	[KMOD_INDEX_MODULES_BUILTIN] = { .fn = "modules.builtin", .prefix = ""},
 };
 
-static const char *default_config_paths[] = {
+static const char *const default_config_paths[] = {
 	SYSCONFDIR "/modprobe.d",
 	"/run/modprobe.d",
 	"/usr/local/lib/modprobe.d",
diff --git a/testsuite/test-new-module.c b/testsuite/test-new-module.c
index 360065c..9872b78 100644
--- a/testsuite/test-new-module.c
+++ b/testsuite/test-new-module.c
@@ -29,7 +29,7 @@
 
 static int from_name(const struct test *t)
 {
-	static const char *modnames[] = {
+	static const char *const modnames[] = {
 		"ext4",
 		"balbalbalbbalbalbalbalbalbalbal",
 		"snd-hda-intel",
@@ -37,7 +37,7 @@ static int from_name(const struct test *t)
 		"iTCO_wdt",
 		NULL,
 	};
-	const char **p;
+	const char *const *p;
 	struct kmod_ctx *ctx;
 	struct kmod_module *mod;
 	const char *null_config = NULL;
@@ -72,11 +72,11 @@ DEFINE_TEST(from_name,
 
 static int from_alias(const struct test *t)
 {
-	static const char *modnames[] = {
+	static const char *const modnames[] = {
 		"ext4.*",
 		NULL,
 	};
-	const char **p;
+	const char *const *p;
 	struct kmod_ctx *ctx;
 	int err;
 
diff --git a/testsuite/test-util.c b/testsuite/test-util.c
index 5766584..e3243e8 100644
--- a/testsuite/test-util.c
+++ b/testsuite/test-util.c
@@ -31,7 +31,7 @@
 
 static int alias_1(const struct test *t)
 {
-	static const char *input[] = {
+	static const char *const input[] = {
 		"test1234",
 		"test[abcfoobar]2211",
 		"bar[aaa][bbbb]sss",
@@ -42,7 +42,7 @@ static int alias_1(const struct test *t)
 
 	char buf[PATH_MAX];
 	size_t len;
-	const char **alias;
+	const char *const *alias;
 
 	for (alias = input; *alias != NULL; alias++) {
 		int ret;
diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c
index 6a2d296..318343a 100644
--- a/testsuite/testsuite.c
+++ b/testsuite/testsuite.c
@@ -53,7 +53,7 @@ static const struct option options[] = {
 #define OVERRIDE_LIBDIR ABS_TOP_BUILDDIR "/testsuite/.libs/"
 #define TEST_TIMEOUT_USEC 2 * USEC_PER_SEC
 
-struct _env_config {
+static const struct {
 	const char *key;
 	const char *ldpreload;
 } env_config[_TC_LAST] = {
diff --git a/tools/depmod.c b/tools/depmod.c
index 5536597..a2c39b3 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -50,7 +50,7 @@ static int verbose = DEFAULT_VERBOSE;
 
 static const char CFG_BUILTIN_KEY[] = "built-in";
 static const char CFG_EXTERNAL_KEY[] = "external";
-static const char *default_cfg_paths[] = {
+static const char *const default_cfg_paths[] = {
 	SYSCONFDIR "/depmod.d",
 	"/run/depmod.d",
 	"/usr/local/lib/depmod.d",
-- 
2.39.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux