aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/kernel.c
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2010-11-19 13:25:54 +0000
committerKeir Fraser <keir@xen.org>2010-11-19 13:25:54 +0000
commit4c776a32dc059c922e4039ff8f2f4c867e6f5af2 (patch)
tree078f37a2600649236fa4bbe8e5fa58bba2098f95 /xen/common/kernel.c
parenta1650a41d7ab6ca2a56e93036a08b310ebe195d7 (diff)
downloadxen-4c776a32dc059c922e4039ff8f2f4c867e6f5af2.tar.gz
xen-4c776a32dc059c922e4039ff8f2f4c867e6f5af2.tar.bz2
xen-4c776a32dc059c922e4039ff8f2f4c867e6f5af2.zip
consolidate custom parameter parsing routines looking for boolean values
Have a single function for this, rather than doing the same in half a dozen places. Signed-off-by: Jan Beulich <jbeulich@novell.com>
Diffstat (limited to 'xen/common/kernel.c')
-rw-r--r--xen/common/kernel.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 96a55318f2..0bc954c1aa 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -26,7 +26,7 @@ int tainted;
xen_commandline_t saved_cmdline;
-void cmdline_parse(char *cmdline)
+void __init cmdline_parse(char *cmdline)
{
char opt[100], *optval, *optkey, *q;
const char *p = cmdline;
@@ -83,10 +83,7 @@ void cmdline_parse(char *cmdline)
break;
case OPT_BOOL:
case OPT_INVBOOL:
- if ( !strcmp("no", optval) ||
- !strcmp("off", optval) ||
- !strcmp("false", optval) ||
- !strcmp("0", optval) )
+ if ( !parse_bool(optval) )
bool_assert = !bool_assert;
if ( param->type == OPT_INVBOOL )
bool_assert = !bool_assert;
@@ -115,6 +112,25 @@ void cmdline_parse(char *cmdline)
}
}
+int __init parse_bool(const char *s)
+{
+ if ( !strcmp("no", s) ||
+ !strcmp("off", s) ||
+ !strcmp("false", s) ||
+ !strcmp("disable", s) ||
+ !strcmp("0", s) )
+ return 0;
+
+ if ( !strcmp("yes", s) ||
+ !strcmp("on", s) ||
+ !strcmp("true", s) ||
+ !strcmp("enable", s) ||
+ !strcmp("1", s) )
+ return 1;
+
+ return -1;
+}
+
/**
* print_tainted - return a string to represent the kernel taint state.
*