Build: Fix some format truncation warnings.

Generally all should be safe already, but better to be sure.
This commit is contained in:
Unknown W. Brackets 2021-12-11 09:40:40 -08:00
parent aeee317368
commit 63e623ecb2
9 changed files with 27 additions and 24 deletions

View File

@ -55,7 +55,7 @@ struct ShaderLanguageDesc {
bool bitwiseOps = false;
bool forceMatrix4x4 = false;
bool coefsFromBuffers = false;
char driverInfo[128]; // Really only GL uses this.
char driverInfo[256]; // Really only GL uses this.
};
enum class UniformType : int8_t {

View File

@ -14,7 +14,7 @@ typedef enum {
typedef enum { EXCOMM_CONST, EXCOMM_CONST_FLOAT, EXCOMM_REF, EXCOMM_OP } ExpressionCommand;
static char expressionError[256];
static char expressionError[512];
typedef struct {
char Name[4];

View File

@ -66,24 +66,22 @@ void sleep_ms(int ms) {
// Return the current time formatted as Minutes:Seconds:Milliseconds
// in the form 00:00:000.
void GetTimeFormatted(char formattedTime[13]) {
void GetTimeFormatted(char formattedTime[11]) {
time_t sysTime;
struct tm * gmTime;
char tmp[13];
time(&sysTime);
gmTime = localtime(&sysTime);
strftime(tmp, 6, "%M:%S", gmTime);
struct tm *gmTime = localtime(&sysTime);
char tmp[6];
strftime(tmp, sizeof(tmp), "%M:%S", gmTime);
// Now tack on the milliseconds
#ifdef _WIN32
struct timeb tp;
(void)::ftime(&tp);
snprintf(formattedTime, 13, "%s:%03i", tmp, tp.millitm);
snprintf(formattedTime, 11, "%s:%03i", tmp, tp.millitm);
#else
struct timeval t;
(void)gettimeofday(&t, NULL);
snprintf(formattedTime, 13, "%s:%03d", tmp, (int)(t.tv_usec / 1000));
snprintf(formattedTime, 11, "%s:%03d", tmp, (int)(t.tv_usec / 1000));
#endif
}

View File

@ -146,7 +146,7 @@ static void CleanupDialogThreads(bool force = false) {
accessThread = nullptr;
accessThreadState = "cleaned up";
} else if (force) {
ERROR_LOG_REPORT(SCEUTILITY, "Utility access thread still running, state: %s, dialog=%d/%d", accessThreadState, currentDialogType, currentDialogActive);
ERROR_LOG_REPORT(SCEUTILITY, "Utility access thread still running, state: %s, dialog=%d/%d", accessThreadState, (int)currentDialogType, currentDialogActive);
// Try to force shutdown anyway.
accessThread->Terminate();

View File

@ -365,22 +365,27 @@ namespace MIPSDis
void Dis_Emuhack(MIPSOpcode op, char *out)
{
auto resolved = Memory::Read_Instruction(disPC, true);
char disasm[256];
union {
char disasm[256];
char truncated[241];
};
if (MIPS_IS_EMUHACK(resolved)) {
strcpy(disasm, "(invalid emuhack)");
} else {
MIPSDisAsm(resolved, disPC, disasm, true);
}
// Truncate in case it was too long, just to avoid warnings.
truncated[240] = '\0';
switch (op.encoding >> 24) {
case 0x68:
snprintf(out, 256, "* jitblock: %s", disasm);
snprintf(out, 256, "* jitblock: %s", truncated);
break;
case 0x6a:
snprintf(out, 256, "* replacement: %s", disasm);
snprintf(out, 256, "* replacement: %s", truncated);
break;
default:
snprintf(out, 256, "* (invalid): %s", disasm);
snprintf(out, 256, "* (invalid): %s", truncated);
break;
}
}

View File

@ -206,7 +206,7 @@ static const char *GetSystemRegName(int o0, int op1, int CRn, int CRm, int op2)
}
static void BranchExceptionAndSystem(uint32_t w, uint64_t addr, Instruction *instr, SymbolCallback symbolCallback) {
char buffer[128];
char buffer[125];
int Rt = w & 0x1f;
int Rn = (w >> 5) & 0x1f;
if (((w >> 26) & 0x1F) == 5) {

View File

@ -340,7 +340,7 @@ bool PortManager::Clear() {
#ifdef WITH_UPNP
int r;
int i = 0;
char index[6];
char index[16];
char intAddr[40];
char intPort[6];
char extPort[6];
@ -359,7 +359,7 @@ bool PortManager::Clear() {
//unsigned int num = 0;
//UPNP_GetPortMappingNumberOfEntries(urls->controlURL, datas->first.servicetype, &num); // Not supported by many routers
do {
snprintf(index, 6, "%d", i);
snprintf(index, sizeof(index), "%d", i);
rHost[0] = '\0'; enabled[0] = '\0';
duration[0] = '\0'; desc[0] = '\0'; protocol[0] = '\0';
extPort[0] = '\0'; intPort[0] = '\0'; intAddr[0] = '\0';
@ -387,7 +387,7 @@ bool PortManager::Clear() {
}
}
i++;
} while (r == 0);
} while (r == 0 && i < 65536);
return true;
#else
return false;
@ -398,7 +398,7 @@ bool PortManager::RefreshPortList() {
#ifdef WITH_UPNP
int r;
int i = 0;
char index[6];
char index[16];
char intAddr[40];
char intPort[6];
char extPort[6];
@ -419,7 +419,7 @@ bool PortManager::RefreshPortList() {
//unsigned int num = 0;
//UPNP_GetPortMappingNumberOfEntries(urls->controlURL, datas->first.servicetype, &num); // Not supported by many routers
do {
snprintf(index, 6, "%d", i);
snprintf(index, sizeof(index), "%d", i);
rHost[0] = '\0'; enabled[0] = '\0';
duration[0] = '\0'; desc[0] = '\0'; protocol[0] = '\0';
extPort[0] = '\0'; intPort[0] = '\0'; intAddr[0] = '\0';
@ -444,7 +444,7 @@ bool PortManager::RefreshPortList() {
}
}
i++;
} while (r == 0);
} while (r == 0 && i < 65536);
return true;
#else
return false;

View File

@ -809,7 +809,7 @@ void TouchTestScreen::render() {
ui_context->Begin();
char buffer[2048];
char buffer[4096];
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
if (touches_[i].id != -1) {
ui_context->Draw()->Circle(touches_[i].x, touches_[i].y, 100.0, 3.0, 80, 0.0f, 0xFFFFFFFF, 1.0);

View File

@ -422,7 +422,7 @@ static bool DisasmNeonImmVal(uint32_t op, char *text) {
int quad = (op >> 6) & 1;
const char *operation = "MOV";
const char *size = "(unk)";
char temp[256] = "(unk)";
char temp[64] = "(unk)";
switch (cmode) {
case VIMM___x___x:
case VIMM___x___x + 1: