Fix some static analysis warnings, including c-style cast
Some checks failed
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm clang (push) Waiting to run
Build RPCS3 / RPCS3 Mac Intel (push) Waiting to run
Build RPCS3 / RPCS3 Mac Apple Silicon (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
Generate Translation Template / Generate Translation Template (push) Failing after 2m59s
Build RPCS3 / RPCS3 Linux ubuntu-24.04 gcc (push) Has been skipped
Build RPCS3 / RPCS3 Linux ubuntu-24.04 clang (push) Has been skipped

This commit is contained in:
Megamouse 2025-06-01 20:45:05 +02:00
parent 70faef3fdb
commit 4704c03209
9 changed files with 16 additions and 14 deletions

View file

@ -96,7 +96,7 @@ class thread_future
thread_future* prev{}; thread_future* prev{};
protected: protected:
atomic_t<void(*)(thread_base*, thread_future*)> exec{}; atomic_t<void(*)(const thread_base*, thread_future*)> exec{};
atomic_t<u32> done{0}; atomic_t<u32> done{0};
@ -389,7 +389,7 @@ public:
: m_args(std::forward<Args>(args)...) : m_args(std::forward<Args>(args)...)
, m_func(std::forward<Ctx>(func)) , m_func(std::forward<Ctx>(func))
{ {
thread_future::exec.raw() = +[](thread_base* tb, thread_future* tf) thread_future::exec.raw() = +[](const thread_base* tb, thread_future* tf)
{ {
const auto _this = static_cast<future*>(tf); const auto _this = static_cast<future*>(tf);

View file

@ -84,9 +84,8 @@ public:
transactional_storage& operator=(const transactional_storage&) = delete; transactional_storage& operator=(const transactional_storage&) = delete;
transactional_storage(transactional_storage&& other) transactional_storage(transactional_storage&& other)
: pool(std::move(other.pool))
{ {
pool = std::move(other.pool);
std::unique_lock lock_other{other.current_mutex}; std::unique_lock lock_other{other.current_mutex};
const std::shared_ptr<T> other_current = other.current; const std::shared_ptr<T> other_current = other.current;
other.current = nullptr; other.current = nullptr;

View file

@ -81,7 +81,8 @@ namespace vm
static inline atomic_t<reservation_waiter_t>* reservation_notifier_begin_wait(u32 raddr, u64 rtime) static inline atomic_t<reservation_waiter_t>* reservation_notifier_begin_wait(u32 raddr, u64 rtime)
{ {
atomic_t<reservation_waiter_t>& waiter = *reservation_notifier(raddr).first; const auto notifiers = reservation_notifier(raddr);
atomic_t<reservation_waiter_t>& waiter = *notifiers.first;
waiter.atomic_op([](reservation_waiter_t& value) waiter.atomic_op([](reservation_waiter_t& value)
{ {

View file

@ -59,7 +59,7 @@ namespace np
u32 last_free = 0; u32 last_free = 0;
bool found_space = false; bool found_space = false;
for (auto& a : m_allocs) for (const auto& a : m_allocs)
{ {
if ((a.first - last_free) >= alloc_size) if ((a.first - last_free) >= alloc_size)
{ {

View file

@ -135,7 +135,7 @@ namespace utils
#endif #endif
} }
constexpr void prefetch_write(void* ptr) constexpr void prefetch_write(const void* ptr)
{ {
if (std::is_constant_evaluated()) if (std::is_constant_evaluated())
{ {

View file

@ -15,12 +15,12 @@ namespace utils
{ {
u128 __vectorcall atomic_load16(const void* ptr) u128 __vectorcall atomic_load16(const void* ptr)
{ {
return std::bit_cast<u128>(_mm_load_si128((__m128i*)ptr)); return std::bit_cast<u128>(_mm_load_si128(static_cast<const __m128i*>(ptr)));
} }
void __vectorcall atomic_store16(void* ptr, u128 value) void __vectorcall atomic_store16(void* ptr, u128 value)
{ {
_mm_store_si128((__m128i*)ptr, std::bit_cast<__m128i>(value)); _mm_store_si128(static_cast<__m128i*>(ptr), std::bit_cast<__m128i>(value));
} }
} }
#endif #endif

View file

@ -479,7 +479,7 @@ struct atomic_storage
#endif #endif
#if defined(_M_X64) && defined(_MSC_VER) #if defined(_M_X64) && defined(_MSC_VER)
return _interlockedbittestandset((long*)dst, bit) != 0; return _interlockedbittestandset(reinterpret_cast<long*>(dst), bit) != 0;
#elif defined(ARCH_X64) #elif defined(ARCH_X64)
bool result; bool result;
__asm__ volatile ("lock btsl %2, 0(%1)\n" : "=@ccc" (result) : "r" (dst), "Ir" (bit) : "cc", "memory"); __asm__ volatile ("lock btsl %2, 0(%1)\n" : "=@ccc" (result) : "r" (dst), "Ir" (bit) : "cc", "memory");
@ -506,7 +506,7 @@ struct atomic_storage
#endif #endif
#if defined(_M_X64) && defined(_MSC_VER) #if defined(_M_X64) && defined(_MSC_VER)
return _interlockedbittestandreset((long*)dst, bit) != 0; return _interlockedbittestandreset(reinterpret_cast<long*>(dst), bit) != 0;
#elif defined(ARCH_X64) #elif defined(ARCH_X64)
bool result; bool result;
__asm__ volatile ("lock btrl %2, 0(%1)\n" : "=@ccc" (result) : "r" (dst), "Ir" (bit) : "cc", "memory"); __asm__ volatile ("lock btrl %2, 0(%1)\n" : "=@ccc" (result) : "r" (dst), "Ir" (bit) : "cc", "memory");
@ -536,9 +536,9 @@ struct atomic_storage
while (true) while (true)
{ {
// Keep trying until we actually invert desired bit // Keep trying until we actually invert desired bit
if (!_bittest((long*)dst, bit) && !_interlockedbittestandset((long*)dst, bit)) if (!_bittest(reinterpret_cast<const long*>(dst), bit) && !_interlockedbittestandset(reinterpret_cast<long*>(dst), bit))
return false; return false;
if (_interlockedbittestandreset((long*)dst, bit)) if (_interlockedbittestandreset(reinterpret_cast<long*>(dst), bit))
return true; return true;
} }
#elif defined(ARCH_X64) #elif defined(ARCH_X64)

View file

@ -16,6 +16,8 @@ namespace utils
T* result; T* result;
__asm__("mov %0, %1" : "=r" (result) : "r" (ptr) : "memory"); __asm__("mov %0, %1" : "=r" (result) : "r" (ptr) : "memory");
return result; return result;
#else
#error "Missing utils::bless() implementation"
#endif #endif
} }
} }

View file

@ -444,7 +444,7 @@ namespace utils
if (proc_dir) if (proc_dir)
{ {
// proc available, iterate through tasks and count them // proc available, iterate through tasks and count them
struct dirent* entry; const struct dirent* entry;
while ((entry = readdir(proc_dir)) != NULL) while ((entry = readdir(proc_dir)) != NULL)
{ {
if (entry->d_name[0] == '.') if (entry->d_name[0] == '.')