[gjs: 2/5] maint: Avoid bogus cppcheck warning about one-definition rule
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/5] maint: Avoid bogus cppcheck warning about one-definition rule
- Date: Thu, 26 Aug 2021 04:18:10 +0000 (UTC)
commit 4ca9473d7c65f2ba45a469d58e8b905679d87abc
Author: Philip Chimento <philip chimento gmail com>
Date: Tue Aug 24 22:50:48 2021 -0700
maint: Avoid bogus cppcheck warning about one-definition rule
Normally I would prefer to wait for cppcheck to get fixed, but this error
is already in the codebase and is causing problems with the version of
cppcheck that we are using in CI. So work around it instead.
The cppcheck bug is tracked in https://trac.cppcheck.net/ticket/10431
modules/console.cpp | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/modules/console.cpp b/modules/console.cpp
index 2ef511aa..393aed59 100644
--- a/modules/console.cpp
+++ b/modules/console.cpp
@@ -90,10 +90,10 @@ public:
}
};
-#ifdef HAVE_SIGNAL_H
// Adapted from https://stackoverflow.com/a/17035073/172999
class AutoCatchCtrlC {
+#ifdef HAVE_SIGNAL_H
void (*m_prev_handler)(int);
static void handler(int signal) {
@@ -118,14 +118,12 @@ class AutoCatchCtrlC {
signal(SIGINT, m_prev_handler);
raise(SIGINT);
}
+#endif // HAVE_SIGNAL_H
};
-sigjmp_buf AutoCatchCtrlC::jump_buffer;
-
-#else // !HAVE_SIGNAL_H
-struct AutoCatchCtrlC {};
-
-#endif // !HAVE_SIGNAL_H
+#ifdef HAVE_SIGNAL_H
+sigjmp_buf AutoCatchCtrlC::jump_buffer;
+#endif // HAVE_SIGNAL_H
[[nodiscard]] static bool gjs_console_readline(char** bufp,
const char* prompt) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]