Skip to content

Commit

Permalink
Fixes warnings as sprintf deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
naussika committed Mar 6, 2023
1 parent 3f6c7ab commit 32f499c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions HexGenerator/Source/Tools/CommandRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ int build_hexfile(
// Move to our Device Source directory
int cd_mod_dir = chdir(module_dir.c_str());
if (cd_mod_dir !=0) {
char msg[50];
sprintf(msg, "chdir() to %s failed with code %d", module_dir.c_str(), cd_mod_dir);
std::cout << msg;
std::cout << "chdir() to " << module_dir << " failed with code " << cd_mod_dir << std::endl;
run_on_main_thread([=]{
QMessageBox box;
box.critical(nullptr, "Error", QString::fromStdString("Failed to change working directory to: " + module_dir));
Expand All @@ -123,7 +121,7 @@ int build_hexfile(

FILE* pipe = popen(command.c_str(), "r");
if (!pipe) {
std::cout << "Failed to create process with command " + command;
std::cout << "Failed to create process with command " << command << std::endl;
run_on_main_thread([=]{
QMessageBox box;
box.critical(nullptr, "Error", QString::fromStdString("Failed to create process for " + module));
Expand All @@ -146,23 +144,21 @@ int build_hexfile(
//TIME_PRINT_
int ret = pclose(pipe)/256;
if (ret != 0) {
std::cout << "error = " << data << std::endl;
char msg[50];
sprintf(msg, "Build process exited with code: %d", ret);
std::string msg = "Build process exited with code: " + std::to_string(ret);
std::cout << msg << std::endl;
run_on_main_thread([=]{
QMessageBox box;
box.critical(nullptr, "Error", msg);
box.critical(nullptr, "Error", QString::fromStdString(msg));
});
}

int cd_back = chdir(cwd);
if ( cd_back !=0) {
char msg[50];
sprintf(msg, "Failed to change back to original working directory: code %d", cd_back);
std::cout << msg;
std::string msg = "Failed to change back to original working directory: code " + std::to_string(cd_back);
std::cout << msg << std::endl;
run_on_main_thread([=]{
QMessageBox box;
box.critical(nullptr, "Error", msg);
box.critical(nullptr, "Error", QString::fromStdString(msg));
});
}
return ret;
Expand Down

0 comments on commit 32f499c

Please sign in to comment.