Skip to content

Commit 82d3a80

Browse files
Avoid knownConditionTrueFalse warning in signalhandler.cpp (#8430)
1 parent 2cfa74b commit 82d3a80

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

cli/signalhandler.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,15 @@ static const Signalmap_t listofsignals = {
108108
*/
109109
static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) // cppcheck-suppress constParameterCallback - info can be const
110110
{
111-
int type = -1;
111+
const char* typeStr = "";
112112
pid_t killid;
113113
// TODO: separate these two defines
114114
#if defined(__linux__) && defined(REG_ERR)
115115
const auto* const uc = reinterpret_cast<const ucontext_t*>(context);
116116
killid = static_cast<pid_t>(syscall(SYS_gettid));
117117
if (uc) {
118-
type = static_cast<int>(uc->uc_mcontext.gregs[REG_ERR]) & 2;
118+
const int type = static_cast<int>(uc->uc_mcontext.gregs[REG_ERR]) & 2;
119+
typeStr = (type == 0) ? "reading " : "writing ";
119120
}
120121
#else
121122
(void)context;
@@ -258,9 +259,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) /
258259
break;
259260
}
260261
fprintf(output, " (%sat 0x%lx).%s\n",
261-
// cppcheck-suppress knownConditionTrueFalse ; FP
262-
(type==-1)? "" :
263-
(type==0) ? "reading " : "writing ",
262+
typeStr,
264263
reinterpret_cast<unsigned long>(info->si_addr),
265264
isAddressOnStack ? " Stackoverflow?" : ""
266265
);

0 commit comments

Comments
 (0)