Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nasser Afshin <afshin.nasser@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v3 3/3] merge_config.sh: Avoid false positive matches from comment lines
Date: Tue, 13 Nov 2018 17:14:04 +0330	[thread overview]
Message-ID: <20181113134404.32235-4-afshin.nasser@gmail.com> (raw)
In-Reply-To: <20181113134404.32235-1-afshin.nasser@gmail.com>

From: Nasser Afshin <Afshin.Nasser@gmail.com>

We are using empty CONFIG_PREFIX_. This results in false positive match
for comment lines when merging config fragments.

To avoid false positive reports, we use separate sed expressions and
address comment lines explicitly.

This is actually an upstream patch [1] from linux/kbuild project.

[1] https://patchwork.kernel.org/patch/10667571/

Signed-off-by: Nasser Afshin <Afshin.Nasser@gmail.com>
---
 support/kconfig/merge_config.sh                    |  7 +++--
 ...false-positive-matches-from-comment-lines.patch | 32 ++++++++++++++++++++++
 support/kconfig/patches/series                     |  1 +
 3 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch

diff --git a/support/kconfig/merge_config.sh b/support/kconfig/merge_config.sh
index 404ca3864f..14917806a3 100755
--- a/support/kconfig/merge_config.sh
+++ b/support/kconfig/merge_config.sh
@@ -109,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
 fi
 
 MERGE_LIST=$*
-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
+SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
+SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
 
 TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
 
@@ -123,7 +124,7 @@ for MERGE_FILE in $MERGE_LIST ; do
 		echo "The merge file '$MERGE_FILE' does not exist.  Exit." >&2
 		exit 1
 	fi
-	CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
+	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
 
 	for CFG in $CFG_LIST ; do
 		grep -q -w $CFG $TMP_FILE || continue
@@ -166,7 +167,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $EXTERNAL_ARG $OUTPUT_ARG $ALLTARGET
 
 
 # Check all specified config values took (might have missed-dependency issues)
-for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
+for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
 
 	REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
 	ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG")
diff --git a/support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch b/support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch
new file mode 100644
index 0000000000..c11144e47e
--- /dev/null
+++ b/support/kconfig/patches/21-Avoid-false-positive-matches-from-comment-lines.patch
@@ -0,0 +1,32 @@
+Index: kconfig/merge_config.sh
+===================================================================
+--- kconfig.orig/merge_config.sh
++++ kconfig/merge_config.sh
+@@ -109,7 +109,8 @@ if [ ! -r "$INITFILE" ]; then
+ fi
+ 
+ MERGE_LIST=$*
+-SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)[= ].*/\2/p"
++SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p"
++SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p"
+ 
+ TMP_FILE=$(mktemp -t .tmp.config.XXXXXXXXXX)
+ 
+@@ -123,7 +124,7 @@ for MERGE_FILE in $MERGE_LIST ; do
+ 		echo "The merge file '$MERGE_FILE' does not exist.  Exit." >&2
+ 		exit 1
+ 	fi
+-	CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
++	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
+ 
+ 	for CFG in $CFG_LIST ; do
+ 		grep -q -w $CFG $TMP_FILE || continue
+@@ -166,7 +167,7 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $EXTERN
+ 
+ 
+ # Check all specified config values took (might have missed-dependency issues)
+-for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
++for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do
+ 
+ 	REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
+ 	ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG")
diff --git a/support/kconfig/patches/series b/support/kconfig/patches/series
index be8627db13..e5a6f69d8f 100644
--- a/support/kconfig/patches/series
+++ b/support/kconfig/patches/series
@@ -9,3 +9,4 @@
 18-merge-config.sh-create-temporary-files-in-tmp.patch
 19-merge_config.sh-add-br2-external-support.patch
 20-merge_config.sh-Allow-to-define-config-prefix.patch
+21-Avoid-false-positive-matches-from-comment-lines.patch
-- 
2.15.0

  parent reply	other threads:[~2018-11-13 13:44 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-19 22:58 [Buildroot] [PATCH] merge_config.sh: Fix finding redundant config mechanism Nasser
2018-10-20 14:56 ` Matthew Weber
2018-10-20 16:01   ` Arnout Vandecappelle
2018-10-21 17:27     ` Petr Vorel
2018-10-21 17:35       ` Matthew Weber
2018-10-21 17:46         ` Petr Vorel
2018-10-23 15:19     ` Nasser Afshin
2018-10-23 18:20       ` Arnout Vandecappelle
2018-10-24 19:15         ` Petr Vorel
2018-10-24 23:00           ` Nasser
2018-10-25  1:13         ` [Buildroot] [PATCH v2] merge_config.sh: merge also buildroot config files Nasser Afshin
2018-10-25  1:19           ` Nasser
2018-10-25  2:20           ` [Buildroot] [PATCH v3] " Nasser Afshin
2018-10-25  6:02             ` [Buildroot] Antwort: " Marcel Patzlaff
2018-10-25  7:43             ` [Buildroot] " Petr Vorel
2018-10-25  9:43               ` [Buildroot] Antwort: " Marcel Patzlaff
2018-10-25 21:43                 ` Petr Vorel
2018-10-26  6:03                   ` [Buildroot] Antwort: " Marcel Patzlaff
2018-10-26 23:05                     ` Nasser
2018-10-27  4:46                       ` Petr Vorel
2018-10-27 10:48                         ` Nasser Afshin
2018-10-31 19:35                           ` [Buildroot] " Petr Vorel
2018-10-31 20:38                             ` Nasser
2018-10-31 20:56                               ` Petr Vorel
2018-11-01  1:09                                 ` [Buildroot] [PATCH] merge_config.sh: Fix merging " Nasser Afshin
2018-11-01  3:51                                   ` yamada.masahiro at socionext.com
2018-11-01  5:49                                     ` Petr Vorel
2018-11-01  8:12                                       ` Nasser
2018-11-01  6:24                                   ` Petr Vorel
2018-11-01 10:55                                     ` Nasser
2018-11-01 12:05                                       ` Arnout Vandecappelle
2018-11-01 16:19                                         ` Petr Vorel
2018-11-02  2:12                                           ` Nasser
2018-11-02  7:55                                             ` yamada.masahiro at socionext.com
2018-11-02 10:05                                               ` Arnout Vandecappelle
2018-11-02 22:50                                                 ` Petr Vorel
2018-11-03 21:32                                                   ` Nasser
2018-11-05  8:23                                                     ` yamada.masahiro at socionext.com
2018-11-05  8:35                                                       ` Petr Vorel
2018-11-13 13:44                                                         ` [Buildroot] [PATCH v3 0/3] Fix merging configuration fragments Nasser Afshin
2018-11-13 13:44                                                           ` [Buildroot] [PATCH v3 1/3] merge_config.sh: Fix merging buildroot config files Nasser Afshin
2018-11-13 18:35                                                             ` Petr Vorel
2018-11-14  7:16                                                               ` Nasser Afshin
2018-11-13 13:44                                                           ` [Buildroot] [PATCH v3 2/3] test-pkg: Use the correct config prefix when merging Nasser Afshin
2018-11-13 18:26                                                             ` Petr Vorel
2018-11-13 13:44                                                           ` Nasser Afshin [this message]
2018-11-13 18:38                                                             ` [Buildroot] [PATCH v3 3/3] merge_config.sh: Avoid false positive matches from comment lines Petr Vorel
2018-11-14  7:18                                                           ` [Buildroot] [PATCH v3 0/3] Fix merging configuration fragments Nasser Afshin
2018-11-01 13:23                                       ` [Buildroot] [PATCH] merge_config.sh: Fix merging buildroot config files Petr Vorel
2018-11-02  2:18                                         ` Nasser
2018-10-29 15:46                     ` [Buildroot] Antwort: Re: Antwort: Re: [PATCH v3] merge_config.sh: merge also " Petr Vorel
  -- strict thread matches above, loose matches on Subject: below --
2018-11-14  7:11 [Buildroot] [PATCH v3 0/3] Fix merging configuration fragments Nasser Afshin
2018-11-14  7:11 ` [Buildroot] [PATCH v3 3/3] merge_config.sh: Avoid false positive matches from comment lines Nasser Afshin
2018-11-23 21:16   ` Yann E. MORIN
2018-11-24  9:12   ` Thomas Petazzoni

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=20181113134404.32235-4-afshin.nasser@gmail.com \
    --to=afshin.nasser@gmail.com \
    --cc=buildroot@busybox.net \
    /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