mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Michael Lentine <mlentine@google.com>, Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] tools: perf: prefer clarity in setup_pager
Date: Sun,  6 Jul 2014 19:42:11 +0200	[thread overview]
Message-ID: <1404668531-31550-1-git-send-email-mina86@mina86.com> (raw)

“!(pager || access(…))” is indeed pretty smart way to write
“!pager && access(…) == 0” but other than being clever it gives
no advantages and merely confuses the reader who needs to wonder
what is actually going on.

As such, replace the checks with much cleaner ones.

Also, while at it, merge the lest “!pager” test with the next
test that yields true after the “!pager” if's body is executed.
---
 tools/perf/util/pager.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c
index 31ee02d..14da1b0 100644
--- a/tools/perf/util/pager.c
+++ b/tools/perf/util/pager.c
@@ -57,13 +57,11 @@ void setup_pager(void)
 	}
 	if (!pager)
 		pager = getenv("PAGER");
-	if (!(pager || access("/usr/bin/pager", X_OK)))
+	if (!pager && access("/usr/bin/pager", X_OK) == 0)
 		pager = "/usr/bin/pager";
-	if (!(pager || access("/usr/bin/less", X_OK)))
+	if (!pager && access("/usr/bin/less", X_OK) == 0)
 		pager = "/usr/bin/less";
-	if (!pager)
-		pager = "cat";
-	if (!*pager || !strcmp(pager, "cat"))
+	if (!pager || !*pager || !strcmp(pager, "cat"))
 		return;
 
 	spawned_pager = 1; /* means we are emitting to terminal */
-- 
2.0.0.526.g5318336


             reply	other threads:[~2014-07-06 17:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-06 17:42 Michal Nazarewicz [this message]
     [not found] ` <CAB1dqC7BqsaDtXVYx24M5R9eaY7ZfpEtu3bxbJHXNHYhAbJETg@mail.gmail.com>
2014-07-07  5:49   ` Stephane Eranian
2014-07-07 12:32   ` Michal Nazarewicz

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=1404668531-31550-1-git-send-email-mina86@mina86.com \
    --to=mina86@mina86.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mlentine@google.com \
    /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

all inboxes | Powered by JetHome®