From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGa7T-0000c6-Ji for qemu-devel@nongnu.org; Thu, 20 Feb 2014 15:21:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGa7N-0005xY-Ju for qemu-devel@nongnu.org; Thu, 20 Feb 2014 15:21:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGa7N-0005xU-At for qemu-devel@nongnu.org; Thu, 20 Feb 2014 15:21:13 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1KKLBZp022097 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Feb 2014 15:21:12 -0500 Date: Thu, 20 Feb 2014 15:21:08 -0500 From: Jeff Cody Message-ID: <20140220202108.GH30664@localhost.localdomain> References: <1392908243-8835-1-git-send-email-kwolf@redhat.com> <1392908243-8835-2-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1392908243-8835-2-git-send-email-kwolf@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 1/6] qemu-option: Introduce has_help_option() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: mreitz@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, armbru@redhat.com On Thu, Feb 20, 2014 at 03:57:18PM +0100, Kevin Wolf wrote: > This new function checks if any help option ('help' or '?') occurs > anywhere in an option string, so that things like 'cluster_size=4k,help' > are recognised. > > Signed-off-by: Kevin Wolf Reviewed-by: Jeff Cody > --- > include/qemu/option.h | 1 + > util/qemu-option.c | 24 ++++++++++++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/include/qemu/option.h b/include/qemu/option.h > index 3ea871a..8d44167 100644 > --- a/include/qemu/option.h > +++ b/include/qemu/option.h > @@ -79,6 +79,7 @@ void parse_option_size(const char *name, const char *value, > void free_option_parameters(QEMUOptionParameter *list); > void print_option_parameters(QEMUOptionParameter *list); > void print_option_help(QEMUOptionParameter *list); > +bool has_help_option(const char *param); > > /* ------------------------------------------------------------------ */ > > diff --git a/util/qemu-option.c b/util/qemu-option.c > index 668e5d9..ce1eba8 100644 > --- a/util/qemu-option.c > +++ b/util/qemu-option.c > @@ -450,6 +450,30 @@ fail: > return NULL; > } > > +bool has_help_option(const char *param) > +{ > + size_t buflen = strlen(param) + 1; > + char *buf = g_malloc0(buflen); > + const char *p = param; > + bool result = false; > + > + while (*p) { > + p = get_opt_value(buf, buflen, p); > + if (*p) { > + p++; > + } > + > + if (is_help_option(buf)) { > + result = true; > + goto out; > + } > + } > + > +out: > + free(buf); > + return result; > +} > + > /* > * Prints all options of a list that have a value to stdout > */ > -- > 1.8.1.4 > >