From 37567bd1bcd3be91f5d207919f5fe95d60983c89 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sun, 4 Jul 2010 13:32:20 +0300 Subject: [PATCH] kvm: Cleanup command line parsing Signed-off-by: Pekka Enberg --- tools/kvm/main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/kvm/main.c b/tools/kvm/main.c index e2e5d775b5f1..9002c0ff6d2b 100644 --- a/tools/kvm/main.c +++ b/tools/kvm/main.c @@ -34,6 +34,11 @@ static void handle_sigquit(int sig) static char real_cmdline[2048]; +static bool option_matches(char *arg, const char *option) +{ + return !strncmp(arg, option, strlen(option)); +} + int main(int argc, char *argv[]) { const char *kernel_filename = NULL; @@ -44,16 +49,16 @@ int main(int argc, char *argv[]) signal(SIGQUIT, handle_sigquit); for (i = 1; i < argc; i++) { - if (!strncmp("--kernel=", argv[i], 9)) { + if (option_matches(argv[i], "--kernel=")) { kernel_filename = &argv[i][9]; continue; - } else if (!strncmp("--params=", argv[i], 9)) { + } else if (option_matches(argv[i], "--params=")) { kernel_cmdline = &argv[i][9]; continue; - } else if (!strncmp("--dbgtest", argv[i], 9)) { + } else if (option_matches(argv[i], "--dbgtest")) { dbgtest_mode = 1; continue; - } else if (!strncmp("--single-step", argv[i], 13)) { + } else if (option_matches(argv[i], "--single-step")) { single_step = true; continue; } else { -- 2.39.5