All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kconfig: Refactor sym_escape_string_value
@ 2021-09-20 21:39 Richard Weinberger
  2021-09-20 21:39 ` [PATCH 2/2] kconfig: Deny command substitution in string values Richard Weinberger
  2021-09-27 12:36 ` [PATCH 1/2] kconfig: Refactor sym_escape_string_value Masahiro Yamada
  0 siblings, 2 replies; 11+ messages in thread
From: Richard Weinberger @ 2021-09-20 21:39 UTC (permalink / raw)
  To: masahiroy; +Cc: linux-kernel, linux-kbuild, Richard Weinberger

sym_escape_string_value() can take a struct symbol directly
and use sym_get_string_value() itself to obtain the string value.
We will need struct symbol later for error reporting.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 scripts/kconfig/conf.c      | 3 +--
 scripts/kconfig/confdata.c  | 3 +--
 scripts/kconfig/lkc_proto.h | 2 +-
 scripts/kconfig/symbol.c    | 6 ++++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 5d84b44a2a2a..a6dad4a2e7a2 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -650,8 +650,7 @@ static void check_conf(struct menu *menu)
 				const char *str;
 
 				if (sym->type == S_STRING) {
-					str = sym_get_string_value(sym);
-					str = sym_escape_string_value(str);
+					str = sym_escape_string(sym);
 					printf("%s%s=%s\n", CONFIG_, sym->name, str);
 					free((void *)str);
 				} else {
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index cf72680cd769..4e053f2477f9 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -734,8 +734,7 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym,
 	case S_UNKNOWN:
 		break;
 	case S_STRING:
-		str = sym_get_string_value(sym);
-		str = sym_escape_string_value(str);
+		str = sym_escape_string(sym);
 		printer->print_symbol(fp, sym, str, printer_arg);
 		free((void *)str);
 		break;
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index a11626bdc421..035cc522808b 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -18,7 +18,7 @@ extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
 
 struct symbol * sym_lookup(const char *name, int flags);
 struct symbol * sym_find(const char *name);
-const char * sym_escape_string_value(const char *in);
+const char * sym_escape_string(struct symbol *sym);
 struct symbol ** sym_re_search(const char *pattern);
 const char * sym_type_name(enum symbol_type type);
 void sym_calc_value(struct symbol *sym);
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 5844d636d38f..4a31bb943f79 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -871,13 +871,15 @@ struct symbol *sym_find(const char *name)
 	return symbol;
 }
 
-const char *sym_escape_string_value(const char *in)
+const char *sym_escape_string(struct symbol *sym)
 {
-	const char *p;
+	const char *in, *p;
 	size_t reslen;
 	char *res;
 	size_t l;
 
+	in = sym_get_string_value(sym);
+
 	reslen = strlen(in) + strlen("\"\"") + 1;
 
 	p = in;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-10-07  6:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 21:39 [PATCH 1/2] kconfig: Refactor sym_escape_string_value Richard Weinberger
2021-09-20 21:39 ` [PATCH 2/2] kconfig: Deny command substitution in string values Richard Weinberger
2021-09-22  7:17   ` Boris Kolpackov
2021-09-22  7:27     ` Richard Weinberger
2021-09-22 15:18       ` Boris Kolpackov
2021-09-22 16:17         ` Richard Weinberger
2021-09-25  8:58           ` Masahiro Yamada
2021-09-27 14:34           ` Boris Kolpackov
2021-09-27 12:36 ` [PATCH 1/2] kconfig: Refactor sym_escape_string_value Masahiro Yamada
2021-10-05 15:42   ` Masahiro Yamada
2021-10-07  6:45     ` Richard Weinberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.