Merge pull request #7667 from unknownbrackets/warnings

Fix some warnings
This commit is contained in:
Henrik Rydgård 2015-04-08 21:21:08 +02:00
commit 050a7c1a85
17 changed files with 43 additions and 32 deletions

View File

@ -381,9 +381,13 @@ void DirectoryFileHandle::Close()
if (needsTrunc_ != -1) {
#ifdef _WIN32
Seek((s32)needsTrunc_, FILEMOVE_BEGIN);
SetEndOfFile(hFile);
if (SetEndOfFile(hFile) == 0) {
ERROR_LOG_REPORT(FILESYS, "Failed to truncate file.");
}
#else
ftruncate(hFile, (off_t)needsTrunc_);
if (ftruncate(hFile, (off_t)needsTrunc_) != 0) {
ERROR_LOG_REPORT(FILESYS, "Failed to truncate file.");
}
#endif
}
#ifdef _WIN32

View File

@ -387,16 +387,7 @@ static int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, bool pro
// If there are any callbacks, we always wait, and wake after the callbacks.
bool hasCallbacks = processCallbacks && __KernelCurHasReadyCallbacks();
if (s->ns.currentCount >= wantedCount && s->waitingThreads.size() == 0 && !hasCallbacks)
{
if (hasCallbacks)
{
// Might actually end up having to wait, so set the timeout.
__KernelSetSemaTimeout(s, timeoutPtr);
__KernelWaitCallbacksCurThread(WAITTYPE_SEMA, id, wantedCount, timeoutPtr);
}
else
s->ns.currentCount -= wantedCount;
}
s->ns.currentCount -= wantedCount;
else
{
SceUID threadID = __KernelGetCurThread();

View File

@ -674,6 +674,7 @@ static int sceMpegRegistStream(u32 mpeg, u32 streamType, u32 streamNum)
StreamInfo info;
info.type = streamType;
info.num = streamNum;
info.sid = sid;
info.needsReset = true;
ctx->streamMap[sid] = info;
return sid;

View File

@ -4785,9 +4785,7 @@ int matchingEventThread(int matchingId)
if (msg->optlen > 0) opt = ((u8 *)msg) + sizeof(ThreadMessage); //&msg[1]
// Log Matching Events
if (msg->opcode >= 0) {
INFO_LOG(SCENET, "EventLoop[%d]: Matching Event [%d=%s] OptSize=%d", matchingId, msg->opcode, getMatchingEventStr(msg->opcode), msg->optlen);
}
INFO_LOG(SCENET, "EventLoop[%d]: Matching Event [%d=%s] OptSize=%d", matchingId, msg->opcode, getMatchingEventStr(msg->opcode), msg->optlen);
context->eventlock->unlock(); // Unlock to prevent race-condition with other threads due to recursive lock
// Call Event Handler

View File

@ -87,7 +87,7 @@ std::vector<std::string> DisassembleArm2(const u8 *data, int size) {
std::string AddAddress(const std::string &buf, uint64_t addr) {
char buf2[16];
snprintf(buf2, sizeof(buf2), "%04x%08x", addr >> 32, addr & 0xFFFFFFFF);
snprintf(buf2, sizeof(buf2), "%04x%08x", (uint32_t)(addr >> 32), (uint32_t)(addr & 0xFFFFFFFF));
return std::string(buf2) + " " + buf;
}

View File

@ -1287,7 +1287,9 @@ skip:
mf.hardcoded = false;
if (fscanf(file, "%llx:%d = %63s\n", &mf.hash, &mf.size, mf.name) < 3) {
char temp[1024];
fgets(temp, 1024, file);
if (!fgets(temp, 1024, file)) {
WARN_LOG(LOADER, "Could not read from hash map: %s", filename.c_str());
}
continue;
}

View File

@ -572,7 +572,7 @@ namespace MIPSInt
{ //TODO: verify
int x = 31;
int count=0;
while (!(R(rs) & (1<<x)) && x >= 0)
while (x >= 0 && !(R(rs) & (1<<x)))
{
count++;
x--;
@ -584,7 +584,7 @@ namespace MIPSInt
{ //TODO: verify
int x = 31;
int count=0;
while ((R(rs) & (1<<x)) && x >= 0)
while (x >= 0 && (R(rs) & (1<<x)))
{
count++;
x--;

View File

@ -390,7 +390,10 @@ namespace MIPSInt
else if (type == 7)
f[0] = Float16ToFloat32((u16)uimm16); // vfim
else
{
_dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted");
f[0] = 0;
}
ApplyPrefixD(f, V_Single);
V(vt) = f[0];
@ -735,6 +738,8 @@ namespace MIPSInt
break;
default:
_dbg_assert_msg_(CPU, 0, "Trying to interpret Int_Vf2h instruction that can't be interpreted");
d[0] = 0;
d[1] = 0;
break;
}
ApplyPrefixD(reinterpret_cast<float *>(d), outsize);
@ -1789,6 +1794,8 @@ bad:
default:
Reporting::ReportMessage("CrossQuat instruction with wrong size");
_dbg_assert_msg_(CPU,0,"Trying to interpret instruction that can't be interpreted");
d[0] = 0;
d[1] = 0;
break;
}
WriteVector(d, sz, vd);

View File

@ -590,7 +590,7 @@ void FramebufferManagerCommon::FindTransferFramebuffers(VirtualFramebuffer *&dst
}
if (match) {
dstYOffset = yOffset;
dstXOffset = (byteOffset / bpp) % dstStride;
dstXOffset = dstStride == 0 ? 0 : (byteOffset / bpp) % dstStride;
dstBuffer = vfb;
}
}

View File

@ -94,6 +94,7 @@ LPDIRECT3DTEXTURE9 DepalShaderCacheDX9::GetClutTexture(const u32 clutID, u32 *ra
HRESULT hr = pD3Ddevice->CreateTexture(texturePixels, 1, 1, usage, (D3DFORMAT)D3DFMT(dstFmt), pool, &tex->texture, NULL);
if (FAILED(hr)) {
ERROR_LOG(G3D, "Failed to create D3D texture for depal");
delete tex;
return nullptr;
}
@ -101,6 +102,7 @@ LPDIRECT3DTEXTURE9 DepalShaderCacheDX9::GetClutTexture(const u32 clutID, u32 *ra
hr = tex->texture->LockRect(0, &rect, NULL, 0);
if (FAILED(hr)) {
ERROR_LOG(G3D, "Failed to lock D3D texture for depal");
delete tex;
return nullptr;
}
// Regardless of format, the CLUT should always be 1024 bytes.

View File

@ -364,7 +364,7 @@ bool TextureCacheDX9::AttachFramebuffer(TexCacheEntry *entry, u32 address, Virtu
const u32 bitOffset = (texaddr - addr) * 8;
const u32 pixelOffset = bitOffset / std::max(1U, (u32)textureBitsPerPixel[entry->format]);
fbInfo.yOffset = pixelOffset / entry->bufw;
fbInfo.yOffset = entry->bufw == 0 ? 0 : pixelOffset / entry->bufw;
fbInfo.xOffset = entry->bufw == 0 ? 0 : pixelOffset % entry->bufw;
if (framebuffer->fb_stride != entry->bufw) {

View File

@ -24,7 +24,7 @@
static const int FRAGTEST_TEXTURE_OLD_AGE = 307;
static const int FRAGTEST_DECIMATION_INTERVAL = 113;
FragmentTestCache::FragmentTestCache() : textureCache_(NULL), lastTexture_(0) {
FragmentTestCache::FragmentTestCache() : textureCache_(NULL), lastTexture_(0), decimationCounter_(0) {
scratchpad_ = new u8[256 * 4];
}

View File

@ -357,7 +357,7 @@ bool TextureCache::AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualF
const u32 bitOffset = (texaddr - addr) * 8;
const u32 pixelOffset = bitOffset / std::max(1U, (u32)textureBitsPerPixel[entry->format]);
fbInfo.yOffset = pixelOffset / entry->bufw;
fbInfo.yOffset = entry->bufw == 0 ? 0 : pixelOffset / entry->bufw;
fbInfo.xOffset = entry->bufw == 0 ? 0 : pixelOffset % entry->bufw;
if (framebuffer->fb_stride != entry->bufw) {

View File

@ -154,19 +154,20 @@ UI::EventReturn CwCheatScreen::OnEditCheatFile(UI::EventParams &params) {
cheatFile = activeCheatFile;
// Can't rely on a .txt file extension to auto-open in the right editor,
// so let's find notepad
wchar_t notepad_path[MAX_PATH];
GetSystemDirectory(notepad_path, sizeof(notepad_path) / sizeof(wchar_t));
wchar_t notepad_path[MAX_PATH + 1];
GetSystemDirectory(notepad_path, MAX_PATH);
wcscat(notepad_path, L"\\notepad.exe");
wchar_t cheat_path[MAX_PATH];
wcscpy(cheat_path, ConvertUTF8ToWString(cheatFile).c_str());
wchar_t cheat_path[MAX_PATH + 1] = {0};
wcsncpy(cheat_path, ConvertUTF8ToWString(cheatFile).c_str(), MAX_PATH);
// Flip any slashes...
for (size_t i = 0; i < wcslen(cheat_path); i++) {
if (cheat_path[i] == '/')
cheat_path[i] = '\\';
}
wchar_t command_line[MAX_PATH * 2 + 1];
// One for the space, one for the null.
wchar_t command_line[MAX_PATH * 2 + 1 + 1];
wsprintf(command_line, L"%s %s", notepad_path, cheat_path);
STARTUPINFO si;
@ -177,7 +178,7 @@ UI::EventReturn CwCheatScreen::OnEditCheatFile(UI::EventParams &params) {
memset(&pi, 0, sizeof(pi));
UINT retval = CreateProcess(0, command_line, 0, 0, 0, 0, 0, 0, &si, &pi);
if (!retval) {
ERROR_LOG(BOOT, "Failed creating notepad process");
ERROR_LOG(COMMON, "Failed creating notepad process");
}
#elif defined(__APPLE__) || defined(__linux__)
#if defined(__linux__)
@ -187,7 +188,10 @@ UI::EventReturn CwCheatScreen::OnEditCheatFile(UI::EventParams &params) {
#endif
cheatFile.append(activeCheatFile);
NOTICE_LOG(BOOT, "Launching %s", cheatFile.c_str());
system(cheatFile.c_str());
int retval = system(cheatFile.c_str());
if (retval != 0) {
ERROR_LOG(COMMON, "Failed to launch cheat file");
}
#endif
return UI::EVENT_DONE;
}

View File

@ -293,6 +293,7 @@ void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam)
break;
default:
temp[0] = '\0';
len = 0;
break;
}

View File

@ -202,7 +202,7 @@ std::string GetVideoCardDriverVersion() {
hr = pEnum->Next(WBEM_INFINITE, 1, &pObj, &uReturned);
}
if (uReturned && !FAILED(hr)) {
if (!FAILED(hr) && uReturned) {
hr = pObj->Get(L"DriverVersion", 0, &var, NULL, NULL);
if (SUCCEEDED(hr)) {
char str[MAX_PATH];

View File

@ -338,7 +338,8 @@ double CompareScreenshot(const std::vector<u32> &pixels, u32 stride, u32 w, u32
{
// The bitmap header is 14 + 40 bytes. We could validate it but the test would fail either way.
fseek(bmp, 14 + 40, SEEK_SET);
fread(reference, sizeof(u32), stride * h, bmp);
if (fread(reference, sizeof(u32), stride * h, bmp) != stride * h)
error = "Unable to read screenshot data: " + screenshotFilename;
fclose(bmp);
}
else