From: "Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
y.karadz@gmail.com,
"Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
Subject: [PATCH v3 2/3] trace-cmd: Remove the die() call from read_proc()
Date: Tue, 16 Jan 2018 09:47:43 +0200 [thread overview]
Message-ID: <20180116074744.5522-3-vladislav.valtchev@gmail.com> (raw)
In-Reply-To: <20180116074744.5522-1-vladislav.valtchev@gmail.com>
As trace-stack.c's read_proc() function is going to be used by trace-cmd stat,
we don't want it to make the program die in case something went wrong.
Therefore, this simple patch makes read_proc() to just return -1 in case the
proc file was empty or read() failed with an error, instead of using die().
Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@gmail.com>
---
trace-stack.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/trace-stack.c b/trace-stack.c
index c1058ca..d55d994 100644
--- a/trace-stack.c
+++ b/trace-stack.c
@@ -79,9 +79,9 @@ static int read_proc(int *status)
n = read(fd, buf, sizeof(buf));
- /* We assume that the file is never empty we got no errors. */
+ /* The file was empty or read() failed with an error. */
if (n <= 0)
- die("error reading %s", PROC_FILE);
+ return -1;
/* Does this file have more than 63 characters?? */
if (n >= sizeof(buf))
--
2.14.1
next prev parent reply other threads:[~2018-01-16 7:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-16 7:47 [PATCH v3 0/3] Integrate stack tracer status in 'stat' Vladislav Valtchev (VMware)
2018-01-16 7:47 ` [PATCH v3 1/3] trace-cmd: Make read_proc() to return int status via OUT arg Vladislav Valtchev (VMware)
2018-01-16 17:19 ` Steven Rostedt
2018-01-16 19:10 ` Vladislav Valtchev
2018-01-16 19:42 ` Steven Rostedt
2018-01-16 17:30 ` Steven Rostedt
2018-01-16 7:47 ` Vladislav Valtchev (VMware) [this message]
2018-01-16 7:47 ` [PATCH v3 3/3] trace-cmd: Making stat to report when the stack tracer is ON Vladislav Valtchev (VMware)
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=20180116074744.5522-3-vladislav.valtchev@gmail.com \
--to=vladislav.valtchev@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=y.karadz@gmail.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®