From: Richard Weinberger <richard@nod.at>
To: masahiroy@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
Richard Weinberger <richard@nod.at>
Subject: [PATCH 1/2] kconfig: Refactor sym_escape_string_value
Date: Mon, 20 Sep 2021 23:39:56 +0200 [thread overview]
Message-ID: <20210920213957.1064-1-richard@nod.at> (raw)
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
next reply other threads:[~2021-09-20 21:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 21:39 Richard Weinberger [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210920213957.1064-1-richard@nod.at \
--to=richard@nod.at \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®