From 2260adb1b956dcb2a526bf3eca5adc3fdeabf465 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Mon, 9 Jul 2012 09:25:15 -0700 Subject: [PATCH] Better arg checking for reboot command Allows 'reboot cold' as an alias for 'reboot hard', since I keep mis-typing that anyway. Returns error for any other option. ('reboot' by itself still does a warm reboot). BUG=none TEST=manual reboot -> does warm reboot reboot hard -> does hard reboot (reason = rtc alarm) reboot cold -> ditto reboot foo -> prints error Change-Id: I183714d4ba09abee3bd9a6f0d5df82389becf410 Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/26924 --- common/system_common.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/system_common.c b/common/system_common.c index 141abcfdb7..0792edcb68 100644 --- a/common/system_common.c +++ b/common/system_common.c @@ -652,9 +652,13 @@ static int command_reboot(int argc, char **argv) { int is_hard = 0; - if (argc == 2 && !strcasecmp(argv[1], "hard")) { - ccputs("Hard-"); - is_hard = 1; + if (argc == 2) { + if (!strcasecmp(argv[1], "hard") || + !strcasecmp(argv[1], "cold")) { + ccputs("Hard-"); + is_hard = 1; + } else + return EC_ERROR_PARAM1; } ccputs("Rebooting!\n\n\n");