From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
linuxppc-dev@lists.ozlabs.org,
Michael Ellerman <mpe@ellerman.id.au>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH 3/5] powerpc/pseries: don't call strrchr() twice
Date: Tue, 4 Aug 2015 17:36:47 +0300 [thread overview]
Message-ID: <1438699009-112794-3-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1438699009-112794-1-git-send-email-andriy.shevchenko@linux.intel.com>
There is no need to call strrchr() second time. We already know that in that
case parent_path_len either 1 ("/foo") or bigger ("/foo/bar").
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/powerpc/platforms/pseries/of_helpers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c
index 2f363e3..027446a 100644
--- a/arch/powerpc/platforms/pseries/of_helpers.c
+++ b/arch/powerpc/platforms/pseries/of_helpers.c
@@ -23,7 +23,7 @@ struct device_node *pseries_of_derive_parent(const char *path)
if (!strcmp(path, "/"))
return ERR_PTR(-EINVAL);
- if (strrchr(path, '/') != path) {
+ if (parent_path_len > 1) {
parent_path = kmalloc(parent_path_len, GFP_KERNEL);
if (!parent_path)
return ERR_PTR(-ENOMEM);
--
2.4.6
next prev parent reply other threads:[~2015-08-04 14:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 14:36 [PATCH 1/5] powerpc/pseries: extract of_helpers module Andy Shevchenko
2015-08-04 14:36 ` [PATCH 2/5] powerpc/pseries: fix a potential memory leak Andy Shevchenko
2015-08-04 14:36 ` Andy Shevchenko [this message]
2015-08-04 14:36 ` [PATCH 4/5] powerpc/pseries: replace kmalloc + strlcpy Andy Shevchenko
2015-08-04 14:36 ` [PATCH 5/5] powerpc/pseries: re-use code from of_helpers module Andy Shevchenko
2015-08-05 5:20 ` [PATCH 1/5] powerpc/pseries: extract " Segher Boessenkool
2015-08-05 9:32 ` Andy Shevchenko
2015-08-05 17:20 ` Segher Boessenkool
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=1438699009-112794-3-git-send-email-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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).