On 21/12/2018 12:13, Jan Beulich wrote:
>>>> On 21.12.18 at 00:40, <[email protected]> wrote:
>> @@ -271,6 +272,26 @@ int parse_boolean(const char *name, const char *s,
>> const char *e)
>> return -1;
>> }
>>
>> +int cmdline_strcmp(const char *frag, const char *name)
> __init ?
I think there are some runtime parameters in need of some fixing as well.
>
>> +{
>> + while ( 1 )
>> + {
>> + int res = (*frag - *name);
>> +
>> + if ( res || *name == '\0' )
>> + {
>> + /* NUL in 'name' matching punctuation in 'frag' implies
>> success. */
>> + if ( *name == '\0' && ispunct(*frag) )
>> + res = 0;
> Isn't ispunct() true for dashes and perhaps also underscores?
> I don't think it can be this generic, the more that ...
>
>> --- a/xen/include/xen/lib.h
>> +++ b/xen/include/xen/lib.h
>> @@ -79,6 +79,13 @@ int parse_bool(const char *s, const char *e);
>> */
>> int parse_boolean(const char *name, const char *s, const char *e);
>>
>> +/**
>> + * Very similar to strcmp(), but will declare a match if the NUL in 'name'
>> + * lines up with punctuationin 'frag'. Designed for picking exact string
>> + * matches out of a comma-separated command line fragment.
>> + */
>> +int cmdline_strcmp(const char *frag, const char *name);
> ... you talk of commas only here.
I actually borrowed this function from my CPUID cmdline patch. In 99%
of cases, we only need to match = and , but we have some other
parameters such as psr= which use : for delimiters, hence the use of
ispunct().
As an alternative, I could revert back to explicitly checking the
expected punctuation. It is not as if this is a fastpath.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel