summaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2024-02-03 00:58:16 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2024-02-19 18:20:41 +0900
commit5b058034e3aa600802ab609e8264dc2ca1300ebe (patch)
treeb40e310dcfe6b0b32ac8819392ab255813259f89 /scripts/kconfig
parent6676c5bc15e66268c9c9669d5852aa779689c74e (diff)
downloadlinux-stable-5b058034e3aa600802ab609e8264dc2ca1300ebe.tar.gz
linux-stable-5b058034e3aa600802ab609e8264dc2ca1300ebe.tar.bz2
linux-stable-5b058034e3aa600802ab609e8264dc2ca1300ebe.zip
kconfig: change file_lookup() to return the file name
Currently, file_lookup() returns a pointer to (struct file), but the callers use only file->name. Make it return the ->name member directly. This adjustment encapsulates struct file and file_list as internal implementation. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/expr.h7
-rw-r--r--scripts/kconfig/lexer.l5
-rw-r--r--scripts/kconfig/lkc.h2
-rw-r--r--scripts/kconfig/menu.c2
-rw-r--r--scripts/kconfig/util.c13
5 files changed, 13 insertions, 16 deletions
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 760b1e681b43..d667f9aa041e 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -17,11 +17,6 @@ extern "C" {
#include <stdbool.h>
#endif
-struct file {
- struct file *next;
- char name[];
-};
-
typedef enum tristate {
no, mod, yes
} tristate;
@@ -275,8 +270,6 @@ struct jump_key {
struct menu *target;
};
-extern struct file *file_list;
-
extern struct symbol symbol_yes, symbol_no, symbol_mod;
extern struct symbol *modules_sym;
extern int cdebug;
diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l
index 71f651bb82ba..89544c3a1a29 100644
--- a/scripts/kconfig/lexer.l
+++ b/scripts/kconfig/lexer.l
@@ -401,13 +401,12 @@ void zconf_initscan(const char *name)
exit(1);
}
- cur_filename = file_lookup(name)->name;
+ cur_filename = file_lookup(name);
yylineno = 1;
}
void zconf_nextfile(const char *name)
{
- struct file *file = file_lookup(name);
struct buffer *buf = xmalloc(sizeof(*buf));
bool recur_include = false;
@@ -443,7 +442,7 @@ void zconf_nextfile(const char *name)
}
yylineno = 1;
- cur_filename = file->name;
+ cur_filename = file_lookup(name);
}
static void zconf_endfile(void)
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index d8249052f2e3..71afcbd56273 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -52,7 +52,7 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
}
/* util.c */
-struct file *file_lookup(const char *name);
+const char *file_lookup(const char *name);
void *xmalloc(size_t size);
void *xcalloc(size_t nmemb, size_t size);
void *xrealloc(void *p, size_t size);
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index b879576d1ab4..f701382f8a69 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -16,8 +16,6 @@ static const char nohelp_text[] = "There is no help available for this option.";
struct menu rootmenu;
static struct menu **last_entry_ptr;
-struct file *file_list;
-
void menu_warn(struct menu *menu, const char *fmt, ...)
{
va_list ap;
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 2636dccea0c9..610d64c01479 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -9,15 +9,22 @@
#include <string.h>
#include "lkc.h"
+struct file {
+ struct file *next;
+ char name[];
+};
+
+static struct file *file_list;
+
/* file already present in list? If not add it */
-struct file *file_lookup(const char *name)
+const char *file_lookup(const char *name)
{
struct file *file;
size_t len;
for (file = file_list; file; file = file->next) {
if (!strcmp(name, file->name)) {
- return file;
+ return file->name;
}
}
@@ -31,7 +38,7 @@ struct file *file_lookup(const char *name)
str_printf(&autoconf_cmd, "\t%s \\\n", name);
- return file;
+ return file->name;
}
/* Allocate initial growable string */