More static code analysis fixes

This commit is contained in:
Henrik Rydgård 2024-10-28 17:46:32 +01:00
parent 1221a6e928
commit 2e85eb5128
13 changed files with 24 additions and 22 deletions

View File

@ -20,6 +20,7 @@ struct ShiftJIS {
return INVALID;
}
// Intentional fall-through.
[[fallthrough]];
case 0x9:
case 0xE:
row = ((j & 0x3F) << 1) - 0x01;

View File

@ -65,7 +65,7 @@ template <typename Value>
class TweenBase: public Tween {
public:
TweenBase(float duration, float (*curve)(float) = [](float f) { return f; })
: Tween(duration, curve), from{}, to_{} {
: Tween(duration, curve), from_{}, to_{} {
}
TweenBase(Value from, Value to, float duration, float (*curve)(float) = [](float f) { return f; })
: Tween(duration, curve), from_(from), to_(to) {

View File

@ -883,7 +883,7 @@ std::set<std::string> SavedataParam::GetSecureFileNames(const std::string &dirPa
std::set<std::string> secureFileNames;
for (const auto &entry : entries) {
char temp[14];
char temp[14]{};
truncate_cpy(temp, entry.filename);
secureFileNames.insert(temp);
}

View File

@ -1208,7 +1208,7 @@ static int sceFontFindOptimumFont(u32 libHandle, u32 fontStylePtr, u32 errorCode
if (PSP_CoreParameter().compat.flags().Fontltn12Hack && requestedStyle->fontLanguage == 2) {
for (size_t j = 0; j < internalFonts.size(); j++) {
const auto tempmatchStyle = internalFonts[j]->GetFontStyle();
const auto &tempmatchStyle = internalFonts[j]->GetFontStyle();
const std::string str(tempmatchStyle.fontFileName);
if (str == "ltn12.pgf") {
optimumFont = internalFonts[j];

View File

@ -379,7 +379,7 @@ public:
insts_ = w.insts_;
return *this;
}
IRWriter &operator =(IRWriter &&w) {
IRWriter &operator =(IRWriter &&w) noexcept {
insts_ = std::move(w.insts_);
return *this;
}

View File

@ -51,7 +51,7 @@ public:
IRBlock() {}
IRBlock(u32 emAddr, u32 origSize, int instOffset, u32 numInstructions)
: origAddr_(emAddr), origSize_(origSize), arenaOffset_(instOffset), numIRInstructions_(numInstructions) {}
IRBlock(IRBlock &&b) {
IRBlock(IRBlock &&b) noexcept {
arenaOffset_ = b.arenaOffset_;
hash_ = b.hash_;
origAddr_ = b.origAddr_;

View File

@ -207,6 +207,8 @@ void MIPSState::Init() {
nextPC = 0;
downcount = 0;
memset(vcmpResult, 0, sizeof(vcmpResult));
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
if (PSP_CoreParameter().cpuCore == CPUCore::JIT || PSP_CoreParameter().cpuCore == CPUCore::JIT_IR) {
MIPSComp::jit = MIPSComp::CreateNativeJit(this, PSP_CoreParameter().cpuCore == CPUCore::JIT_IR);

View File

@ -961,9 +961,11 @@ namespace MIPSInt
case V_Triple:
sz = V_Pair;
// Intentional fallthrough.
[[fallthrough]];
case V_Pair:
oz = V_Quad;
// Intentional fallthrough.
[[fallthrough]];
case V_Single:
for (int i = 0; i < GetNumVectorElements(sz); i++) {
u32 value = s[i];
@ -985,9 +987,11 @@ namespace MIPSInt
case V_Triple:
sz = V_Pair;
// Intentional fallthrough.
[[fallthrough]];
case V_Pair:
oz = V_Quad;
// Intentional fallthrough.
[[fallthrough]];
case V_Single:
for (int i = 0; i < GetNumVectorElements(sz); i++) {
u32 value = s[i];

View File

@ -27,10 +27,6 @@
// Slow freaking thing but works (eventually) :)
BlockAllocator::BlockAllocator(int grain) : bottom_(NULL), top_(NULL), grain_(grain)
{
}
BlockAllocator::~BlockAllocator()
{
Shutdown();

View File

@ -24,7 +24,7 @@ class PointerWrap;
class BlockAllocator
{
public:
BlockAllocator(int grain = 16); // 16 byte granularity by default.
BlockAllocator(int grain = 16) : grain_(grain) {} // 16 byte granularity by default.
~BlockAllocator();
void Init(u32 _rangeStart, u32 _rangeSize, bool suballoc);
@ -59,8 +59,7 @@ public:
private:
void CheckBlocks() const;
struct Block
{
struct Block {
Block(u32 _start, u32 _size, bool _taken, Block *_prev, Block *_next);
void SetAllocated(const char *_tag, bool suballoc);
void DoState(PointerWrap &p);
@ -72,13 +71,13 @@ private:
Block *next;
};
Block *bottom_;
Block *top_;
u32 rangeStart_;
u32 rangeSize_;
Block *bottom_ = nullptr;
Block *top_ = nullptr;
u32 rangeStart_ = 0;
u32 rangeSize_ = 0;
u32 grain_;
bool suballoc_;
bool suballoc_ = false;
void MergeFreeBlocks(Block *fromBlock);
Block *GetBlockFromAddress(u32 addr);

View File

@ -418,7 +418,7 @@ static void DataProcessingRegister(uint32_t w, uint64_t addr, Instruction *instr
int opcode2 = (w >> 16) & 0x1F;
int opcode = (w >> 10) & 0x3F;
// Data-processing (1 source)
const char *opname[8] = { "rbit", "rev16", "rev32", "(unk)", "clz", "cls" };
const char *opname[64] = { "rbit", "rev16", "rev32", "(unk)", "clz", "cls" };
const char *op = opcode2 >= 8 ? "unk" : opname[opcode];
snprintf(instr->text, sizeof(instr->text), "%s %c%d, %c%d", op, r, Rd, r, Rn);
} else if (((w >> 21) & 0x2FF) == 0x0D6) {
@ -749,7 +749,7 @@ static void FPandASIMD1(uint32_t w, uint64_t addr, Instruction *instr) {
int dst_index = imm5 >> (size + 1);
int src_index = imm4 >> size;
int op = (w >> 29) & 1;
char s;
char s = '_';
switch (size) {
case 0x00: s = 'b'; break;
case 0x01: s = 'h'; break;

View File

@ -12,8 +12,8 @@ class VFSInterface;
struct GameDBInfo {
std::string title;
std::string foreignTitle;
uint32_t crc;
uint64_t size;
uint32_t crc = 0;
uint64_t size = 0;
};
class GameDB {

View File

@ -2233,7 +2233,7 @@ static void decode_inst_operands(rv_decode *dec)
static void decode_inst_decompress(rv_decode *dec, rv_isa isa)
{
int decomp_op;
int decomp_op = 0;
switch (isa) {
case rv32: decomp_op = opcode_data[dec->op].decomp_rv32; break;
case rv64: decomp_op = opcode_data[dec->op].decomp_rv64; break;