From: Pavel Machek <pavel@ucw.cz>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/12] power: Replace strncmp with str_has_prefix
Date: Mon, 29 Jul 2019 21:15:12 +0200 [thread overview]
Message-ID: <20190729191511.GB2023@amd> (raw)
In-Reply-To: <20190729151454.9606-1-hslester96@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1208 bytes --]
On Mon 2019-07-29 23:14:54, Chuhong Yuan wrote:
> strncmp(str, const, len) is error-prone.
> We had better use newly introduced
> str_has_prefix() instead of it.
>
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
> kernel/power/hibernate.c | 8 ++++----
> kernel/power/main.c | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> index cd7434e6000d..49d4bfdb2b67 100644
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -1188,15 +1188,15 @@ static int __init resume_offset_setup(char *str)
>
> static int __init hibernate_setup(char *str)
> {
> - if (!strncmp(str, "noresume", 8)) {
> + if (str_has_prefix(str, "noresume")) {
> noresume = 1;
> - } else if (!strncmp(str, "nocompress", 10)) {
> + } else if (str_has_prefix(str, "nocompress")) {
> nocompress = 1;
Ok, old code is bad, too... but this makes the error visible. We do
not want "noresumenextmonday" to set noresume = 1, right?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2019-07-29 19:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 15:14 [PATCH 07/12] power: Replace strncmp with str_has_prefix Chuhong Yuan
2019-07-29 19:15 ` Pavel Machek [this message]
2019-08-01 8:07 ` Chuhong Yuan
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=20190729191511.GB2023@amd \
--to=pavel@ucw.cz \
--cc=hslester96@gmail.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/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).