[PATCH:xpr] Use strncmp() instead of bcmp() to compare string subsets

Alan Coopersmith alan.coopersmith at oracle.com
Tue Aug 12 17:16:17 PDT 2014


On 08/ 8/14 07:30 AM, Matthieu Herrb wrote:
> On 08/08/2014 04:51 AM, Alan Coopersmith wrote:
>> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
>
> Hi,
>
> Here it seems to me that strcmp() would be safe. While it changes the behaviour
> a bit, it seems more logical to only accept exact matches on the options (and
> not anything with random suffixes after the initial option name).

I'd not considered changing the behavior, but I've also never really liked this
pattern of accepting substrings and hoping no one needs an option that overlaps
in the future.   (You'll note when I added "-version" I made it a full match, so
no one could write scripts expecting "-ver" to work and then break if "-verbose"
is ever added.)

> Moreover I got bored by the useless micro-optimisations of the option parser and
> removed them.
>
> What do you think of the attached patch instead?

Works for me, and no one else seems to be complaining about it.

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list