From 101dc0ba83260db3a859cb7e9a54e257ee601d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 17 Dec 2021 20:19:35 +0100 Subject: [PATCH] strace: fix revents output for poll syscall each poll_fd struct should be checked, valid when not -1 and revents not zero. Change-Id: Ia624ad1369ad1a6066c9970a47cfac63fa773702 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4821 Reviewed-by: waddlesplash --- src/bin/debug/strace/NetworkTypes.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bin/debug/strace/NetworkTypes.cpp b/src/bin/debug/strace/NetworkTypes.cpp index a5411e7748..3a5d71c16f 100644 --- a/src/bin/debug/strace/NetworkTypes.cpp +++ b/src/bin/debug/strace/NetworkTypes.cpp @@ -134,11 +134,7 @@ format_signed_number(int32 value) static string read_pollfd(Context &context, void *data) { - nfds_t numfds = 0; - if (context.GetContents(Context::INPUT_VALUES)) - numfds = get_value(context.GetValue(context.GetSibling(1))); - else if (context.GetContents(Context::OUTPUT_VALUES)) - numfds = context.GetReturnValue(); + nfds_t numfds = get_value(context.GetValue(context.GetSibling(1))); if ((int64)numfds <= 0) return string(); @@ -157,6 +153,10 @@ read_pollfd(Context &context, void *data) r = "["; for (nfds_t i = 0; i < numfds && added < 8; i++) { + if ((tmp[i].fd == -1 || tmp[i].revents == 0) + && context.GetContents(Context::OUTPUT_VALUES)) { + continue; + } if (added > 0) r += ", "; r += "{fd=" + format_signed_number(tmp[i].fd); @@ -176,7 +176,7 @@ read_pollfd(Context &context, void *data) flags++; } } - if (tmp[i].fd != -1 && context.GetContents(Context::OUTPUT_VALUES)) { + if (context.GetContents(Context::OUTPUT_VALUES)) { r += ", revents="; int flags = 0; if ((tmp[i].revents & POLLIN) != 0) {