From: "Jan Beulich" Subject: Re: [PATCH v2 1/2] cmdline_parse: Convert no- prefix into =no for OPT_CUSTOM Date: Wed, 30 Jul 2014 08:58:13 +0100 Message-ID: <53D8C1B50200007800027886@mail.emea.novell.com> References: <1406663869-31522-1-git-send-email-dslutz@verizon.com> <1406663869-31522-2-git-send-email-dslutz@verizon.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartC3F14585.2__=" Return-path: In-Reply-To: <1406663869-31522-2-git-send-email-dslutz@verizon.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Don Slutz Cc: Keir Fraser , Ian Campbell , Andrew Cooper , Tim Deegan , xen-devel@lists.xen.org, Ian Jackson List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartC3F14585.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline >>> On 29.07.14 at 21:57, wrote: > This allows converting OPT_BOOL into OPT_CUSTOM and still do what is > expected. >=20 > Note: if both no- and =3D provided, pass provided =3D if not a zero > length string. Also log a warning about this. >=20 > Signed-off-by: Don Slutz > --- > xen/common/kernel.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) >=20 > diff --git a/xen/common/kernel.c b/xen/common/kernel.c > index 7e83353..9857159 100644 > --- a/xen/common/kernel.c > +++ b/xen/common/kernel.c > @@ -135,7 +135,20 @@ void __init cmdline_parse(const char *cmdline) > parse_size_and_unit(optval, NULL)); > break; > case OPT_CUSTOM: > - ((void (*)(const char *))param->var)(optval); > + if ( !bool_assert ) > + { > + if ( *optval ) > + { > + printk(XENLOG_WARNING > + "Warning: ignored no- prefix for = %s=3D%s\n", > + param->name, optval); Log messages printed before the consoles get initialized are of limited value (they would only show up in "xl dmesg" or equivalent output). Therefore I'm not really certain this is worthwhile. > + ((void (*)(const char *))param->var)(optval); > + } > + else > + ((void (*)(const char *))param->var)("no"); > + } > + else > + ((void (*)(const char *))param->var)(optval); Considering this repeated cast I'd prefer coding this quite differently, not the least because you also can't pass a literal "no" to the parsing functions (as they're permitted to alter the string), and at once also ignoring bogus "no-=3D" options instead of trying to assign a (perhaps unexpected) meaning: convert "no-" command line option prefix into "=3Dno" for OPT_CUSTOM ... to allow restoring/retaining previous behavior for options getting converted from boolean to custom. Reported-by: Don Slutz Signed-off-by: Jan Beulich --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -135,6 +135,13 @@ void __init cmdline_parse(const char *cm parse_size_and_unit(optval, NULL)); break; case OPT_CUSTOM: + if ( !bool_assert ) + { + if ( *optval ) + break; + safe_strcpy(opt, "no"); + optval =3D opt; + } ((void (*)(const char *))param->var)(optval); break; default: --=__PartC3F14585.2__= Content-Type: text/plain; name="cmdline-with-no-prefix.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="cmdline-with-no-prefix.patch" convert "no-" command line option prefix into "=3Dno" for OPT_CUSTOM=0A=0A.= .. to allow restoring/retaining previous behavior for options getting=0Acon= verted from boolean to custom.=0A=0AReported-by: Don Slutz =0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/common= /kernel.c=0A+++ b/xen/common/kernel.c=0A@@ -135,6 +135,13 @@ void __init = cmdline_parse(const char *cm=0A parse_size_and_unit(opt= val, NULL));=0A break;=0A case OPT_CUSTOM:=0A+ = if ( !bool_assert )=0A+ {=0A+ = if ( *optval )=0A+ break;=0A+ = safe_strcpy(opt, "no");=0A+ optval =3D opt;=0A+ = }=0A ((void (*)(const char *))param->var)(optval);= =0A break;=0A default:=0A --=__PartC3F14585.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartC3F14585.2__=--