kconfig: make hexadecimal prefix mandatory for S_HEX default value
Subsystems (6)
PATCH 1/5 kconfig: make hexadecimal prefix mandatory for S_HEX default value
--- scripts/kconfig/symbol.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
scripts/kconfig/symbol.c +4 -2
@@ -548,8 +548,10 @@ bool sym_string_valid(struct symbol *sym, const char *str) }return true;case S_HEX : -if (str[0 ] =='0' && (str[1 ] =='x' || str[1 ] =='X' )) - str +=2 ; +if (str[0 ] !='\0' && + !(str[0 ] =='0' && (str[1 ] =='x' || str[1 ] =='X' ))) +return false; + str +=2 ; ch = *str++; do { if (!isxdigit(ch))
Signature · 1 line
1.7.2.30.gc37d7.dirty
PATCH 2/5 kconfig: add more S_INT and S_HEX consistency checks
This patch add more number consistency checkg, trying to catch the following situation:
config FOO0
hex
default 42
config FOO1
string
config BAR0
int
default FOO1
config BAR1
hex
default FOO1
config FOO2
hex
default 42h
config FOO3
int
default "1bar"
--- scripts/kconfig/menu.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
scripts/kconfig/menu.c +12 -3
@@ -183,7 +183,7 @@ void menu_add_option(int token, char *arg) } } -static int menu_range_valid_sym (struct symbol *sym,struct symbol *sym2) +static int menu_validate_number (struct symbol *sym,struct symbol *sym2) {return sym2->type ==S_INT || sym2->type ==S_HEX || (sym2->type ==S_UNKNOWN &&sym_string_valid (sym, sym2->name));
@@ -201,6 +201,15 @@ static void sym_check_prop(struct symbol *sym)prop_warn (prop,"default for config symbol '%s'" " must be a single symbol" , sym->name); +if (prop->expr->type !=E_SYMBOL ) +break ; + sym2 =prop_get_symbol (prop); +if (sym->type ==S_HEX || sym->type ==S_INT ) { +if (!menu_validate_number (sym, sym2)) +prop_warn (prop, +"'%s': number is invalid" , + sym->name); + }break ;case P_SELECT : sym2 =prop_get_symbol (prop);
@@ -220,8 +229,8 @@ static void sym_check_prop(struct symbol *sym)if (sym->type !=S_INT && sym->type !=S_HEX )prop_warn (prop,"range is only allowed " "for int or hex symbols" ); -if (!menu_range_valid_sym (sym, prop->expr->left.sym) || - !menu_range_valid_sym (sym, prop->expr->right.sym)) +if (!menu_validate_number (sym, prop->expr->left.sym) || + !menu_validate_number (sym, prop->expr->right.sym))prop_warn (prop,"range is invalid" );break ;default :
Signature · 1 line
1.7.2.30.gc37d7.dirty
Re: [PATCH 2/5] kconfig: add more S_INT and S_HEX consistency checks
Hi,
Quoted 22 lines · Arnaud Lacombe
This patch add more number consistency checkg, trying to catch the following situation:
config FOO0
hex
default 42config FOO1
stringconfig BAR0
int
default FOO1config BAR1
hex
default FOO1config FOO2
hex
default 42h
Quoted 9 lines
config FOO3
int
default "1bar"Signed-off-by Arnaud Lacombe <[email protected]>---
scripts/kconfig/menu.c | 15 ++++++++++++---1 files changed, 12 insertions(+), 3 deletions(-)
ping ?
- Arnaud
Quoted 44 lines
scripts/kconfig/menu.c +1
-1@@ -183,7 +183,7 @@ void menu_add_option(int token, char *arg) } } -static int menu_range_valid_sym (struct symbol *sym,struct symbol *sym2) +static int menu_validate_number (struct symbol *sym,struct symbol *sym2) {return
sym2->type==S_INT||sym2->type==S_HEX|| (sym2->type==S_UNKNOWN&&sym_string_valid(sym, sym2->name));scripts/kconfig/menu.c +0
-0@@ -201,6 +201,15 @@ static void sym_check_prop(struct symbol *sym) prop_warn(prop,"default for config symbol '%s'" " must be a single symbol",
sym->name);
+ if (prop->expr->type!=E_SYMBOL)
+ break;
+ sym2 =prop_get_symbol(prop);
+ if (sym->type==S_HEX||sym->type==S_INT) {
+ if (!menu_validate_number(sym, sym2))
+ prop_warn(prop,
+ "'%s': number is invalid",
+sym->name);
+ }
break;
caseP_SELECT:
sym2 =prop_get_symbol(prop);scripts/kconfig/menu.c +0
-0@@ -220,8 +229,8 @@ static void sym_check_prop(struct symbol *sym) if (sym->type != S_INT && sym->type != S_HEX)prop_warn(prop, "range is only allowed " "for int or hex symbols");
- if (!menu_range_valid_sym(sym,prop->expr->left.sym) ||
- !menu_range_valid_sym(sym,prop->expr->right.sym))
+ if (!menu_validate_number(sym,prop->expr->left.sym) ||
+ !menu_validate_number(sym,prop->expr->right.sym))prop_warn(prop, "range is invalid"); break;
default:
--
1.7.2.30.gc37d7.dirty
Re: [PATCH 2/5] kconfig: add more S_INT and S_HEX consistency checks
In reply to Arnaud LacombeQuoted 22 lines · Arnaud Lacombe
This patch add more number consistency checkg, trying to catch the following situation:
config FOO0
hex
default 42config FOO1
stringconfig BAR0
int
default FOO1config BAR1
hex
default FOO1config FOO2
hex
default 42h
Quoted 8 lines
config FOO3
int
default "1bar"Signed-off-by Arnaud Lacombe <[email protected]>--- scripts/kconfig/menu.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
Thanks, applied to kbuild-2.6.git#kconfig.
Michal
PATCH 5/5 Add missing hexadicimal prefix
In reply to Arnaud Lacombe[Included for reference to give an idea of the change needed. Will be sent later to maintainers if needed.]
--- sound/oss/Kconfig | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-)
sound/oss/Kconfig +19 -19
@@ -76,17 +76,17 @@ config MSNDCLAS_IRQ Interrupt Request line for the MultiSound Classic and related cards. config MSNDCLAS_MEM - hex "MSND Classic memory B0000, C8000, D0000, D8000, E0000, E8000" + hex "MSND Classic memory 0xB0000, 0xC8000, 0xD0000, 0xD8000, 0xE0000, 0xE8000" depends on SOUND_MSNDCLAS=y - default "D0000" + default "0xD0000" help Memory-mapped I/O base address for the MultiSound Classic and related cards. config MSNDCLAS_IO - hex "MSND Classic I/O 210, 220, 230, 240, 250, 260, 290, 3E0" + hex "MSND Classic I/O 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0x290, 0x3E0" depends on SOUND_MSNDCLAS=y - default "290" + default "0x290" help I/O port address for the MultiSound Classic and related cards.
@@ -139,17 +139,17 @@ config MSNDPIN_IRQ Pinnacle and Fiji sound cards. config MSNDPIN_MEM - hex "MSND Pinnacle memory B0000, C8000, D0000, D8000, E0000, E8000" + hex "MSND Pinnacle memory 0xB0000, 0xC8000, 0xD0000, 0xD8000, 0xE0000, 0xE8000" depends on SOUND_MSNDPIN=y - default "D0000" + default "0xD0000" help Memory-mapped I/O base address for the primary synthesizer on MultiSound Pinnacle and Fiji sound cards. config MSNDPIN_IO - hex "MSND Pinnacle I/O 210, 220, 230, 240, 250, 260, 290, 3E0" + hex "MSND Pinnacle I/O 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0x290, 0x3E0" depends on SOUND_MSNDPIN=y - default "290" + default "0x290" help Memory-mapped I/O base address for the primary synthesizer on MultiSound Pinnacle and Fiji sound cards.
@@ -181,9 +181,9 @@ comment "MSND Pinnacle DSP section will be configured to above parameters." depends on SOUND_MSNDPIN=y && MSNDPIN_NONPNP config MSNDPIN_CFG - hex "MSND Pinnacle config port 250,260,270" + hex "MSND Pinnacle config port 0x250, 0x260, 0x270" depends on MSNDPIN_NONPNP - default "250" + default "0x250" help This is the port which the Pinnacle and Fiji uses to configure the card's resources when not in PnP mode. If your card is in PnP mode,
@@ -194,9 +194,9 @@ comment "Pinnacle-specific Device Configuration (0 disables)" depends on SOUND_MSNDPIN=y && MSNDPIN_NONPNP config MSNDPIN_MPU_IO - hex "MSND Pinnacle MPU I/O (e.g. 330)" + hex "MSND Pinnacle MPU I/O (e.g. 0x330)" depends on MSNDPIN_NONPNP - default "0" + default "0x0" help Memory-mapped I/O base address for the Kurzweil daughterboard synthesizer on MultiSound Pinnacle and Fiji sound cards.
@@ -210,17 +210,17 @@ config MSNDPIN_MPU_IRQ synthesizer on MultiSound Pinnacle and Fiji sound cards. config MSNDPIN_IDE_IO0 - hex "MSND Pinnacle IDE I/O 0 (e.g. 170)" + hex "MSND Pinnacle IDE I/O 0 (e.g. 0x170)" depends on MSNDPIN_NONPNP - default "0" + default "0x0" help CD-ROM drive 0 memory-mapped I/O base address for the MultiSound Pinnacle and Fiji sound cards. config MSNDPIN_IDE_IO1 - hex "MSND Pinnacle IDE I/O 1 (e.g. 376)" + hex "MSND Pinnacle IDE I/O 1 (e.g. 0x376)" depends on MSNDPIN_NONPNP - default "0" + default "0x0" help CD-ROM drive 1 memory-mapped I/O base address for the MultiSound Pinnacle and Fiji sound cards.
@@ -234,9 +234,9 @@ config MSNDPIN_IDE_IRQ MultiSound Pinnacle and Fiji sound cards. config MSNDPIN_JOYSTICK_IO - hex "MSND Pinnacle joystick I/O (e.g. 200)" + hex "MSND Pinnacle joystick I/O (e.g. 0x200)" depends on MSNDPIN_NONPNP - default "0" + default "0x0" help Memory-mapped I/O base address for the joystick port on MultiSound Pinnacle and Fiji sound cards.
@@ -520,7 +520,7 @@ config SC6600_CDROM config SC6600_CDROMBASE hex "SC-6600 CDROM Interface I/O Address" depends on SC6600 - default "0" + default "0x0" help Base I/O port address for the CD-ROM interface of the Audio Excel DSP 16 card.
Signature · 10 lines
1.7.2.30.gc37d7.dirty From: Arnaud Lacombe <[email protected]> drivers/media/radio/Kconfig: add missing hexadicimal prefix Signed-off-by: Arnaud Lacombe <[email protected]> --- drivers/media/radio/Kconfig | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/radio/Kconfig +8 -8
@@ -58,7 +58,7 @@ config RADIO_RTRACK config RADIO_RTRACK_PORT hex "RadioTrack i/o port (0x20f or 0x30f)" depends on RADIO_RTRACK=y - default "20f" + default "0x20f" help Enter either 0x30f or 0x20f here. The card default is 0x30f, if you haven't changed the jumper setting on the card.
@@ -81,7 +81,7 @@ config RADIO_RTRACK2 config RADIO_RTRACK2_PORT hex "RadioTrack II i/o port (0x20c or 0x30c)" depends on RADIO_RTRACK2=y - default "30c" + default "0x30c" help Enter either 0x30c or 0x20c here. The card default is 0x30c, if you haven't changed the jumper setting on the card.
@@ -104,7 +104,7 @@ config RADIO_AZTECH config RADIO_AZTECH_PORT hex "Aztech/Packard Bell I/O port (0x350 or 0x358)" depends on RADIO_AZTECH=y - default "350" + default "0x350" help Enter either 0x350 or 0x358 here. The card default is 0x350, if you haven't changed the setting of jumper JP3 on the card. Removing the
@@ -133,7 +133,7 @@ config RADIO_GEMTEK config RADIO_GEMTEK_PORT hex "Fixed I/O port (0x20c, 0x30c, 0x24c, 0x34c, 0c24c or 0x28c)" depends on RADIO_GEMTEK=y - default "34c" + default "0x34c" help Enter either 0x20c, 0x30c, 0x24c or 0x34c here. The card default is 0x34c, if you haven't changed the jumper setting on the card. On
@@ -266,7 +266,7 @@ config RADIO_TERRATEC config RADIO_TERRATEC_PORT hex "Terratec i/o port (normally 0x590)" depends on RADIO_TERRATEC=y - default "590" + default "0x590" help Fill in the I/O port of your TerraTec FM radio card. If unsure, go with the default.
@@ -284,7 +284,7 @@ config RADIO_TRUST config RADIO_TRUST_PORT hex "Trust i/o port (usually 0x350 or 0x358)" depends on RADIO_TRUST=y - default "350" + default "0x350" help Enter the I/O port of your Trust FM radio card. If unsure, try the values "0x350" or "0x358".
@@ -307,7 +307,7 @@ config RADIO_TYPHOON config RADIO_TYPHOON_PORT hex "Typhoon I/O port (0x316 or 0x336)" depends on RADIO_TYPHOON=y - default "316" + default "0x316" help Enter the I/O port of your Typhoon or EcoRadio radio card.
@@ -341,7 +341,7 @@ config RADIO_ZOLTRIX config RADIO_ZOLTRIX_PORT hex "ZOLTRIX I/O port (0x20c or 0x30c)" depends on RADIO_ZOLTRIX=y - default "20c" + default "0x20c" help Enter the I/O port of your Zoltrix radio card.
Signature · 13 lines
1.7.2.30.gc37d7.dirty From: Arnaud Lacombe <[email protected]> drivers/mtd/*/Kconfig: add missing hexadicimal prefix Signed-off-by: Arnaud Lacombe <[email protected]> --- drivers/mtd/devices/Kconfig | 5 ++--- drivers/mtd/maps/Kconfig | 2 +- drivers/mtd/nand/Kconfig | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
drivers/mtd/devices/Kconfig +2 -3
@@ -167,7 +167,7 @@ config MTDRAM_ERASE_SIZE config MTDRAM_ABS_POS hex "SRAM Hexadecimal Absolute position or 0" depends on MTD_MTDRAM=y - default "0" + default "0x0" help If you have system RAM accessible by the CPU but not used by Linux in normal operation, you can give the physical address at which the
@@ -268,8 +268,7 @@ config MTD_DOCPROBE_ADVANCED config MTD_DOCPROBE_ADDRESS hex "Physical address of DiskOnChip" if MTD_DOCPROBE_ADVANCED depends on MTD_DOCPROBE - default "0x0000" if MTD_DOCPROBE_ADVANCED - default "0" if !MTD_DOCPROBE_ADVANCED + default "0x0" ---help--- By default, the probe for DiskOnChip devices will look for a DiskOnChip at every multiple of 0x2000 between 0xC8000 and 0xEE000.
drivers/mtd/maps/Kconfig +1 -1
@@ -47,7 +47,7 @@ config MTD_PHYSMAP_START config MTD_PHYSMAP_LEN hex "Physical length of flash mapping" depends on MTD_PHYSMAP_COMPAT - default "0" + default "0x0" help This is the total length of the mapping of the flash chips on your particular board. If there is space, or aliases, in the
drivers/mtd/nand/Kconfig +1 -1
@@ -274,7 +274,7 @@ config MTD_NAND_DISKONCHIP_PROBE_ADVANCED config MTD_NAND_DISKONCHIP_PROBE_ADDRESS hex "Physical address of DiskOnChip" if MTD_NAND_DISKONCHIP_PROBE_ADVANCED depends on MTD_NAND_DISKONCHIP - default "0" + default "0x0" ---help--- By default, the probe for DiskOnChip devices will look for a DiskOnChip at every multiple of 0x2000 between 0xC8000 and 0xEE000.
Signature · 1 line
1.7.2.30.gc37d7.dirty
Hi,
Quoted 5 lines · Arnaud Lacombe
Signed-off-by Arnaud Lacombe <[email protected]>---
scripts/kconfig/symbol.c | 6 ++++--1 files changed, 4 insertions(+), 2 deletions(-)
ping ?
[I do not really care about that one, but still... The next patch does not address ~100 other warnings potentially triggered in arch/ Kconfig.]
- Arnaud
Quoted 21 lines
scripts/kconfig/symbol.c +0
-0@@ -548,8 +548,10 @@ bool sym_string_valid(struct symbol *sym, const char *str) } return true;case
S_HEX:
- if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
- str += 2;
+ if (str[0] != '\0' &&
+ !(str[0] == '0' && (str[1] == 'x' || str[1] == 'X')))
+ return false;
+ str += 2;
ch = *str++;
do {
if (!isxdigit(ch))
--
1.7.2.30.gc37d7.dirty
Quoted 12 lines · Arnaud Lacombe
Signed-off-by Arnaud Lacombe <[email protected]>--- scripts/kconfig/symbol.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)scripts/kconfig/symbol.c +0
-0@@ -548,8 +548,10 @@ bool sym_string_valid(struct symbol *sym, const char *str) }return true;
scripts/kconfig/symbol.c bool sym_string_valid(struct symbol *sym, const char *str) · line 557
Quoted 10 lines
scripts/kconfig/symbol.c +4
-2case S_HEX : -if (str[0 ] =='0' && (str[1 ] =='x' || str[1 ] =='X' )) - str +=2 ; +if (str[0 ] !='\0' && + !(str[0 ] =='0' && (str[1 ] =='x' || str[1 ] =='X' ))) +return false; + str +=2 ; ch = *str++; do { if (!isxdigit(ch))
I think that saying "hex" is enough to express that the value is to be interpreted in hexadecimal, so let's keep the 0x prefix optional. Kconfig prints enough warnings these days... ;)
Michal