[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 01/53] xen: add an optional string end parameter to parse_bool()
Add a parameter to parse_bool() to specify the end of the to be parsed string. Specifying it as NULL will preserve the current behavior to parse until the end of the input string, while passing a non-NULL pointer will specify the first character after the input string. This will allow to parse boolean sub-strings without having to write a NUL byte into the input string. Modify all users of parse_bool() to pass NULL for the new parameter. Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Julien Grall <julien.grall@xxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Cc: Tim Deegan <tim@xxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Kevin Tian <kevin.tian@xxxxxxxxx> Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- xen/arch/arm/acpi/boot.c | 2 +- xen/arch/x86/cpu/vpmu.c | 2 +- xen/arch/x86/mm.c | 2 +- xen/arch/x86/nmi.c | 2 +- xen/arch/x86/psr.c | 2 +- xen/arch/x86/setup.c | 6 +++--- xen/arch/x86/x86_64/mmconfig-shared.c | 2 +- xen/common/kernel.c | 28 ++++++++++++++++------------ xen/drivers/char/console.c | 2 +- xen/drivers/cpufreq/cpufreq.c | 2 +- xen/drivers/passthrough/iommu.c | 2 +- xen/drivers/passthrough/vtd/quirks.c | 2 +- xen/include/xen/lib.h | 2 +- 13 files changed, 30 insertions(+), 26 deletions(-) diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c index 889208a0ea..a5a6f55f0e 100644 --- a/xen/arch/arm/acpi/boot.c +++ b/xen/arch/arm/acpi/boot.c @@ -199,7 +199,7 @@ static void __init parse_acpi_param(char *arg) return; /* Interpret the parameter for use within Xen. */ - if ( !parse_bool(arg) ) + if ( !parse_bool(arg, NULL) ) param_acpi_off = true; else if ( !strcmp(arg, "force") ) /* force ACPI to be enabled */ param_acpi_force = true; diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c index 90954ca884..1c0ea10777 100644 --- a/xen/arch/x86/cpu/vpmu.c +++ b/xen/arch/x86/cpu/vpmu.c @@ -80,7 +80,7 @@ static void __init parse_vpmu_params(char *s) { char *sep, *p = s; - switch ( parse_bool(s) ) + switch ( parse_bool(s, NULL) ) { case 0: break; diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index ed77270586..5b0e55d7d9 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -184,7 +184,7 @@ static void __init parse_mmio_relax(const char *s) if ( !*s ) opt_mmio_relax = 1; else - opt_mmio_relax = parse_bool(s); + opt_mmio_relax = parse_bool(s, NULL); if ( opt_mmio_relax < 0 && strcmp(s, "all") ) opt_mmio_relax = 0; } diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index 8914581f66..e44f88045e 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -54,7 +54,7 @@ static void __init parse_watchdog(char *s) return; } - switch ( parse_bool(s) ) + switch ( parse_bool(s, NULL) ) { case 0: opt_watchdog = false; diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index c2036cbed4..25a85b65b2 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -427,7 +427,7 @@ static void __init parse_psr_bool(char *s, char *value, char *feature, opt_psr |= mask; else { - int val_int = parse_bool(value); + int val_int = parse_bool(value, NULL); if ( val_int == 0 ) opt_psr &= ~mask; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index db5df6956d..414681d5a1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -110,7 +110,7 @@ static void __init parse_smep_param(char *s) return; } - switch ( parse_bool(s) ) + switch ( parse_bool(s, NULL) ) { case 0: opt_smep = 0; @@ -136,7 +136,7 @@ static void __init parse_smap_param(char *s) return; } - switch ( parse_bool(s) ) + switch ( parse_bool(s, NULL) ) { case 0: opt_smap = 0; @@ -160,7 +160,7 @@ static void __init parse_acpi_param(char *s) safe_strcpy(acpi_param, s); /* Interpret the parameter for use within Xen. */ - if ( !parse_bool(s) ) + if ( !parse_bool(s, NULL) ) { disable_acpi(); } diff --git a/xen/arch/x86/x86_64/mmconfig-shared.c b/xen/arch/x86/x86_64/mmconfig-shared.c index 488470bfeb..dbf9ff07fa 100644 --- a/xen/arch/x86/x86_64/mmconfig-shared.c +++ b/xen/arch/x86/x86_64/mmconfig-shared.c @@ -37,7 +37,7 @@ static void __init parse_mmcfg(char *s) if ( ss ) *ss = '\0'; - if ( !parse_bool(s) ) + if ( !parse_bool(s, NULL) ) pci_probe &= ~PCI_PROBE_MMCONF; else if ( !strcmp(s, "amd_fam10") || !strcmp(s, "amd-fam10") ) pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF; diff --git a/xen/common/kernel.c b/xen/common/kernel.c index ce7cb8adb5..4979e1c49b 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -114,7 +114,7 @@ static void __init _cmdline_parse(const char *cmdline) simple_strtoll(optval, NULL, 0)); break; case OPT_BOOL: - if ( !parse_bool(optval) ) + if ( !parse_bool(optval, NULL) ) bool_assert = !bool_assert; assign_integer_param(param, bool_assert); break; @@ -163,20 +163,24 @@ void __init cmdline_parse(const char *cmdline) #endif } -int __init parse_bool(const char *s) +int __init parse_bool(const char *s, const char *e) { - if ( !strcmp("no", s) || - !strcmp("off", s) || - !strcmp("false", s) || - !strcmp("disable", s) || - !strcmp("0", s) ) + unsigned int len; + + len = e ? e - s : strlen(s); + + if ( !strncmp("no", s, len) || + !strncmp("off", s, len) || + !strncmp("false", s, len) || + !strncmp("disable", s, len) || + !strncmp("0", s, len) ) return 0; - if ( !strcmp("yes", s) || - !strcmp("on", s) || - !strcmp("true", s) || - !strcmp("enable", s) || - !strcmp("1", s) ) + if ( !strncmp("yes", s, len) || + !strncmp("on", s, len) || + !strncmp("true", s, len) || + !strncmp("enable", s, len) || + !strncmp("1", s, len) ) return 1; return -1; diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index f0659fba1b..8f2a24496a 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -605,7 +605,7 @@ static int printk_prefix_check(char *p, char **pp) static void __init parse_console_timestamps(char *s) { - switch ( parse_bool(s) ) + switch ( parse_bool(s, NULL) ) { case 0: opt_con_timestamp_mode = TSM_NONE; diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c index fd82ef5dce..5580bd370d 100644 --- a/xen/drivers/cpufreq/cpufreq.c +++ b/xen/drivers/cpufreq/cpufreq.c @@ -69,7 +69,7 @@ static void __init setup_cpufreq_option(char *str) if ( arg ) *arg++ = '\0'; - choice = parse_bool(str); + choice = parse_bool(str, NULL); if ( choice < 0 && !strcmp(str, "dom0-kernel") ) { diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 5e81813942..f1aefc47ce 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -92,7 +92,7 @@ static void __init parse_iommu_param(char *s) if ( ss ) *ss = '\0'; - if ( !parse_bool(s) ) + if ( !parse_bool(s, NULL) ) iommu_enable = 0; else if ( !strcmp(s, "force") || !strcmp(s, "required") ) force_iommu = val; diff --git a/xen/drivers/passthrough/vtd/quirks.c b/xen/drivers/passthrough/vtd/quirks.c index 5bbbd96d51..d6dd671dbf 100644 --- a/xen/drivers/passthrough/vtd/quirks.c +++ b/xen/drivers/passthrough/vtd/quirks.c @@ -251,7 +251,7 @@ static void __init parse_snb_timeout(const char *s) { int t; - t = parse_bool(s); + t = parse_bool(s, NULL); if ( t < 0 ) { if ( *s == '\0' ) diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 995a85a7db..8e57bbd021 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -71,7 +71,7 @@ struct domain; void cmdline_parse(const char *cmdline); -int parse_bool(const char *s); +int parse_bool(const char *s, const char *e); /*#define DEBUG_TRACE_DUMP*/ #ifdef DEBUG_TRACE_DUMP -- 2.12.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |