[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <70d98067245c4b4ebb411e68fb3162ef@AcuMS.aculab.com>
Date: Mon, 7 Dec 2020 16:25:17 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Steven Rostedt' <rostedt@...dmis.org>,
James Bottomley <James.Bottomley@...senPartnership.com>
CC: Ard Biesheuvel <ardb@...nel.org>,
"laniel_francis@...vacyrequired.com"
<laniel_francis@...vacyrequired.com>,
linux-efi <linux-efi@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: RE: [RFC PATCH v1 07/12] efi: Replace strstarts() by
str_has_prefix().
From: Steven Rostedt
> Sent: 07 December 2020 15:10
>
> On Sat, 05 Dec 2020 15:04:31 -0800
> James Bottomley <James.Bottomley@...senPartnership.com> wrote:
>
> > Well, I think the pattern
> >
> > if (strstarts(option, <string>)) {
> > ...
> > option += strlen(<same string>);
> >
> > is a bad one because one day <string> may get updated but not <same
> > string>. And if <same string> is too far away in the code it might not
> > even show up in the diff, leading to reviewers not noticing either. So
> > I think eliminating the pattern is a definite improvement.
>
> And one of the reasons we created str_has_prefix() is because we fixed that
> exact bug, in a few places.
>
> It was caused by a typo, where we had something like:
>
> strstarts(option, "foo=") {
> option += strlen("foo");
>
> and forgot the "=" part, and broke the rest of the logic.
And then someone else wonders whether the paint is the right colour.
Maybe the function should return the pointer to the character
after the prefix.
Suddenly you have a load of functions to pick from, none do
quite what you want - so you add yet another :-)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists