From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests 09/15] lib/argv: fix coding style Date: Fri, 13 Jan 2017 19:15:27 +0100 Message-ID: <20170113181533.15145-10-drjones@redhat.com> References: <20170113181533.15145-1-drjones@redhat.com> Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, thuth@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58278 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbdAMSPu (ORCPT ); Fri, 13 Jan 2017 13:15:50 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A22161BAE for ; Fri, 13 Jan 2017 18:15:51 +0000 (UTC) In-Reply-To: <20170113181533.15145-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: The next patch will double the amount of code in the file, so let's fix its coding style first. No functional change. Signed-off-by: Andrew Jones --- lib/argv.c | 55 ++++++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/lib/argv.c b/lib/argv.c index 482ed004ee64..fe8826255c18 100644 --- a/lib/argv.c +++ b/lib/argv.c @@ -8,49 +8,46 @@ char *__args; static char args_copy[1000]; static char *copy_ptr = args_copy; -static bool isblank(char p) -{ - return p == ' ' || p == '\t'; -} +#define isblank(c) ((c) == ' ' || (c) == '\t') static char *skip_blanks(char *p) { - while (isblank(*p)) - ++p; - return p; + while (isblank(*p)) + ++p; + return p; } void __setup_args(void) { - char *args = __args; - char **argv = __argv + __argc; - - while (*(args = skip_blanks(args)) != '\0') { - *argv++ = copy_ptr; - while (*args != '\0' && !isblank(*args)) - *copy_ptr++ = *args++; - *copy_ptr++ = '\0'; - } - __argc = argv - __argv; + char *args = __args; + char **argv = __argv + __argc; + + while (*(args = skip_blanks(args)) != '\0') { + *argv++ = copy_ptr; + while (*args != '\0' && !isblank(*args)) + *copy_ptr++ = *args++; + *copy_ptr++ = '\0'; + } + __argc = argv - __argv; } void setup_args(char *args) { - if (!args) - return; + if (!args) + return; - __args = args; - __setup_args(); + __args = args; + __setup_args(); } void setup_args_progname(char *args) { - __argv[0] = copy_ptr; - strcpy(__argv[0], auxinfo.progname); - copy_ptr += strlen(auxinfo.progname) + 1; - ++__argc; - if (args) { - __args = args; - __setup_args(); - } + __argv[0] = copy_ptr; + strcpy(__argv[0], auxinfo.progname); + copy_ptr += strlen(auxinfo.progname) + 1; + ++__argc; + if (args) { + __args = args; + __setup_args(); + } } -- 2.9.3