From d1d9aa2edb4bc7b6158c99a38bb9adcf39a31ab2 Mon Sep 17 00:00:00 2001 From: nihui Date: Thu, 21 Dec 2023 16:26:16 +0800 Subject: [PATCH] fix some cpu.cpp warning (#5244) --- src/cpu.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/cpu.cpp b/src/cpu.cpp index d5ab511d970b..e56cd67098f2 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -238,7 +238,7 @@ static int detectisa(const void* some_inst) static int g_sigill_caught = 0; static sigjmp_buf g_jmpbuf; -static void catch_sigill(int signo, siginfo_t* si, void* data) +static void catch_sigill(int /*signo*/, siginfo_t* /*si*/, void* /*data*/) { g_sigill_caught = 1; siglongjmp(g_jmpbuf, -1); @@ -248,10 +248,11 @@ static int detectisa(void (*some_inst)()) { g_sigill_caught = 0; - struct sigaction sa = {0}; + struct sigaction sa; struct sigaction old_sa; - sa.sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO; + memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = catch_sigill; + sa.sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO; sigaction(SIGILL, &sa, &old_sa); if (sigsetjmp(g_jmpbuf, 1) == 0) @@ -2043,12 +2044,12 @@ CpuSet::CpuSet() void CpuSet::enable(int cpu) { - mask |= (1 << cpu); + mask |= ((ULONG_PTR)1 << cpu); } void CpuSet::disable(int cpu) { - mask &= ~(1 << cpu); + mask &= ~((ULONG_PTR)1 << cpu); } void CpuSet::disable_all() @@ -2058,7 +2059,7 @@ void CpuSet::disable_all() bool CpuSet::is_enabled(int cpu) const { - return mask & (1 << cpu); + return mask & ((ULONG_PTR)1 << cpu); } int CpuSet::num_enabled() const @@ -2117,12 +2118,12 @@ CpuSet::CpuSet() void CpuSet::enable(int cpu) { - policy |= (1 << cpu); + policy |= ((unsigned int)1 << cpu); } void CpuSet::disable(int cpu) { - policy &= ~(1 << cpu); + policy &= ~((unsigned int)1 << cpu); } void CpuSet::disable_all() @@ -2132,7 +2133,7 @@ void CpuSet::disable_all() bool CpuSet::is_enabled(int cpu) const { - return policy & (1 << cpu); + return policy & ((unsigned int)1 << cpu); } int CpuSet::num_enabled() const