From: David Laight <David.Laight@ACULAB.COM>
To: 'Alexey Dobriyan' <adobriyan@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] string: implement streq()
Date: Wed, 5 Apr 2023 10:45:36 +0000 [thread overview]
Message-ID: <64f79f9610284091863ec8ce54660b85@AcuMS.aculab.com> (raw)
In-Reply-To: <db6ce106-a5fc-4742-a59e-ccbd39dfd69d@p183>
From: Alexey Dobriyan
> Sent: 04 April 2023 15:55
>
> On Mon, Apr 03, 2023 at 02:16:41PM -0700, Andrew Morton wrote:
> > On Sat, 1 Apr 2023 20:48:05 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:
> >
> > > Most of the time strcmp() is being used, strings are checked for equality.
> > > Add wrapper to relay such intent (it is shorter to type, too).
> > >
> > > Use
> > > if (streq(s, "s")) {
> > > }
> > > or
> > > if (!streq(s, "s")) {
> > > }
> >
> > Gee, do we really want this? I mean, we all know how strcmp() works,
> > don't we?
> >
> > I'm thinking it would be better to remove the various cute little
> > streq() macros and open-code strcmp(...)==0.
>
> No! It's cool, trust me. Try it out, you'll like it.
> We "know" how strcmp() works because C didn't have streq() from
> the very beginning.
>
> strcmp() is only for insertion into trees. Half of the time you need
> to read to the end of the expression to know if it is check for equality
> or inequality. With streq(), you don't.
Instead you have to go away and look up what a function
you've never heard of does.
Live with strcmp()...
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-04-05 10:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-01 17:48 Alexey Dobriyan
2023-04-03 21:16 ` Andrew Morton
2023-04-04 14:54 ` Alexey Dobriyan
2023-04-05 10:45 ` David Laight [this message]
2023-04-05 11:39 ` Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64f79f9610284091863ec8ce54660b85@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®