Re: [PATCH v2 2/3] trace-cmd: Remove the die() call from read_proc()

From: Vladislav Valtchev
Date: Tue Jan 16 2018 - 10:05:00 EST


On Fri, 2018-01-12 at 10:43 -0500, Steven Rostedt wrote:
>
> But you need to handle the error cases for the users of read_proc().
> From the previous patch:
>
> static void change_stack_tracer_status(int new_status)
> {
> char buf[1];
> int status;
> int fd;
> int n;
>
> if (read_proc(&status) > 0 && status == new_status)
> return; /* nothing to do */
>
> We should not continue if read_proc() fails. Should move the die here:
>
> ret = read_proc(&status);
> if (ret < 0)
> die("error reading %s", PROC_FILE);
>
> if (ret > 0 && status == new_status)
> return; /* nothing to do */
>
> -- Steve
>

You're totally right. I overlooked at this detail.

--
Vladislav Valtchev
VMware Open Source Technology Center