mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: David Laight <David.Laight@aculab.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] string: implement streq()
Date: Wed, 5 Apr 2023 14:39:33 +0300	[thread overview]
Message-ID: <c68b346e-107f-4864-b13a-25a25acdb80d@p183> (raw)
In-Reply-To: <64f79f9610284091863ec8ce54660b85@AcuMS.aculab.com>

On Wed, Apr 05, 2023 at 10:45:36AM +0000, David Laight wrote:
> 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()...

It is obvious what it does.

      reply	other threads:[~2023-04-05 11:39 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
2023-04-05 11:39       ` Alexey Dobriyan [this message]

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=c68b346e-107f-4864-b13a-25a25acdb80d@p183 \
    --to=adobriyan@gmail.com \
    --cc=David.Laight@aculab.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®