From: David Laight <David.Laight@ACULAB.COM>
To: 'Andy Shevchenko' <andriy.shevchenko@linux.intel.com>,
Kees Cook <keescook@chromium.org>,
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>
Cc: 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 v2 3/3] kobject: Use return value of strreplace()
Date: Sun, 26 Mar 2023 13:37:37 +0000 [thread overview]
Message-ID: <55ddb6da555a408da801f56577845a09@AcuMS.aculab.com> (raw)
In-Reply-To: <20230323123704.37983-4-andriy.shevchenko@linux.intel.com>
From: Andy Shevchenko
> Sent: 23 March 2023 12:37
>
> Since strreplace() returns the pointer to the string itself,
> we may use it directly in the code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> lib/kobject.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/kobject.c b/lib/kobject.c
> index f79a434e1231..16d530f9c174 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -281,8 +281,7 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
> kfree_const(s);
> if (!t)
> return -ENOMEM;
> - strreplace(t, '/', '!');
> - s = t;
> + s = strreplace(t, '/', '!');
Why do this? It just makes the code harder to read because
you have to know another 'silly fact' about a function.
Possibly useful return values might be:
1) The address of the first changed character.
2) The address of the last changed characher.
3) The '\0' terminator.
4) void.
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-26 13:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 12:37 [PATCH v2 0/3] lib/string_helpers et al.: Change return value of strreplace() Andy Shevchenko
2023-03-23 12:37 ` [PATCH v2 1/3] jbd2: Avoid printing outside the boundary of the buffer Andy Shevchenko
2023-03-23 12:37 ` [PATCH v2 2/3] lib/string_helpers: Change returned value of the strreplace() Andy Shevchenko
2023-03-23 12:37 ` [PATCH v2 3/3] kobject: Use return value of strreplace() Andy Shevchenko
2023-03-26 13:37 ` David Laight [this message]
2023-04-05 13:34 ` [PATCH v2 0/3] lib/string_helpers et al.: Change " Andy Shevchenko
2023-04-05 14:24 ` Greg Kroah-Hartman
2023-04-05 14:38 ` Andy Shevchenko
2023-04-06 2:58 ` Kees Cook
2023-06-05 14:04 ` Andy Shevchenko
2023-06-05 16:57 ` Greg Kroah-Hartman
2023-06-05 17:06 ` 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=55ddb6da555a408da801f56577845a09@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