diff options
author | Andrew Burgess <aburgess@redhat.com> | 2021-12-29 11:53:49 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-01-04 10:28:19 +0000 |
commit | 926ac872e924e6618441f76917d58088d92dd11d (patch) | |
tree | 01d85e83aeaa509f7455d3577dc0591f57f8481d /gdbsupport | |
parent | e2c0cef94da679745201317a0da0228f0f50158b (diff) | |
download | gdb-926ac872e924e6618441f76917d58088d92dd11d.zip gdb-926ac872e924e6618441f76917d58088d92dd11d.tar.gz gdb-926ac872e924e6618441f76917d58088d92dd11d.tar.bz2 |
gdb: don't pass nullptr to sigwait
I tried building GDB on GNU/Hurd, and ran into this warning:
gdbsupport/scoped_ignore_signal.h:78:16: error: null argument where non-null required (argument 2) [-Werror=nonnull]
This is because in this commit:
commit 99624310dd82542c389c89c2e55d8cae36bb74e1
Date: Sun Jun 27 15:13:14 2021 -0400
gdb: fall back on sigpending + sigwait if sigtimedwait is not available
A call to sigwait was introduced that passes nullptr as the second
argument, this call is only reached if sigtimedwait is not supported.
The original patch was written for macOS, I assume on that target
passing nullptr as the second argument is fine.
On my GNU/Linux box, the man-page for sigwait doesn't mention that
nullptr is allowed for the second argument, so my assumption would be
that nullptr is not OK, and, if I change the '#ifdef
HAVE_SIGTIMEDWAIT' introduced by the above patch to '#if 0', and
rebuild on GNU/Linux, I see the same warning that I see on GNU/Hurd.
I propose that we stop passing nullptr as the second argument to
sigwait, and instead pass a valid int pointer. The value returned in
the int can then be used in an assert.
For testing, I (locally) made the change to the #ifdef I mentioned
above, compiled GDB, and ran the usual tests, this meant I was using
sigwait instead on sigtimedwait on GNU/Linux, I saw no regressions.
Diffstat (limited to 'gdbsupport')
-rw-r--r-- | gdbsupport/scoped_ignore_signal.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gdbsupport/scoped_ignore_signal.h b/gdbsupport/scoped_ignore_signal.h index eff240f..cb46812 100644 --- a/gdbsupport/scoped_ignore_signal.h +++ b/gdbsupport/scoped_ignore_signal.h @@ -75,7 +75,12 @@ public: sigpending (&pending); if (sigismember (&pending, Sig)) - sigwait (&set, nullptr); + { + int sig_found; + + sigwait (&set, &sig_found); + gdb_assert (sig_found == Sig); + } #endif } |