From ab58bbddc82a86d0689ebe52f694413370b98767 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 15 Apr 2018 01:18:50 -0400 Subject: [PATCH] unicorn: Be explicit about casting away const to const-incorrect APIs Uses C++ casts which silence relevant warnings in Xcode 9.3 Also migrates relevant Read function equivalents over for consistency. --- tests/A64/unicorn_emu/unicorn.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/A64/unicorn_emu/unicorn.cpp b/tests/A64/unicorn_emu/unicorn.cpp index 93cc4966..41aec0c3 100644 --- a/tests/A64/unicorn_emu/unicorn.cpp +++ b/tests/A64/unicorn_emu/unicorn.cpp @@ -72,7 +72,8 @@ std::array Unicorn::GetRegisters() const { for (size_t i = 0; i < num_gprs; ++i) ptrs[i] = ®s[i]; - CHECKED(uc_reg_read_batch(uc, const_cast(gpr_ids.data()), (void**)ptrs.data(), num_gprs)); + CHECKED(uc_reg_read_batch(uc, const_cast(gpr_ids.data()), + reinterpret_cast(ptrs.data()), num_gprs)); return regs; } @@ -81,7 +82,8 @@ void Unicorn::SetRegisters(const std::array& value) { for (size_t i = 0; i < num_gprs; ++i) ptrs[i] = &value[i]; - CHECKED(uc_reg_write_batch(uc, const_cast(gpr_ids.data()), (void**)ptrs.data(), num_gprs)); + CHECKED(uc_reg_write_batch(uc, const_cast(gpr_ids.data()), + reinterpret_cast(const_cast(ptrs.data())), num_gprs)); } using Vector = Unicorn::Vector; @@ -99,7 +101,8 @@ std::array Unicorn::GetVectors() const { for (size_t i = 0; i < num_vecs; ++i) ptrs[i] = &vecs[i]; - CHECKED(uc_reg_read_batch(uc, const_cast(vec_ids.data()), (void**)ptrs.data(), num_vecs)); + CHECKED(uc_reg_read_batch(uc, const_cast(vec_ids.data()), + reinterpret_cast(ptrs.data()), num_vecs)); return vecs; } @@ -109,7 +112,8 @@ void Unicorn::SetVectors(const std::array& value) { for (size_t i = 0; i < num_vecs; ++i) ptrs[i] = &value[i]; - CHECKED(uc_reg_write_batch(uc, const_cast(vec_ids.data()), (void**)ptrs.data(), num_vecs)); + CHECKED(uc_reg_write_batch(uc, const_cast(vec_ids.data()), + reinterpret_cast(const_cast(ptrs.data())), num_vecs)); } u32 Unicorn::GetFpcr() const {