Pull request for branch yem/kconfig-for-next
From: "Yann E. MORIN" <[email protected]>
Hello Michal,
Please pull a few more changes queued for 3.12 since your last pull:
- POSIX compliance when using sed in scripts/config (CLément)
- use 'long long' to represent hex and ranges, so their width
is not dependent on the architecture (32/64 bits) (Kees)
- remove the warning when parsing auto.conf, that frigthened Linus when he merged the ext4 tree
- explicit use CONFIG_MODULES to enable tristates
Regards,
Yann E. MORIN.
PS. I've indeed changed the naming scheme of my branches, don't worry. ;-)
The following changes since commit c3286ee337b0586a8ae2b4f13c33e3de5d71139e:
Merge branch 'yem-kconfig-rc-fixes' of git://gitorious.org/linux-kconfig/linux-kconfig into kbuild/kconfig (2013-07-23 15:57:17 +0200)
are available in the git repository at:
git://gitorious.org/linux-kconfig/linux-kconfig.git yem/kconfig-for-next
for you to fetch changes up to 11097a0367e48954ecf616f9b0df48d86835dd0d:
modules: do not depend on kconfig to set 'modules' option to symbol MODULES (2013-08-15 22:56:08 +0200)
----------------------------------------------------------------
Clement Chauplannaz (1):
scripts/config: use sed's POSIX interface
Kees Cook (1):
kconfig: switch to "long long" for sanity
Yann E. MORIN (2):
kconfig: silence warning when parsing auto.conf when a symbol has changed type
modules: do not depend on kconfig to set 'modules' option to symbol MODULES
init/Kconfig | 1 + scripts/config | 44 +++++++++++++++++++++++++++++++++++++++++--- scripts/kconfig/confdata.c | 11 ++++++++--- scripts/kconfig/symbol.c | 19 ++++++++++--------- 4 files changed, 60 insertions(+), 15 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/4 kconfig: switch to "long long" for sanity
From: Kees Cook <[email protected]>
Instead of using "long" for kconfig "hex" and "range" values, which may change in size depending on the host architecture, use "long long". This will allow values greater than INT_MAX on 32-bit hosts when cross compiling.
--- scripts/kconfig/symbol.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
scripts/kconfig/symbol.c +10 -9
@@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)return NULL ; } -static long sym_get_range_val (struct symbol *sym,int base) +static long long sym_get_range_val (struct symbol *sym,int base) {sym_calc_value (sym);switch (sym->type) {
@@ -149,13 +149,14 @@ static long sym_get_range_val(struct symbol *sym, int base)default :break ; } -return strtol (sym->curr.val,NULL , base); +return strtoll (sym->curr.val,NULL , base); }static void sym_validate_range (struct symbol *sym) {struct property *prop; -long base, val, val2; +int base; +long long val, val2;char str[64 ];switch (sym->type) {
@@ -171,7 +172,7 @@ static void sym_validate_range(struct symbol *sym) prop =sym_get_range_prop (sym);if (!prop)return ; - val =strtol (sym->curr.val,NULL , base); + val =strtoll (sym->curr.val,NULL , base); val2 =sym_get_range_val (prop->expr->left.sym, base);if (val >= val2) { val2 =sym_get_range_val (prop->expr->right.sym, base);
@@ -179,9 +180,9 @@ static void sym_validate_range(struct symbol *sym)return ; }if (sym->type ==S_INT ) -sprintf (str,"%ld" , val2); +sprintf (str,"%lld" , val2);else -sprintf (str,"0x%lx" , val2); +sprintf (str,"0x%llx" , val2); sym->curr.val =strdup (str); }
@@ -594,7 +595,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)bool sym_string_within_range (struct symbol *sym,const char *str) {struct property *prop; -long val; +long long val;switch (sym->type) {case S_STRING :
@@ -605,7 +606,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str) prop =sym_get_range_prop (sym);if (!prop)return true; - val =strtol (str,NULL ,10 ); + val =strtoll (str,NULL ,10 );return val >=sym_get_range_val (prop->expr->left.sym,10 ) && val <=sym_get_range_val (prop->expr->right.sym,10 );case S_HEX :
@@ -614,7 +615,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str) prop =sym_get_range_prop (sym);if (!prop)return true; - val =strtol (str,NULL ,16 ); + val =strtoll (str,NULL ,16 );return val >=sym_get_range_val (prop->expr->left.sym,16 ) && val <=sym_get_range_val (prop->expr->right.sym,16 );case S_BOOLEAN :
Signature · 1 line
1.8.1.2
PATCH 2/4 scripts/config: use sed's POSIX interface
In reply to Yann E. MORINFrom: Clement Chauplannaz <[email protected]>
Script config' relies on extensions of GNU sed', and is thus not working on all Unixes:
- in-place edition of files (-i), which can be replaced with
a temporary file;
- extended-regexps (-r), which can be split into basic regexps;
- single-line calls to `a' command, while some implementations require a leading newline before the parameter.
Rewrite calls to `sed' to comply with POSIX interface, and move them to helper functions.
--- scripts/config | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-)
scripts/config +41 -3
@@ -62,15 +62,52 @@ checkarg() { fi } +txt_append() { + local anchor="$1" + local insert="$2" + local infile="$3" + local tmpfile="$infile.swp" + + # sed append cmd: 'a\' + newline + text + newline + cmd="$(printf "a\\%b$insert" "\n")" + + sed -e "/$anchor/$cmd" "$infile" >"$tmpfile" + # replace original file with the edited one + mv "$tmpfile" "$infile" +} + +txt_subst() { + local before="$1" + local after="$2" + local infile="$3" + local tmpfile="$infile.swp" + + sed -e "s/$before/$after/" "$infile" >"$tmpfile" + # replace original file with the edited one + mv "$tmpfile" "$infile" +} + +txt_delete() { + local text="$1" + local infile="$2" + local tmpfile="$infile.swp" + + sed -e "/$text/d" "$infile" >"$tmpfile" + # replace original file with the edited one + mv "$tmpfile" "$infile" +} + set_var() { local name=$1 new=$2 before=$3 name_re="^($name=|# $name is not set)" before_re="^($before=|# $before is not set)" if test -n "$before" && grep -Eq "$before_re" "$FN"; then - sed -ri "/$before_re/a $new" "$FN" + txt_append "^$before=" "$new" "$FN" + txt_append "^# $before is not set" "$new" "$FN" elif grep -Eq "$name_re" "$FN"; then - sed -ri "s:$name_re.*:$new:" "$FN" + txt_subst "^$name=.*" "$new" "$FN" + txt_subst "^# $name is not set" "$new" "$FN" else echo "$new" >>"$FN" fi
@@ -79,7 +116,8 @@ set_var() { undef_var() { local name=$1 - sed -ri "/^($name=|# $name is not set)/d" "$FN" + txt_delete "^$name=" "$FN" + txt_delete "^# $name is not set" "$FN" } if [ "$1" = "--file" ]; then
Signature · 1 line
1.8.1.2
Re: [PATCH 2/4] scripts/config: use sed's POSIX interface
Quoted 10 lines · Yann E. MORIN
From: Clement Chauplannaz <[email protected]>
Script
config' relies on extensions ofGNU sed', and is thus not working on all Unixes:
- in-place edition of files (-i), which can be replaced witha temporary file;- extended-regexps (-r), which can be split into basic regexps;
- single-line calls to `a' command, while some implementations require a leading newline before the parameter.
Quoted 7 lines
Rewrite calls to `sed' to comply with POSIX interface, and move them to helper functions.
Signed-off-by Clement Chauplannaz <[email protected]>Tested-by "Yann E. MORIN" <[email protected]>Reviewed-by "Yann E. MORIN" <[email protected]>Signed-off-by Yann E. MORIN <[email protected]>
This patch totally breaks my usage of the --set-str argument to "config".
Reverting this patch solves the problem.
Reproduce:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- KBUILD_OUTPUT=build-nomadik nhk8815_defconfig scripts/config --file build-nomadik/.config --set-str CMDLINE "root=/dev/ram0 console=ttyAMA1,115200n8 earlyprintk"
sed: -e uttryck #1, tecken 44: flaggan okänd för "s"
sed: -e uttryck #1, tecken 54: flaggan okänd för "s"
Swedish messages meaning "unknown flag for "s""
After reverting the patch these messages no longer appear.
At failure my config file is scratched :-O
Yours,
Linus Walleij
Re: [PATCH 2/4] scripts/config: use sed's POSIX interface
2013/9/12 Linus Walleij <[email protected]>:
Quoted 33 lines · Yann E. MORIN
Quoted 11 lines
From: Clement Chauplannaz <[email protected]>
Script
config' relies on extensions ofGNU sed', and is thus not working on all Unixes:
- in-place edition of files (-i), which can be replaced witha temporary file;- extended-regexps (-r), which can be split into basic regexps;
- single-line calls to `a' command, while some implementations require a leading newline before the parameter.Quoted 7 lines
Rewrite calls to `sed' to comply with POSIX interface, and move them to helper functions.
Signed-off-by Clement Chauplannaz <[email protected]>Tested-by "Yann E. MORIN" <[email protected]>Reviewed-by "Yann E. MORIN" <[email protected]>Signed-off-by Yann E. MORIN <[email protected]>This patch totally breaks my usage of the --set-str argument to "config".
Reverting this patch solves the problem.
Reproduce:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- KBUILD_OUTPUT=build-nomadiknhk8815_defconfigscripts/config--file build-nomadik/.config --set-str CMDLINE "root=/dev/ram0 console=ttyAMA1,115200n8 earlyprintk"
sed: -e uttryck #1, tecken 44: flaggan okänd för "s"
sed: -e uttryck #1, tecken 54: flaggan okänd för "s"
Quoted 8 lines
Swedish messages meaning "unknown flag for "s""
After reverting the patch these messages no longer appear.
At failure my config file is scratched :-O
Yours,
Linus Walleij
Hello Linus,
Thank you for this report. I was able to reproduce this bug and fix it.
My previous commit changed the separator between sed's substitute command and its parameters, from ':' to '/'. The latter conflicted with the slashes found in the value of variable CMDLINE, as provided in your email.
I'm sending a patch right now to revert to previous behavior.
Best regards,
Clement Chauplannaz
PATCH 1/1 scripts/config: fix variable substitution command
Commit 229455bc02b87f7128f190c4491b4ceffff38648 accidentally changed the separator between sed `s' command and its parameters from ':' to '/'.
Revert this change.
--- scripts/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/config +1 -1
@@ -80,7 +80,7 @@ txt_subst() { local infile="$3" local tmpfile="$infile.swp" - sed -e "s/$before/$after/" "$infile" >"$tmpfile" + sed -e "s:$before:$after:" "$infile" >"$tmpfile" # replace original file with the edited one mv "$tmpfile" "$infile" }
Signature · 1 line
1.8.3.2.dirty
Re: [PATCH] scripts/config: fix variable substitution command
Quoted 6 lines · Clement Chauplannaz
Commit
229455bc02b87f7128f190c4491b4ceffff38648accidentally changed the separator between sed `s' command and its parameters from ':' to '/'.Revert this change.
Signed-off-by Clement Chauplannaz <[email protected]>
This patch fixes my issue with --set-str, thanks!
Yours,
Linus Walleij
Re: [PATCH 2/4] scripts/config: use sed's POSIX interface
In reply to Clément ChauplannazQuoted 1 line · Clément Chauplannaz
Thank you for this report. I was able to reproduce this bug and fix it.
Thanks! Tested and works fine.
Quoted 4 lines
My previous commit changed the separator between sed's substitute command and its parameters, from ':' to '/'. The latter conflicted with the slashes found in the value of variable CMDLINE, as provided in your email.
Hm it could actually be useful to be able to have colons in a CMDLINE, I wonder if we can think about some better separator ... oh well that is another issue, all old scripts work now anyway.
Yours,
Linus Walleij
Re: [PATCH 2/4] scripts/config: use sed's POSIX interface
Quoted 6 lines · Linus Walleij
Quoted 1 line · Clément Chauplannaz
Thank you for this report. I was able to reproduce this bug and fix it.
Thanks! Tested and works fine.
Glad to read the patch solves your issue. Thanks for the quick feedback!
Quoted 9 lines
Quoted 5 lines
My previous commit changed the separator between sed's substitute command and its parameters, from ':' to '/'. The latter conflicted with the slashes found in the value of variable CMDLINE, as provided in your email.
Hm it could actually be useful to be able to have colons in a CMDLINE, I wonder if we can think about some better separator ... oh well that is another issue, all old scripts work now anyway.
Indeed config script may not work with all possible string values. My first concern for now was to fallback to previous interface. We may look into hardening the script later on.
Best regards,
Clement Chauplannaz
Re: [PATCH 2/4] scripts/config: use sed's POSIX interface
Dne 13.9.2013 11:54, Clément Chauplannaz napsal(a):
Quoted 15 lines · Linus Walleij
Quoted 7 lines
Quoted 1 line · Clément Chauplannaz
Thank you for this report. I was able to reproduce this bug and fix it.
Thanks! Tested and works fine.
Glad to read the patch solves your issue. Thanks for the quick feedback!
Quoted 6 lines
Quoted 5 lines
My previous commit changed the separator between sed's substitute command and its parameters, from ':' to '/'. The latter conflicted with the slashes found in the value of variable CMDLINE, as provided in your email.
Quoted 7 lines
Quoted 3 lines
Hm it could actually be useful to be able to have colons in a CMDLINE, I wonder if we can think about some better separator ... oh well that is another issue, all old scripts work now anyway.
Indeed config script may not work with all possible string values. My
first concern for now was to fallback to previous interface. We may look into hardening the script later on.
Right. I will merge the patch because it reverts a regression. But feel free to submit another patch that escapes the colons in $after. The script already uses #!/bin/bash, so a "${after//:/\:}" should work.
Michal
PATCH 3/4 kconfig: silence warning when parsing auto.conf when a symbol has changed type
In reply to Yann E. MORINFrom: "Yann E. MORIN" <[email protected]>
When a symbol changes type from tristate to bool, and was previously set to 'm', a subsequent silentoldconfig would warn about inconsistency, such as:
include/config/auto.conf:3014:warning: symbol value 'm' invalid for HOTPLUG_PCI_PCIE
Seen by Linus with the merge in aa8032b (sequence to reproduce by Michal):
git checkout 1fe0135
make mrproper
make allmodconfig
make silentoldconfig
git checkout aa8032b
make allmodconfig
make silentoldconfig
Since HOTPLUG_PCI_PCIE changed from tristate to bool in aa8032b, it was previously set to 'm' in auto.conf by the first allmodconfig+silentoldconfig, but then was set to 'y' by the second allmodconfig. Then the second silentoldconfig prints the warning.
The warning in this case is a spurious warning, which happens at the time kconfig tries to detect symbols that have changed, to touch the empty header files in include/config used for dependency-tracking by make.
Silence the warning when we read the old auto.conf file, since it is perfectly legit that a symbol changed type since the previous call.
Thread in:
http://marc.info/?l=linux-pci&m=137569198904000&w=2
--- scripts/kconfig/confdata.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
scripts/kconfig/confdata.c +8 -3
@@ -140,7 +140,9 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) sym->flags |= def_flags;break ; } -conf_warning ("symbol value '%s' invalid for %s" , p, sym->name); +if (def !=S_DEF_AUTO ) +conf_warning ("symbol value '%s' invalid for %s" , + p, sym->name);return 1 ;case S_OTHER :if (*p !='"' ) {
@@ -161,7 +163,8 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)memmove (p2, p2 +1 ,strlen (p2)); }if (!p2) { -conf_warning ("invalid string found" ); +if (def !=S_DEF_AUTO ) +conf_warning ("invalid string found" );return 1 ; }/* fall through */
@@ -172,7 +175,9 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) sym->def[def].val =strdup (p); sym->flags |= def_flags; }else { -conf_warning ("symbol value '%s' invalid for %s" , p, sym->name); +if (def !=S_DEF_AUTO ) +conf_warning ("symbol value '%s' invalid for %s" , + p, sym->name);return 1 ; }break ;
Signature · 1 line
1.8.1.2
PATCH 4/4 modules: do not depend on kconfig to set 'modules' option to symbol MODULES
In reply to Yann E. MORINFrom: "Yann E. MORIN" <[email protected]>
Currently, the MODULES symbol is special-cased in different places in the kconfig language. For example, if no symbol is defined to enable tristates, then kconfig looks up for a symbol named 'MODULES', and forces the 'modules' option onto that symbol.
This causes problems as such:
- since MODULES is special-cased, reading the configuration with KCONFIG_ALLCONFIG set will forcibly set MODULES to be 'valid' (ie. it has a valid value), when no such value was previously set. So MODULES defaults to 'n' unless it is present in KCONFIG_ALLCONFIG
- other third-party projects may decide that 'MODULES' plays a different role for them
This has been exposed by cset #cfa98f2e:
kconfig: do not override symbols already set
and reported by Stephen in:
http://marc.info/?l=linux-next&m=137592137915234&w=2
As suggested by Sam, we explicitly define the MODULES symbol to be the tristate-enabler. This will allow us to drop special-casing of MODULES in the kconfig language, later.
(Note: this patch is not a fix to Stephen's issue, just a first step).
--- init/Kconfig | 1 + 1 file changed, 1 insertion(+)
init/Kconfig +1 -0
@@ -1666,6 +1666,7 @@ config BASE_SMALL menuconfig MODULES bool "Enable loadable module support" + option modules help Kernel modules are small pieces of compiled code which can be inserted in the running kernel, rather than being
Signature · 1 line
1.8.1.2
Quoted 4 lines · Yann E. MORIN
From: "Yann E. MORIN" <[email protected]>
Hello Michal,
Quoted 8 lines
Please pull a few more changes queued for 3.12 since your last pull:
- POSIX compliance when using sed in
scripts/config(CLément)
- use 'long long' to represent hex and ranges, so their width
is not dependent on the architecture (32/64 bits) (Kees)
- remove the warning when parsing auto.conf, that frigthened Linus when he merged the ext4 tree
- explicit useCONFIG_MODULESto enable tristates
Pulled, thanks! Now you can remove the CONFIG_MODULES special handling from kconfig.
Michal
Michal, All,
Quoted 14 lines · On Friday 16 August 2013 14:48:47 Michal Marek wrote:
Quoted 4 lines · Yann E. MORIN
From: "Yann E. MORIN" <[email protected]>
Hello Michal,
Quoted 8 lines
Please pull a few more changes queued for 3.12 since your last pull:
- POSIX compliance when using sed in
scripts/config(CLément)
- use 'long long' to represent hex and ranges, so their width
is not dependent on the architecture (32/64 bits) (Kees)
- remove the warning when parsing auto.conf, that frigthened Linus when he merged the ext4 tree
- explicit useCONFIG_MODULESto enable tristates
Quoted 2 lines
Pulled, thanks! Now you can remove the
CONFIG_MODULESspecial handling from kconfig.
Eh! Easier said than done! ;-)
Thanks!
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +0/33 662376056 | Software Designer | \ / CAMPAIGN | ^ | | --==< O_o >==-- '------------.-------: X AGAINST | /e\ There is no | | http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL | """ conspiracy. | '------------------------------'-------'------------------'--------------------'