* [PATCH] [virt-server] trace-cmd: Fix a minor bug in `trace-cmd listen`
@ 2018-09-21 12:46 Slavomir Kaslev
2018-09-21 13:32 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Slavomir Kaslev @ 2018-09-21 12:46 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel
There is a potential bug caused by C's operator precedence when checking
the flags set by `poll` in `trace-cmd listen`:
if (!fds[i].revents & POLLIN)
continue;
vs
if (!(fds[i].revents & POLLIN))
continue;
Curiously enough, the bug doesn't manifest itself since POLLIN is equal
to 1 and `trace-cmd listen` waits only for read events so no other flags
will be set by `poll`.
Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
---
tracecmd/trace-listen.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tracecmd/trace-listen.c b/tracecmd/trace-listen.c
index 7bc723e..c05c2d8 100644
--- a/tracecmd/trace-listen.c
+++ b/tracecmd/trace-listen.c
@@ -2020,7 +2020,7 @@ static void do_accept_loop(int nfd, int vfd, int mfd)
continue;
}
- if (!fds[i].revents & POLLIN)
+ if (!(fds[i].revents & POLLIN))
continue;
if (i < FD_CONNECTED) {
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [virt-server] trace-cmd: Fix a minor bug in `trace-cmd listen`
2018-09-21 12:46 [PATCH] [virt-server] trace-cmd: Fix a minor bug in `trace-cmd listen` Slavomir Kaslev
@ 2018-09-21 13:32 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2018-09-21 13:32 UTC (permalink / raw)
To: Slavomir Kaslev; +Cc: linux-trace-devel
On Fri, 21 Sep 2018 15:46:17 +0300
Slavomir Kaslev <kaslevs@vmware.com> wrote:
> There is a potential bug caused by C's operator precedence when checking
> the flags set by `poll` in `trace-cmd listen`:
>
> if (!fds[i].revents & POLLIN)
> continue;
>
> vs
>
> if (!(fds[i].revents & POLLIN))
> continue;
>
Nice catch!
> Curiously enough, the bug doesn't manifest itself since POLLIN is equal
> to 1 and `trace-cmd listen` waits only for read events so no other flags
> will be set by `poll`.
Funny how it worked out that way. Probably why it wasn't caught before,
because if it didn't work out that way, it would have shown up quickly
and have been fixed!
-- Steve
>
> Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
> ---
> tracecmd/trace-listen.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tracecmd/trace-listen.c b/tracecmd/trace-listen.c
> index 7bc723e..c05c2d8 100644
> --- a/tracecmd/trace-listen.c
> +++ b/tracecmd/trace-listen.c
> @@ -2020,7 +2020,7 @@ static void do_accept_loop(int nfd, int vfd, int mfd)
> continue;
> }
>
> - if (!fds[i].revents & POLLIN)
> + if (!(fds[i].revents & POLLIN))
> continue;
>
> if (i < FD_CONNECTED) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-21 19:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-21 12:46 [PATCH] [virt-server] trace-cmd: Fix a minor bug in `trace-cmd listen` Slavomir Kaslev
2018-09-21 13:32 ` Steven Rostedt
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).