From: Reinette Chatre <reinette.chatre@intel.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Fenghua Yu <fenghua.yu@intel.com>, Borislav Petkov <bp@alien8.de>,
Tony Luck <tony.luck@intel.com>,
kuo-lang.tseng@intel.com, Ingo Molnar <mingo@redhat.com>,
babu.moger@amd.com, "H. Peter Anvin" <hpa@zytor.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] x86/resctrl: Use appropriate API for strings terminated by newline
Date: Fri, 3 Apr 2020 08:35:49 -0700 [thread overview]
Message-ID: <13499ebf-dd5f-1940-3d01-366f038d5a66@intel.com> (raw)
In-Reply-To: <CAHp75VdoVxDaBYtiH8D_0DLKcwP7AAS2M7XoyrDj7LAv8cOoDA@mail.gmail.com>
Hi Andy,
On 4/3/2020 12:27 AM, Andy Shevchenko wrote:
> On Fri, Apr 3, 2020 at 12:54 AM Reinette Chatre
> <reinette.chatre@intel.com> wrote:
>> On 4/2/2020 6:06 AM, Andy Shevchenko wrote:
>>> On Wed, Apr 01, 2020 at 11:30:48AM -0700, Reinette Chatre wrote:
...
>>>> /* Valid input requires a trailing newline */
>>>> if (nbytes == 0 || buf[nbytes - 1] != '\n')
>>>> return -EINVAL;
>>>> - buf[nbytes - 1] = '\0';
>>>
>>> The above test is not needed and comment now is misleading.
>>> WRT nbytes I believe that kernel fs code checks for that.
>
> This module provides it's own kernfs_ops...
>
>> If nbytes is 0 it is still passed to this function. You are correct that
>> those tests are not needed though (if nbytes is 0 then
>> sysfs_match_string() will not find a match and return EINVAL via that path).
>>
>> Thank you for catching this. I'll remove those unnecessary checks.
>
> ...which means that nbytes == 0 is a valid check. Please keep it
> there. It will protect from unnecessary locking and loading CPU for
> nothing.
>
Will do. Thank you.
Reinette
prev parent reply other threads:[~2020-04-03 15:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 18:30 [PATCH 0/2] x86/resctrl: Enable user to view and select thread throttling mode Reinette Chatre
2020-04-01 18:30 ` [PATCH 1/2] " Reinette Chatre
2020-04-01 18:30 ` [PATCH 2/2] x86/resctrl: Use appropriate API for strings terminated by newline Reinette Chatre
2020-04-02 13:06 ` Andy Shevchenko
2020-04-02 19:35 ` Andy Shevchenko
2020-04-02 21:19 ` Reinette Chatre
2020-04-03 7:27 ` Andy Shevchenko
2020-04-03 15:35 ` Reinette Chatre [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=13499ebf-dd5f-1940-3d01-366f038d5a66@intel.com \
--to=reinette.chatre@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=kuo-lang.tseng@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).