qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Namhyung Kim <namhyung@gmail.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 1/4] trace: Simplify find_debugfs()
Date: Mon, 18 Dec 2017 14:47:57 +0000	[thread overview]
Message-ID: <20171218144800.27337-2-stefanha@redhat.com> (raw)
In-Reply-To: <20171218144800.27337-1-stefanha@redhat.com>

From: Namhyung Kim <namhyung@gmail.com>

The return vale of find_debugfs() is 1 if it could find a mount point of
debugfs.  It can be saved in the while loop instead of checking it again.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 trace/ftrace.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/trace/ftrace.c b/trace/ftrace.c
index 7de104deba..bfa38e71f0 100644
--- a/trace/ftrace.c
+++ b/trace/ftrace.c
@@ -19,6 +19,7 @@ static int find_debugfs(char *debugfs)
 {
     char type[100];
     FILE *fp;
+    int ret = 0;
 
     fp = fopen("/proc/mounts", "r");
     if (fp == NULL) {
@@ -28,15 +29,13 @@ static int find_debugfs(char *debugfs)
     while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
                   debugfs, type) == 2) {
         if (strcmp(type, "debugfs") == 0) {
+            ret = 1;
             break;
         }
     }
     fclose(fp);
 
-    if (strcmp(type, "debugfs") != 0) {
-        return 0;
-    }
-    return 1;
+    return ret;
 }
 
 bool ftrace_init(void)
-- 
2.14.3

  reply	other threads:[~2017-12-18 14:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-18 14:47 [Qemu-devel] [PULL 0/4] Tracing patches Stefan Hajnoczi
2017-12-18 14:47 ` Stefan Hajnoczi [this message]
2017-12-18 14:47 ` [Qemu-devel] [PULL 2/4] trace: Generalize searching for debugfs Stefan Hajnoczi
2017-12-18 14:47 ` [Qemu-devel] [PULL 3/4] trace: Try using tracefs first Stefan Hajnoczi
2017-12-18 14:48 ` [Qemu-devel] [PULL 4/4] gdbstub: add tracing Stefan Hajnoczi
2017-12-19 12:48 ` [Qemu-devel] [PULL 0/4] Tracing patches Peter Maydell

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=20171218144800.27337-2-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=namhyung@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).