summaryrefslogtreecommitdiff
path: root/scripts/kconfig/util.c
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/util.c
parent6676c5bc15e66268c9c9669d5852aa779689c74e (diff)
downloadlwn-5b058034e3aa600802ab609e8264dc2ca1300ebe.tar.gz
lwn-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/util.c')
-rw-r--r--scripts/kconfig/util.c13
1 files changed, 10 insertions, 3 deletions
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 */