Fix some static analysis warnings

This commit is contained in:
Megamouse 2025-05-24 04:45:35 +02:00
parent 4f2324cae7
commit da273761d1
7 changed files with 36 additions and 33 deletions

View file

@ -143,10 +143,10 @@ class CgBinaryDisasm
std::vector<u32> m_loop_end_offsets;
// VP members
u32 m_sca_opcode;
u32 m_vec_opcode;
static const usz m_max_instr_count = 512;
usz m_instr_count;
u32 m_sca_opcode = 0;
u32 m_vec_opcode = 0;
static constexpr usz m_max_instr_count = 512;
usz m_instr_count = 0;
std::vector<u32> m_data;
public:

View file

@ -18,9 +18,8 @@ namespace rsx
static inline std::string_view location_tostring(u32 location)
{
ensure(location < 2);
constexpr const char* location_names[2] = { "CELL_GCM_LOCATION_LOCAL", "CELL_GCM_LOCATION_MAIN" };
return location_names[location];
return ::at32(location_names, location);
}
static inline u32 classify_location(u32 address)

View file

@ -16,7 +16,7 @@ namespace vk
disposable_t() = delete;
disposable_t(const disposable_t&) = delete;
disposable_t(disposable_t&& other) :
disposable_t(disposable_t&& other) noexcept :
ptr(std::exchange(other.ptr, nullptr)),
deleter(other.deleter)
{}

View file

@ -425,7 +425,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptr<CPUDis
setLayout(vbox_panel);
// Events
connect(m_addr_line, &QLineEdit::returnPressed, [this]()
connect(m_addr_line, &QLineEdit::returnPressed, this, [this]()
{
bool ok = false;
const u32 addr = normalize_hex_qstring(m_addr_line->text()).toULong(&ok, 16);
@ -433,17 +433,17 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptr<CPUDis
scroll(0); // Refresh
});
connect(sb_words, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=, this]()
connect(sb_words, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=, this]()
{
m_colcount = 1 << sb_words->value();
ShowMemory();
});
connect(b_prev, &QAbstractButton::clicked, [this]() { scroll(-1); });
connect(b_next, &QAbstractButton::clicked, [this]() { scroll(1); });
connect(b_fprev, &QAbstractButton::clicked, [this]() { scroll(m_rowcount * -1); });
connect(b_fnext, &QAbstractButton::clicked, [this]() { scroll(m_rowcount); });
connect(b_img, &QAbstractButton::clicked, [=, this]()
connect(b_prev, &QAbstractButton::clicked, this, [this]() { scroll(-1); });
connect(b_next, &QAbstractButton::clicked, this, [this]() { scroll(1); });
connect(b_fprev, &QAbstractButton::clicked, this, [this]() { scroll(m_rowcount * -1); });
connect(b_fnext, &QAbstractButton::clicked, this, [this]() { scroll(m_rowcount); });
connect(b_img, &QAbstractButton::clicked, this, [=, this]()
{
const color_format format = cbox_img_mode->currentData().value<color_format>();
const int sizex = sb_img_size_x->value();
@ -580,7 +580,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptr<CPUDis
const u32 id = idm::last_id();
auto handle_ptr = idm::get_unlocked<memory_viewer_handle>(id);
connect(this, &memory_viewer_panel::finished, [handle_ptr = std::move(handle_ptr), id, this](int)
connect(this, &memory_viewer_panel::finished, this, [handle_ptr = std::move(handle_ptr), id, this](int)
{
if (m_search_thread)
{
@ -617,7 +617,7 @@ memory_viewer_panel::~memory_viewer_panel()
void memory_viewer_panel::wheelEvent(QWheelEvent *event)
{
// Set some scrollspeed modifiers:
// Set some scroll speed modifiers:
u32 step_size = 1;
if (event->modifiers().testFlag(Qt::ControlModifier))
step_size *= m_rowcount;
@ -986,6 +986,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form
const u32 memsize = utils::mul_saturate<u32>(utils::mul_saturate<u32>(texel_bytes, width), height);
if (memsize == 0)
{
gui_log.error("Can not show image. memsize is 0 (texel_bytes=%d, width=%d, height=%d)", texel_bytes, width, height);
return;
}
@ -993,6 +994,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form
if (!originalBuffer)
{
gui_log.error("Can not show image. originalBuffer is null (addr=%d, memsize=%d)", addr, memsize);
return;
}
@ -1001,6 +1003,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form
if (!convertedBuffer)
{
// OOM or invalid memory address, give up
gui_log.error("Can not show image. convertedBuffer is null (addr=%d, memsize=%d)", addr, memsize);
return;
}
@ -1014,7 +1017,7 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form
{
const u32 offset = y * pitch;
const u32 offset_new = y * pitch_new;
for (u32 x = 0, x_new = 0; x < pitch; x += 3, x_new += 4)
for (u32 x = 0, x_new = 0; x < pitch && x_new < pitch_new; x += 3, x_new += 4)
{
convertedBuffer[offset_new + x_new + 0] = originalBuffer[offset + x + 2];
convertedBuffer[offset_new + x_new + 1] = originalBuffer[offset + x + 1];
@ -1116,19 +1119,20 @@ void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format form
}
// Flip vertically
if (flipv && height > 1 && memsize > 1)
if (flipv && width > 0 && height > 1 && memsize > 1)
{
const u32 pitch = width * 4;
std::vector<u8> tmp_row(pitch);
for (u32 y = 0; y < height / 2; y++)
{
const u32 offset = y * pitch;
const u32 flip_offset = (height - y - 1) * pitch;
for (u32 x = 0; x < pitch; x++)
{
const u8 tmp = convertedBuffer[offset + x];
convertedBuffer[offset + x] = convertedBuffer[flip_offset + x];
convertedBuffer[flip_offset + x] = tmp;
}
u8* row_top = &convertedBuffer[y * pitch];
u8* row_bottom = &convertedBuffer[(height - y - 1) * pitch];
// Swap rows
std::memcpy(tmp_row.data(), row_top, pitch);
std::memcpy(row_top, row_bottom, pitch);
std::memcpy(row_bottom, tmp_row.data(), pitch);
}
}

View file

@ -86,13 +86,12 @@ std::array<midi_device, max_midi_devices> midi_creator::get_selection_list() con
std::string midi_creator::set_device(u32 num, const midi_device& device)
{
ensure(num < m_sel_list.size());
m_sel_list[num] = device;
midi_device& dev = ::at32(m_sel_list, num);
dev = device;
if (device.name == get_none().toStdString())
{
m_sel_list[num].name.clear();
dev.name.clear();
}
std::string result;

View file

@ -11,7 +11,7 @@
struct recvmessage_signal_struct
{
shared_ptr<std::pair<std::string, message_data>> msg;
u64 msg_id;
u64 msg_id = 0;
};
Q_DECLARE_METATYPE(recvmessage_signal_struct);

View file

@ -17,7 +17,7 @@ skylander_dialog* skylander_dialog::inst = nullptr;
std::optional<std::tuple<u8, u16, u16>> skylander_dialog::sky_slots[UI_SKY_NUM];
QString last_skylander_path;
const std::map<const std::pair<const u16, const u16>, const std::string> list_skylanders = {
static const std::map<const std::pair<const u16, const u16>, const std::string> list_skylanders = {
{{0, 0x0000}, "Whirlwind"},
{{0, 0x1801}, "Series 2 Whirlwind"},
{{0, 0x1C02}, "Polar Whirlwind"},
@ -502,7 +502,8 @@ const std::map<const std::pair<const u16, const u16>, const std::string> list_sk
u16 skylander_crc16(u16 init_value, const u8* buffer, u32 size)
{
const unsigned short CRC_CCITT_TABLE[256] = {0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273,
constexpr unsigned short CRC_CCITT_TABLE[256] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273,
0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528,
0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 0x48C4, 0x58E5, 0x6886,
0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF,