public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mark Pearson <mpearson-lenovo@squebb.ca>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Mark Pearson <markpearson@lenovo.com>,
	Mark Gross <markgross@kernel.org>
Subject: Re: [PATCH v1 2/2] platform/x86: think-lmi: Use strreplace() to replace a character by nul
Date: Mon, 18 Sep 2023 18:38:19 +0300	[thread overview]
Message-ID: <ZQhu647Bo9gsldIF@smile.fi.intel.com> (raw)
In-Reply-To: <c6caae28-01fc-2354-6c7a-3f515a0e1402@rasmusvillemoes.dk>

On Mon, Sep 18, 2023 at 04:48:40PM +0200, Rasmus Villemoes wrote:
> On 13/09/2023 11.27, Andy Shevchenko wrote:

> > -		p = strchrnul(value, ';');
> > -		*p = '\0';
> > +		strreplace(value, ';', '\0');
> 
> So how do you know that the string contains at most one ';'? Same for
> all the other replacements. If that's not guaranteed, this is not at all
> equivalent.
> 
> Or maybe the result is just used a normal string afterwards, and it
> doesn't matter at all how the content after the first ';' has been mangled?
> 
> It's certainly not obvious to me that this is correct, but of course I
> know nothing about this code.

If you read the comment and code slightly above you may get that this is not
a problem at all. There are no side effects as the part after first occurrence
of ; is not used and original string is NUL-terminated.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-09-18 16:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-13  9:27 [PATCH v1 1/2] platform/x86: think-lmi: Replace kstrdup() + strreplace() with kstrdup_and_replace() Andy Shevchenko
2023-09-13  9:27 ` [PATCH v1 2/2] platform/x86: think-lmi: Use strreplace() to replace a character by nul Andy Shevchenko
2023-09-13 13:17   ` Mark Pearson
2023-09-15 14:57   ` Ilpo Järvinen
2023-09-18 14:48   ` Rasmus Villemoes
2023-09-18 15:38     ` Andy Shevchenko [this message]
2023-09-13 13:15 ` [PATCH v1 1/2] platform/x86: think-lmi: Replace kstrdup() + strreplace() with kstrdup_and_replace() Mark Pearson
2023-09-15 14:57 ` Ilpo Järvinen
2023-09-18 12:30 ` Hans de Goede
2023-09-18 13:50   ` 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=ZQhu647Bo9gsldIF@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=markgross@kernel.org \
    --cc=markpearson@lenovo.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=platform-driver-x86@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