From patchwork Sat Nov 18 07:59:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13459901 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3524C63B2 for ; Sat, 18 Nov 2023 07:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SqkBXj4R" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17AD1C433C7; Sat, 18 Nov 2023 07:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700294356; bh=FUJGT7Wxv+A9qlisbFn6Z/VU7oX5Ys4xFHdHW9fEVFQ=; h=From:To:Cc:Subject:Date:From; b=SqkBXj4ROG6o8h/47chPS34ducc2BQrT+TZDy8Ool3IvQ0UiqmYgaVQm838jnb9h/ dh2Eod92LXLdxcInnHoEBD6/o0f7gRxdA0me2vM/GcgoEkfYg5dVH5+O6SQoRYGCG5 OE7qeFXedj3McK0OrSTq9mPaVbsQu4dPSscNaDuFZ5ztZ7zDXynQ0Dqxba7zGfHmor 0jhLRNRP6HcpIdgjxxn4XSAourXfi3o1KRvDq3Tzi28o8o3wW1d1sa8Ca0pB4Ptd+D nGiYYCsO15qTJzRHCoNpxDdraZWrTqt3cC0s8BuZxaTn8aGGdel0soxC3u//6YlTYs QhV+yQDtLVH6Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 1/6] kconfig: require a space after '#' for valid input Date: Sat, 18 Nov 2023 16:59:07 +0900 Message-Id: <20231118075912.1303509-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, when an input line starts with '#', (line + 2) is passed to memcmp() without checking line[1]. It means that line[1] can be any arbitrary character. For example, "#KCONFIG_FOO is not set" is accepted as valid input, functioning the same as "# CONFIG_FOO is not set". More importantly, this can potentially lead to a buffer overrun if line[1] == '\0'. It occurs if the input only contains '#', as (line + 2) points to an uninitialized buffer. Check line[1], and skip the line if it is not a space. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 2ba4dfdd1aee..556b7f087dbb 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -426,6 +426,8 @@ int conf_read_simple(const char *name, int def) conf_lineno++; sym = NULL; if (line[0] == '#') { + if (line[1] != ' ') + continue; if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) continue; p = strchr(line + 2 + strlen(CONFIG_), ' '); From patchwork Sat Nov 18 07:59:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13459902 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BE7120F7 for ; Sat, 18 Nov 2023 07:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PjbwH44S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28B26C433C8; Sat, 18 Nov 2023 07:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700294357; bh=jauAd/DlIAxGRDHMhsV9eiDiF6QyHtLCAz+l36D7zjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PjbwH44S8XJsybJbgN1uXro8sSssuv0tAW825PLtyijhAG8M7czDA+DWYy0tkE0Nf HHXKNdJn3E0ejeHOTC8pQ8gE5pJjf86hCY2uJTVB/OWyu/SGCjORkJP2iITAViUTZv mYekF/H72wCwzdaf3/RzGh9DqO7hMY6P73YYkRVuNYUf3sBajQsvlKU7ujoc9sI4A4 kMwzbSPn/xf63v8TA+if0Xu0f8O+CrwyDl2Ns212Og0+48tyv6CkJ1vi/a+19lLkqf +mOU7YfpRHhm+kwJT7ikG5lOCRPJTHxgdflgisJAjZXabCJO0PvQX36EHw5XKQJiRX PsCS1nbyqmKfg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 2/6] kconfig: remove unused code for S_DEF_AUTO in conf_read_simple() Date: Sat, 18 Nov 2023 16:59:08 +0900 Message-Id: <20231118075912.1303509-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231118075912.1303509-1-masahiroy@kernel.org> References: <20231118075912.1303509-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The 'else' arm here is unreachable in practical use cases. include/config/auto.conf does not include "# CONFIG_... is not set" line unless it is manually hacked. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 556b7f087dbb..92e8e37aca4d 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -436,20 +436,15 @@ int conf_read_simple(const char *name, int def) *p++ = 0; if (strncmp(p, "is not set", 10)) continue; - if (def == S_DEF_USER) { - sym = sym_find(line + 2 + strlen(CONFIG_)); - if (!sym) { - if (warn_unknown) - conf_warning("unknown symbol: %s", - line + 2 + strlen(CONFIG_)); - conf_set_changed(true); - continue; - } - } else { - sym = sym_lookup(line + 2 + strlen(CONFIG_), 0); - if (sym->type == S_UNKNOWN) - sym->type = S_BOOLEAN; + sym = sym_find(line + 2 + strlen(CONFIG_)); + if (!sym) { + if (warn_unknown) + conf_warning("unknown symbol: %s", + line + 2 + strlen(CONFIG_)); + + conf_set_changed(true); + continue; } if (sym->flags & def_flags) { conf_warning("override: reassigning to symbol %s", sym->name); From patchwork Sat Nov 18 07:59:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13459903 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D2C323CA for ; Sat, 18 Nov 2023 07:59:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RydCbEjN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 342B5C433C9; Sat, 18 Nov 2023 07:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700294358; bh=YxFaQuWjuJpS5NUYQ/dIR/BuE2+ge6XoKjKGeh3QdZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RydCbEjNwUvyzYgnPXpoQnsDGmvaPa+DqH6m/UGtiqzLQFwoJrZf7xfrMvZGXemYD Bz79mX4w5aXFlxf1Y5x5RmvFwkfbE52Sk7sGpYhI03McpyvaF7yq/z1FX7+ciOU3Og qACTu2uaSzjvPjyGPqG40OPkBVNiZAU7Ymkre/xaFOu6E70W3X03PkuAVEn2b58B3x fE+0Bwd+tUFK0mfFJnSJgkyiJgpqhVNZtj7p/6MkwF0u2tZ4LP/8COrEspm3vCQHJ2 phJY39ZuMaH5l32Ra64ba4Hjo3cXPiYj1URfxSUkznp8MuNyZU+2oykoLHIlImL3Ix H12/nymBeAr+w== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 3/6] kconfig: deduplicate code in conf_read_simple() Date: Sat, 18 Nov 2023 16:59:09 +0900 Message-Id: <20231118075912.1303509-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231118075912.1303509-1-masahiroy@kernel.org> References: <20231118075912.1303509-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as a valid input, but conf_read_simple() duplicates similar code to handle them. Factor out the common code. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 89 +++++++++++++++----------------------- 1 file changed, 35 insertions(+), 54 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 92e8e37aca4d..b6a90f6baea1 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -342,11 +342,10 @@ int conf_read_simple(const char *name, int def) FILE *in = NULL; char *line = NULL; size_t line_asize = 0; - char *p, *p2; + char *p, *p2, *val; struct symbol *sym; int i, def_flags; - const char *warn_unknown; - const char *werror; + const char *warn_unknown, *werror, *sym_name; warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS"); werror = getenv("KCONFIG_WERROR"); @@ -424,77 +423,34 @@ int conf_read_simple(const char *name, int def) while (compat_getline(&line, &line_asize, in) != -1) { conf_lineno++; - sym = NULL; if (line[0] == '#') { if (line[1] != ' ') continue; - if (memcmp(line + 2, CONFIG_, strlen(CONFIG_))) + p = line + 2; + if (memcmp(p, CONFIG_, strlen(CONFIG_))) continue; - p = strchr(line + 2 + strlen(CONFIG_), ' '); + sym_name = p + strlen(CONFIG_); + p = strchr(sym_name, ' '); if (!p) continue; *p++ = 0; if (strncmp(p, "is not set", 10)) continue; - sym = sym_find(line + 2 + strlen(CONFIG_)); - if (!sym) { - if (warn_unknown) - conf_warning("unknown symbol: %s", - line + 2 + strlen(CONFIG_)); - - conf_set_changed(true); - continue; - } - if (sym->flags & def_flags) { - conf_warning("override: reassigning to symbol %s", sym->name); - } - switch (sym->type) { - case S_BOOLEAN: - case S_TRISTATE: - sym->def[def].tri = no; - sym->flags |= def_flags; - break; - default: - ; - } + val = "n"; } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) { - p = strchr(line + strlen(CONFIG_), '='); + sym_name = line + strlen(CONFIG_); + p = strchr(sym_name, '='); if (!p) continue; *p++ = 0; + val = p; p2 = strchr(p, '\n'); if (p2) { *p2-- = 0; if (*p2 == '\r') *p2 = 0; } - - sym = sym_find(line + strlen(CONFIG_)); - if (!sym) { - if (def == S_DEF_AUTO) { - /* - * Reading from include/config/auto.conf - * If CONFIG_FOO previously existed in - * auto.conf but it is missing now, - * include/config/FOO must be touched. - */ - conf_touch_dep(line + strlen(CONFIG_)); - } else { - if (warn_unknown) - conf_warning("unknown symbol: %s", - line + strlen(CONFIG_)); - - conf_set_changed(true); - } - continue; - } - - if (sym->flags & def_flags) { - conf_warning("override: reassigning to symbol %s", sym->name); - } - if (conf_set_sym_val(sym, def, def_flags, p)) - continue; } else { if (line[0] != '\r' && line[0] != '\n') conf_warning("unexpected data: %.*s", @@ -503,6 +459,31 @@ int conf_read_simple(const char *name, int def) continue; } + sym = sym_find(sym_name); + if (!sym) { + if (def == S_DEF_AUTO) { + /* + * Reading from include/config/auto.conf. + * If CONFIG_FOO previously existed in auto.conf + * but it is missing now, include/config/FOO + * must be touched. + */ + conf_touch_dep(sym_name); + } else { + if (warn_unknown) + conf_warning("unknown symbol: %s", sym_name); + + conf_set_changed(true); + } + continue; + } + + if (sym->flags & def_flags) + conf_warning("override: reassigning to symbol %s", sym->name); + + if (conf_set_sym_val(sym, def, def_flags, val)) + continue; + if (sym && sym_is_choice_value(sym)) { struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); switch (sym->def[def].tri) { From patchwork Sat Nov 18 07:59:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13459904 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5155320F7 for ; Sat, 18 Nov 2023 07:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nKXRv4Zt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F603C433CA; Sat, 18 Nov 2023 07:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700294359; bh=7B9xzLj7sIaqmkQ1H5s+m9dY9DubmYm9c00xpE/4MPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nKXRv4Zt8qe0WCMduKIxPCC67/0jUCspqh1jRXrxruCDwXj1rPlOzGpHrKK393xgV XTbNFN58g73dfeBmmoTv6FNn7csho25HIDWOeOi+JgP0pMzHqk7ConchAkFCgfuGjs HHJw1tmEiM3RHF2DXXudpFiZzd2Vm61Nx++tNS7T/B1EbekHZ0OQOzgdQE3CPJt36k xNkz32DDAi0EsbjFpix58JEKrDgUaMT0DPKBDoTxSwUS4eP2pt0kHq6H6PM9OVNoqm dYGidN2bS39UrtgQq10pWPvs5mXvAKFXRouaC0ZZVjMZiNiqYLGBS6YdKI+eOcrC+U zhRh0mjghKVPw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 4/6] kconfig: introduce getline_stripped() helper Date: Sat, 18 Nov 2023 16:59:10 +0900 Message-Id: <20231118075912.1303509-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231118075912.1303509-1-masahiroy@kernel.org> References: <20231118075912.1303509-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, newline characters are stripped away in multiple places on the caller. Doing that in the callee is helpful for further cleanups. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 40 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index b6a90f6baea1..795ac6c9378f 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -337,12 +337,32 @@ static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream) return -1; } +/* like getline(), but the newline character is stripped away */ +static ssize_t getline_stripped(char **lineptr, size_t *n, FILE *stream) +{ + ssize_t len; + + len = compat_getline(lineptr, n, stream); + + if (len > 0 && (*lineptr)[len - 1] == '\n') { + len--; + (*lineptr)[len] = '\0'; + + if (len > 0 && (*lineptr)[len - 1] == '\r') { + len--; + (*lineptr)[len] = '\0'; + } + } + + return len; +} + int conf_read_simple(const char *name, int def) { FILE *in = NULL; char *line = NULL; size_t line_asize = 0; - char *p, *p2, *val; + char *p, *val; struct symbol *sym; int i, def_flags; const char *warn_unknown, *werror, *sym_name; @@ -421,7 +441,7 @@ int conf_read_simple(const char *name, int def) } } - while (compat_getline(&line, &line_asize, in) != -1) { + while (getline_stripped(&line, &line_asize, in) != -1) { conf_lineno++; if (line[0] == '#') { if (line[1] != ' ') @@ -443,19 +463,11 @@ int conf_read_simple(const char *name, int def) p = strchr(sym_name, '='); if (!p) continue; - *p++ = 0; - val = p; - p2 = strchr(p, '\n'); - if (p2) { - *p2-- = 0; - if (*p2 == '\r') - *p2 = 0; - } + *p = 0; + val = p + 1; } else { - if (line[0] != '\r' && line[0] != '\n') - conf_warning("unexpected data: %.*s", - (int)strcspn(line, "\r\n"), line); - + if (line[0] != '\0') + conf_warning("unexpected data: %s", line); continue; } From patchwork Sat Nov 18 07:59:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13459905 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66A3B110F for ; Sat, 18 Nov 2023 07:59:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dO8nnAy9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A797C433C9; Sat, 18 Nov 2023 07:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700294360; bh=JYJrXNFpHjgM9hzobfa0oay+OYFkHJDCeKRYtYSm0BA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dO8nnAy9OwYrA+7yb/7/G7ZlgLeEt/p5iY39MO0KMnqweiduZpzpDiySsbNtIuris 3XRqXgjRWjdHgJ/yB+xjvPAdfA9KZQ6lk+V33CWAdWFeOFC4Ku25rt1uPTxijl0vFO 3HzJHG3iWTcWokJY1ON/H0qoZQjNL1YMOzOd3LBOlaOdMyfyomdlJUlxI1GP2qd4w8 3I+tv5NxJrGgUIjhD3u872dZjB3kohUSIEYOcGvcYEkrfi3OkFS4c0s+vQURYryrIr td0ypwhWx4E4vvqOn7LEqzCZDhuqpyO/2BS9uTBeLL/zzA+dIfsLiaSS2QGaoJepZ9 qyQJJlqox5B6g== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 5/6] kconfig: require an exact match for "is not set" to disable CONFIG option Date: Sat, 18 Nov 2023 16:59:11 +0900 Message-Id: <20231118075912.1303509-5-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231118075912.1303509-1-masahiroy@kernel.org> References: <20231118075912.1303509-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently, any string starting "is not set" disables a CONFIG option. For example, "# CONFIG_FOO is not settled down" is accepted as valid input, functioning the same as "# CONFIG_FOO is not set". It is a long-standing oddity. Check the line against the exact pattern "is not set". Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 795ac6c9378f..958be12cd621 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -454,7 +454,7 @@ int conf_read_simple(const char *name, int def) if (!p) continue; *p++ = 0; - if (strncmp(p, "is not set", 10)) + if (strcmp(p, "is not set")) continue; val = "n"; From patchwork Sat Nov 18 07:59:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13459906 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 739A24F8AD for ; Sat, 18 Nov 2023 07:59:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bYhntA+b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55CCEC433C7; Sat, 18 Nov 2023 07:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700294362; bh=ltXpZxzZisF0fheB2Pyv5Oadd/1xNAmgjgKDKLE8PmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYhntA+bM5EgGMr+Y1nx358VbjA5Rv+51e6CcZ80YMxkhU4lpcKO0p/3dXATjkqjV /A1qhJ7XQkypaUyXWtwXiCmMBogTlAQtzTj4GhE0d6JAn48m0X7xA1JtoIT+0mxmaO xLlQdKJPc5vBZsuV/S/WrCVEPfl2eD2/Xxfo25ky6sqqDeAOgQzKXzhBtyKiIFY5d/ FvVHKy7p8qFn1VA9K5Et/c2VCYldtOXiadTCumf/TzhQYwkisLzvhsM8Js4cT59mjk 08gXBP+1qpMPsNY66BX4/pCAn+uMqbwPBVt8eB6+HkBKA1+r5/1CLv9FlWlKHEB3vU xU+XFBgSIXhQQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 6/6] kconfig: massage the loop in conf_read_simple() Date: Sat, 18 Nov 2023 16:59:12 +0900 Message-Id: <20231118075912.1303509-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231118075912.1303509-1-masahiroy@kernel.org> References: <20231118075912.1303509-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make the while-loop code a little more readable. The gain is that "CONFIG_FOO" without '=' is warned as unexpected data. Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 958be12cd621..bd14aae1db58 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -443,6 +443,10 @@ int conf_read_simple(const char *name, int def) while (getline_stripped(&line, &line_asize, in) != -1) { conf_lineno++; + + if (!line[0]) /* blank line */ + continue; + if (line[0] == '#') { if (line[1] != ' ') continue; @@ -458,17 +462,20 @@ int conf_read_simple(const char *name, int def) continue; val = "n"; - } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) { + } else { + if (memcmp(line, CONFIG_, strlen(CONFIG_))) { + conf_warning("unexpected data: %s", line); + continue; + } + sym_name = line + strlen(CONFIG_); p = strchr(sym_name, '='); - if (!p) + if (!p) { + conf_warning("unexpected data: %s", line); continue; + } *p = 0; val = p + 1; - } else { - if (line[0] != '\0') - conf_warning("unexpected data: %s", line); - continue; } sym = sym_find(sym_name);