Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix almost every warning #2195

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ARMJIT_A64/ARMJIT_Branch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void Compiler::Comp_JumpTo(u32 addr, bool forceNonConstantCycles)
// doesn't matter if we put garbage in the MSbs there
if (addr & 0x2)
{
cpu9->CodeRead32(addr-2, true) >> 16;
cpu9->CodeRead32(addr-2, true);
cycles += cpu9->CodeCycles;
cpu9->CodeRead32(addr+2, false);
cycles += CurCPU->CodeCycles;
Expand Down Expand Up @@ -437,4 +437,4 @@ void Compiler::T_Comp_BL_Merged()
Comp_JumpTo(target);
}

}
}
4 changes: 2 additions & 2 deletions src/ARMJIT_Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ ARMJIT_Memory::ARMJIT_Memory(melonDS::NDS& nds) : NDS(nds)
}
#else
char fastmemPidName[snprintf(NULL, 0, "/melondsfastmem%d", getpid()) + 1];
sprintf(fastmemPidName, "/melondsfastmem%d", getpid());
snprintf(fastmemPidName, sizeof(fastmemPidName), "/melondsfastmem%d", getpid());
MemoryFile = shm_open(fastmemPidName, O_RDWR | O_CREAT | O_EXCL, 0600);
if (MemoryFile == -1)
{
Expand Down Expand Up @@ -1432,4 +1432,4 @@ void* ARMJIT_Memory::GetFuncForAddr(ARM* cpu, u32 addr, bool store, int size) co
}
return NULL;
}
}
}
2 changes: 0 additions & 2 deletions src/frontend/qt_sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ if (WIN32)
endif()

if (APPLE)
target_sources(melonDS PRIVATE sem_timedwait.cpp)

# Copy icon into the bundle
set(RESOURCE_FILES "${CMAKE_SOURCE_DIR}/res/melon.icns")
target_sources(melonDS PUBLIC "${RESOURCE_FILES}")
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/qt_sdl/CameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void CameraFrameDumper::present(const QVideoFrame& _frame)
case QVideoFrameFormat::Format_NV12:
cam->feedFrame_NV12((u8*)frame.bits(0), (u8*)frame.bits(1), frame.width(), frame.height());
break;
default:
break;
}

frame.unmap();
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/qt_sdl/DateTimeDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DateTimeDialog : public QDialog
void timerEvent(QTimerEvent* event) override;

private slots:
void done(int r);
void done(int r) override;

void on_chkChangeTime_clicked(bool checked);
void on_chkResetTime_clicked(bool checked);
Expand Down
32 changes: 14 additions & 18 deletions src/frontend/qt_sdl/EmuInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,13 +1077,13 @@ std::optional<DSi_NAND::NANDImage> EmuInstance::loadNAND(const std::array<u8, DS
auto firmcfg = localCfg.GetTable("Firmware");

// we store relevant strings as UTF-8, so we need to convert them to UTF-16
auto converter = wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{};
//auto converter = wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{};

// setting up username
std::u16string username = converter.from_bytes(firmcfg.GetString("Username"));
size_t usernameLength = std::min(username.length(), (size_t) 10);
auto username = firmcfg.GetQString("Username");
size_t usernameLength = std::min(username.length(), (qsizetype) 10);
memset(&settings.Nickname, 0, sizeof(settings.Nickname));
memcpy(&settings.Nickname, username.data(), usernameLength * sizeof(char16_t));
memcpy(&settings.Nickname, username.utf16(), usernameLength * sizeof(char16_t));

// setting language
settings.Language = static_cast<Firmware::Language>(firmcfg.GetInt("Language"));
Expand All @@ -1096,10 +1096,10 @@ std::optional<DSi_NAND::NANDImage> EmuInstance::loadNAND(const std::array<u8, DS
settings.BirthdayDay = firmcfg.GetInt("BirthdayDay");

// setup message
std::u16string message = converter.from_bytes(firmcfg.GetString("Message"));
size_t messageLength = std::min(message.length(), (size_t) 26);
auto message = firmcfg.GetQString("Message");
size_t messageLength = std::min(message.length(), (qsizetype) 26);
memset(&settings.Message, 0, sizeof(settings.Message));
memcpy(&settings.Message, message.data(), messageLength * sizeof(char16_t));
memcpy(&settings.Message, message.utf16(), messageLength * sizeof(char16_t));

// TODO: make other items configurable?
}
Expand Down Expand Up @@ -1660,14 +1660,12 @@ void EmuInstance::customizeFirmware(Firmware& firmware, bool overridesettings) n
auto firmcfg = localCfg.GetTable("Firmware");

// setting up username
std::string orig_username = firmcfg.GetString("Username");
if (!orig_username.empty())
auto username = firmcfg.GetQString("Username");
if (!username.isEmpty())
{ // If the frontend defines a username, take it. If not, leave the existing one.
std::u16string username = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(
orig_username);
size_t usernameLength = std::min(username.length(), (size_t) 10);
size_t usernameLength = std::min(username.length(), (qsizetype) 10);
currentData.NameLength = usernameLength;
memcpy(currentData.Nickname, username.data(), usernameLength * sizeof(char16_t));
memcpy(currentData.Nickname, username.utf16(), usernameLength * sizeof(char16_t));
}

auto language = static_cast<Firmware::Language>(firmcfg.GetInt("Language"));
Expand Down Expand Up @@ -1697,12 +1695,10 @@ void EmuInstance::customizeFirmware(Firmware& firmware, bool overridesettings) n
}

// setup message
std::string orig_message = firmcfg.GetString("Message");
if (!orig_message.empty())
auto message = firmcfg.GetQString("Message");
if (!message.isEmpty())
{
std::u16string message = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(
orig_message);
size_t messageLength = std::min(message.length(), (size_t) 26);
size_t messageLength = std::min(message.length(), (qsizetype) 26);
currentData.MessageLength = messageLength;
memcpy(currentData.Message, message.data(), messageLength * sizeof(char16_t));
}
Expand Down
8 changes: 4 additions & 4 deletions src/frontend/qt_sdl/EmuThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ void EmuThread::run()
double actualfps = (59.8261 * 263.0) / nlines;
int inst = emuInstance->instanceID;
if (inst == 0)
sprintf(melontitle, "[%d/%.0f] melonDS " MELONDS_VERSION, fps, actualfps);
snprintf(melontitle, sizeof(melontitle), "[%d/%.0f] melonDS " MELONDS_VERSION, fps, actualfps);
else
sprintf(melontitle, "[%d/%.0f] melonDS (%d)", fps, fpstarget, inst+1);
snprintf(melontitle, sizeof(melontitle), "[%d/%.0f] melonDS (%d)", fps, fpstarget, inst+1);
changeWindowTitle(melontitle);
}
}
Expand All @@ -445,9 +445,9 @@ void EmuThread::run()

int inst = emuInstance->instanceID;
if (inst == 0)
sprintf(melontitle, "melonDS " MELONDS_VERSION);
snprintf(melontitle, sizeof(melontitle), "melonDS " MELONDS_VERSION);
else
sprintf(melontitle, "melonDS (%d)", inst+1);
snprintf(melontitle, sizeof(melontitle), "melonDS (%d)", inst+1);
changeWindowTitle(melontitle);

SDL_Delay(75);
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/qt_sdl/LANDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ void LANDialog::doUpdatePlayerList()
case LAN::Player_Disconnected:
status = "Connection lost";
break;
case LAN::Player_None:
break;
}
model->item(i, 2)->setText(status);

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/qt_sdl/LANDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Q_OBJECT
}

private slots:
void done(int r);
void done(int r) override;

private:
Ui::LANStartHostDialog* ui;
Expand Down Expand Up @@ -76,7 +76,7 @@ private slots:
void onGameSelectionChanged(const QItemSelection& cur, const QItemSelection& prev);
void on_tvAvailableGames_doubleClicked(QModelIndex index);
void onDirectConnect();
void done(int r);
void done(int r) override;

void doUpdateDiscoveryList();

Expand Down Expand Up @@ -105,7 +105,7 @@ Q_OBJECT

private slots:
void on_btnLeaveGame_clicked();
void done(int r);
void done(int r) override;

void doUpdatePlayerList();

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/qt_sdl/MPSettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MPSettingsDialog : public QDialog
}

private slots:
void done(int r);
void done(int r) override;

//

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/qt_sdl/NetplayDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void NetplayDialog::doUpdatePlayerList(Netplay::Player* players, int num)

char ip[32];
u32 addr = player->Address;
sprintf(ip, "%d.%d.%d.%d", addr&0xFF, (addr>>8)&0xFF, (addr>>16)&0xFF, addr>>24);
snprintf(ip, sizeof(ip), "%d.%d.%d.%d", addr&0xFF, (addr>>8)&0xFF, (addr>>16)&0xFF, addr>>24);
model->setItem(i, 4, new QStandardItem(ip));
}
}
4 changes: 2 additions & 2 deletions src/frontend/qt_sdl/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ bool ScreenPanelGL::createContext()
if (ourwin->getWindowID() != 0)
{
if (windowinfo.has_value())
if (glContext = parentwin->getOGLContext()->CreateSharedContext(*windowinfo))
if ((glContext = parentwin->getOGLContext()->CreateSharedContext(*windowinfo)))
glContext->DoneCurrent();
}
else
Expand All @@ -885,7 +885,7 @@ bool ScreenPanelGL::createContext()
GL::Context::Version{GL::Context::Profile::Core, 4, 3},
GL::Context::Version{GL::Context::Profile::Core, 3, 2}};
if (windowinfo.has_value())
if (glContext = GL::Context::Create(*windowinfo, versionsToTry))
if ((glContext = GL::Context::Create(*windowinfo, versionsToTry)))
glContext->DoneCurrent();
}

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/qt_sdl/TitleManagerDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void TitleManagerDialog::createTitleItem(u32 category, u32 titleid)
*(u32*)&gamecode[0] = *(u32*)&header.GameCode[0];
gamecode[4] = '\0';
char extra[128];
sprintf(extra, "\n(title ID: %s · %08x/%08x · version %08x)", gamecode, category, titleid, version);
snprintf(extra, sizeof(extra), "\n(title ID: %s · %08x/%08x · version %08x)", gamecode, category, titleid, version);

QListWidgetItem* item = new QListWidgetItem(title + QString(extra));
item->setIcon(icon);
Expand Down Expand Up @@ -481,7 +481,7 @@ void TitleImportDialog::accept()
network = new QNetworkAccessManager(this);

char url[256];
sprintf(url, "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/%08x%08x/tmd", titleid[1], titleid[0]);
snprintf(url, sizeof(url), "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/%08x%08x/tmd", titleid[1], titleid[0]);

QNetworkRequest req;
req.setUrl(QUrl(url));
Expand Down
12 changes: 6 additions & 6 deletions src/frontend/qt_sdl/WifiSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ void WifiSettingsDialog::on_cbxDirectAdapter_currentIndexChanged(int sel)
melonDS::AdapterData* adapter = &adapters[sel];
char tmp[64];

sprintf(tmp, "%02X:%02X:%02X:%02X:%02X:%02X",
adapter->MAC[0], adapter->MAC[1], adapter->MAC[2],
adapter->MAC[3], adapter->MAC[4], adapter->MAC[5]);
snprintf(tmp, sizeof(tmp), "%02X:%02X:%02X:%02X:%02X:%02X",
adapter->MAC[0], adapter->MAC[1], adapter->MAC[2],
adapter->MAC[3], adapter->MAC[4], adapter->MAC[5]);
ui->lblAdapterMAC->setText(QString(tmp));

sprintf(tmp, "%d.%d.%d.%d",
adapter->IP_v4[0], adapter->IP_v4[1],
adapter->IP_v4[2], adapter->IP_v4[3]);
snprintf(tmp, sizeof(tmp), "%d.%d.%d.%d",
adapter->IP_v4[0], adapter->IP_v4[1],
adapter->IP_v4[2], adapter->IP_v4[3]);
ui->lblAdapterIP->setText(QString(tmp));
}

Expand Down
Loading
Loading