From patchwork Mon Sep 20 21:39:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 12506469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1A04C433FE for ; Mon, 20 Sep 2021 21:51:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBD8160F48 for ; Mon, 20 Sep 2021 21:51:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230240AbhITVwk (ORCPT ); Mon, 20 Sep 2021 17:52:40 -0400 Received: from lithops.sigma-star.at ([195.201.40.130]:35474 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233719AbhITVuk (ORCPT ); Mon, 20 Sep 2021 17:50:40 -0400 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 5A3546169BC6; Mon, 20 Sep 2021 23:40:11 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cQQp0LvWxRIc; Mon, 20 Sep 2021 23:40:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 927886169BCC; Mon, 20 Sep 2021 23:40:10 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FmJOGlMy-qjY; Mon, 20 Sep 2021 23:40:10 +0200 (CEST) Received: from blindfold.corp.sigma-star.at (213-47-184-186.cable.dynamic.surfer.at [213.47.184.186]) by lithops.sigma-star.at (Postfix) with ESMTPSA id ACB746108471; Mon, 20 Sep 2021 23:40:09 +0200 (CEST) From: Richard Weinberger To: masahiroy@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Richard Weinberger Subject: [PATCH 1/2] kconfig: Refactor sym_escape_string_value Date: Mon, 20 Sep 2021 23:39:56 +0200 Message-Id: <20210920213957.1064-1-richard@nod.at> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 --- 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;