From: David Laight <David.Laight@ACULAB.COM>
To: 'Kees Cook' <keescook@chromium.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Cezary Rojewski <cezary.rojewski@intel.com>,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Theodore Ts'o <tytso@mit.edu>, Jan Kara <jack@suse.com>,
Andy Shevchenko <andy@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: RE: [PATCH v1 2/3] lib/string_helpers: Change returned value of the strreplace()
Date: Thu, 23 Mar 2023 22:23:11 +0000 [thread overview]
Message-ID: <989d091b100a4dfcbce0dce81b48e672@AcuMS.aculab.com> (raw)
In-Reply-To: <641b320b.a70a0220.2bb1d.30fc@mx.google.com>
From: Kees Cook
> Sent: 22 March 2023 16:51
>
> On Wed, Mar 22, 2023 at 04:12:05PM +0200, Andy Shevchenko wrote:
> > It's more useful to return the original string with strreplace(),
Won't that break anything that is using the result?
> I found the use of "original" confusing here and in the comments. This
> just returns arg 1, yes? i.e. it's not the original (unreplaced) string,
> but rather just the string itself.
>
> I agree, though, that's much more useful than a pointer to the end of
> the string.
If you want a pointer to the start of the string, you've
already got it.
Almost all the time you can do the assignment first.
But if you want a pointer to the end you'll need to scan it again.
I have a feeling that the reason many of the string functions
return the original pointer is a historic side effect of
the original implementation.
Going back to before C had a 'return' statement.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-03-23 22:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 14:12 [PATCH v1 0/3] lib/string_helpers et al.: Change return value of strreplace() Andy Shevchenko
2023-03-22 14:12 ` [PATCH v1 1/3] jbd2: Avoid printing out the boundary Andy Shevchenko
2023-03-22 16:45 ` kernel test robot
2023-03-23 9:53 ` Jan Kara
2023-03-23 12:27 ` Andy Shevchenko
2023-03-22 14:12 ` [PATCH v1 2/3] lib/string_helpers: Change returned value of the strreplace() Andy Shevchenko
2023-03-22 16:51 ` Kees Cook
2023-03-23 12:26 ` Andy Shevchenko
2023-03-23 22:23 ` David Laight [this message]
2023-03-22 14:12 ` [PATCH v1 3/3] kobject: Use return value of strreplace() Andy Shevchenko
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=989d091b100a4dfcbce0dce81b48e672@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.com \
--cc=keescook@chromium.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=tytso@mit.edu \
/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;
as well as URLs for NNTP newsgroup(s).