]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
kconfig: change file_lookup() to return the file name
authorMasahiro Yamada <masahiroy@kernel.org>
Fri, 2 Feb 2024 15:58:16 +0000 (00:58 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Mon, 19 Feb 2024 09:20:41 +0000 (18:20 +0900)
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>
scripts/kconfig/expr.h
scripts/kconfig/lexer.l
scripts/kconfig/lkc.h
scripts/kconfig/menu.c
scripts/kconfig/util.c

index 760b1e681b4339ef6a63dd7e136c7cbac74675b3..d667f9aa041e7a0adf6ecd4875d8d7ecb140e0ac 100644 (file)
@@ -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;
index 71f651bb82bae12dcbdd416c9745e8ef23779f99..89544c3a1a2995d0daf817adbc7ad2d588ccf76d 100644 (file)
@@ -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)
index d8249052f2e3d919ceadbe7a969e8afa014c8f06..71afcbd562739ceb41bb7f8ec377e3b801da3455 100644 (file)
@@ -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);
index b879576d1ab4a8920ac57168833e6c3c500a1645..f701382f8a6929196612ac7149d7c7167f23997e 100644 (file)
@@ -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;
index 2636dccea0c9a84670bf6dfcc48b14c4dcf16d80..610d64c01479b85a6059f0633ae5af0cf3844744 100644 (file)
@@ -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 */