From 1f2e9ca2601ec9801e25318132b4a54169bc5edf Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Sat, 24 Jun 2023 18:26:18 +0100 Subject: [PATCH] kernel: ignore overflow warnings in teams.cpp and threads.cpp GCC's overflow checker gives a warning about the potential that the atomic functions called in teams.cpp and threads.cpp will write to a null-pointer. In this case, it is safe to assume that the values will never be null, therefore these warnings can be safely ignored. Relates to/fixes #17734 Change-Id: I777ff96f2812ed7d3ba57a46cad89ef6994cb08f Reviewed-on: https://review.haiku-os.org/c/haiku/+/6643 Tested-by: Commit checker robot Reviewed-by: Adrien Destugues --- src/system/kernel/team.cpp | 6 ++++++ src/system/kernel/thread.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 55c4a3980e..ca8860563a 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -4363,8 +4363,14 @@ _user_exit_team(status_t returnValue) // Stop the thread, if the team is being debugged and that has been // requested. + // Note: GCC 13 marks the following call as potentially overflowing, since it thinks team may + // be `nullptr`. This cannot be the case in reality, therefore ignore this specific + // error. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstringop-overflow" if ((atomic_get(&team->debug_info.flags) & B_TEAM_DEBUG_PREVENT_EXIT) != 0) user_debug_stop_thread(); + #pragma GCC diagnostic pop // Send this thread a SIGKILL. This makes sure the thread will not return to // userland. The signal handling code forwards the signal to the main diff --git a/src/system/kernel/thread.cpp b/src/system/kernel/thread.cpp index 3329dcb3f1..be7a60a09c 100644 --- a/src/system/kernel/thread.cpp +++ b/src/system/kernel/thread.cpp @@ -3796,7 +3796,13 @@ _user_block_thread(uint32 flags, bigtime_t timeout) return waitStatus; // nope, so wait + // Note: GCC 13 marks the following call as potentially overflowing, since it thinks `thread` + // may be `nullptr`. This cannot be the case in reality, therefore ignore this specific + // error. + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstringop-overflow" thread_prepare_to_block(thread, flags, THREAD_BLOCK_TYPE_USER, NULL); + #pragma GCC diagnostic pop threadLocker.Unlock();