diff --git a/Source/Core/DolphinTool/ConvertCommand.cpp b/Source/Core/DolphinTool/ConvertCommand.cpp index 386ae2bc8c..d96e571d28 100644 --- a/Source/Core/DolphinTool/ConvertCommand.cpp +++ b/Source/Core/DolphinTool/ConvertCommand.cpp @@ -3,6 +3,7 @@ #include "DolphinTool/ConvertCommand.h" +#include #include #include #include @@ -123,7 +124,7 @@ int ConvertCommand(const std::vector& args) if (input_file_path.empty()) { std::cerr << "Error: No input set" << std::endl; - return 1; + return EXIT_FAILURE; } // --output @@ -131,7 +132,7 @@ int ConvertCommand(const std::vector& args) if (output_file_path.empty()) { std::cerr << "Error: No output set" << std::endl; - return 1; + return EXIT_FAILURE; } // --format @@ -140,7 +141,7 @@ int ConvertCommand(const std::vector& args) if (!format_o.has_value()) { std::cerr << "Error: No output format set" << std::endl; - return 1; + return EXIT_FAILURE; } const DiscIO::BlobType format = format_o.value(); @@ -149,7 +150,7 @@ int ConvertCommand(const std::vector& args) if (!blob_reader) { std::cerr << "Error: The input file could not be opened." << std::endl; - return 1; + return EXIT_FAILURE; } // --scrub @@ -162,7 +163,7 @@ int ConvertCommand(const std::vector& args) if (scrub) { std::cerr << "Error: Scrubbing is only supported for GC/Wii disc images." << std::endl; - return 1; + return EXIT_FAILURE; } std::cerr << "Warning: The input file is not a GC/Wii disc image. Continuing anyway." @@ -174,7 +175,7 @@ int ConvertCommand(const std::vector& args) if (volume->IsDatelDisc()) { std::cerr << "Error: Scrubbing a Datel disc is not supported." << std::endl; - return 1; + return EXIT_FAILURE; } blob_reader = DiscIO::ScrubbedBlob::Create(input_file_path); @@ -182,7 +183,7 @@ int ConvertCommand(const std::vector& args) if (!blob_reader) { std::cerr << "Error: Unable to process disc image. Try again without --scrub." << std::endl; - return 1; + return EXIT_FAILURE; } } @@ -225,13 +226,13 @@ int ConvertCommand(const std::vector& args) if (!block_size_o.has_value()) { std::cerr << "Error: Block size must be set for GCZ/RVZ/WIA" << std::endl; - return 1; + return EXIT_FAILURE; } if (!DiscIO::IsDiscImageBlockSizeValid(block_size_o.value(), format)) { std::cerr << "Error: Block size is not valid for this format" << std::endl; - return 1; + return EXIT_FAILURE; } if (block_size_o.value() < DiscIO::PREFERRED_MIN_BLOCK_SIZE || @@ -265,7 +266,7 @@ int ConvertCommand(const std::vector& args) if (!compression_o.has_value()) { std::cerr << "Error: Compression format must be set for WIA or RVZ" << std::endl; - return 1; + return EXIT_FAILURE; } if ((format == DiscIO::BlobType::WIA && @@ -274,7 +275,7 @@ int ConvertCommand(const std::vector& args) compression_o.value() == DiscIO::WIARVZCompressionType::Purge)) { std::cerr << "Error: Compression type is not supported for the container format" << std::endl; - return 1; + return EXIT_FAILURE; } if (compression_o.value() == DiscIO::WIARVZCompressionType::None) @@ -287,7 +288,7 @@ int ConvertCommand(const std::vector& args) { std::cerr << "Error: Compression level must be set when compression type is not 'none'" << std::endl; - return 1; + return EXIT_FAILURE; } const std::pair range = @@ -295,7 +296,7 @@ int ConvertCommand(const std::vector& args) if (compression_level_o.value() < range.first || compression_level_o.value() > range.second) { std::cerr << "Error: Compression level not in acceptable range" << std::endl; - return 1; + return EXIT_FAILURE; } } } @@ -349,9 +350,9 @@ int ConvertCommand(const std::vector& args) if (!success) { std::cerr << "Error: Conversion failed" << std::endl; - return 1; + return EXIT_FAILURE; } - return 0; + return EXIT_SUCCESS; } } // namespace DolphinTool diff --git a/Source/Core/DolphinTool/HeaderCommand.cpp b/Source/Core/DolphinTool/HeaderCommand.cpp index ab237efd88..aba6c0883f 100644 --- a/Source/Core/DolphinTool/HeaderCommand.cpp +++ b/Source/Core/DolphinTool/HeaderCommand.cpp @@ -3,6 +3,7 @@ #include "DolphinTool/HeaderCommand.h" +#include #include #include #include @@ -46,7 +47,7 @@ int HeaderCommand(const std::vector& args) if (input_file_path.empty()) { std::cerr << "Error: No input set" << std::endl; - return 1; + return EXIT_FAILURE; } const bool enable_block_size = options.is_set_by_user("block_size"); @@ -58,7 +59,7 @@ int HeaderCommand(const std::vector& args) if (!blob_reader) { std::cerr << "Error: Unable to open disc image" << std::endl; - return 1; + return EXIT_FAILURE; } if (enable_block_size || enable_compression_method || enable_compression_level) @@ -104,6 +105,6 @@ int HeaderCommand(const std::vector& args) } } - return 0; + return EXIT_SUCCESS; } } // namespace DolphinTool diff --git a/Source/Core/DolphinTool/ToolMain.cpp b/Source/Core/DolphinTool/ToolMain.cpp index 7dae146082..db6eb30c40 100644 --- a/Source/Core/DolphinTool/ToolMain.cpp +++ b/Source/Core/DolphinTool/ToolMain.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include #include @@ -16,12 +17,10 @@ #include "DolphinTool/HeaderCommand.h" #include "DolphinTool/VerifyCommand.h" -static int PrintUsage(int code) +static void PrintUsage() { std::cerr << "usage: dolphin-tool COMMAND -h" << std::endl << std::endl; std::cerr << "commands supported: [convert, verify, header]" << std::endl; - - return code; } #ifdef _WIN32 @@ -33,7 +32,10 @@ int main(int argc, char* argv[]) Core::DeclareAsHostThread(); if (argc < 2) - return PrintUsage(1); + { + PrintUsage(); + return EXIT_FAILURE; + } const std::string_view command_str = argv[1]; // Take off the program name and command selector before passing arguments down @@ -45,7 +47,8 @@ int main(int argc, char* argv[]) return DolphinTool::VerifyCommand(args); else if (command_str == "header") return DolphinTool::HeaderCommand(args); - return PrintUsage(1); + PrintUsage(); + return EXIT_FAILURE; } #ifdef _WIN32 diff --git a/Source/Core/DolphinTool/VerifyCommand.cpp b/Source/Core/DolphinTool/VerifyCommand.cpp index c27c02c646..3c3af0d358 100644 --- a/Source/Core/DolphinTool/VerifyCommand.cpp +++ b/Source/Core/DolphinTool/VerifyCommand.cpp @@ -3,6 +3,7 @@ #include "DolphinTool/VerifyCommand.h" +#include #include #include @@ -112,7 +113,7 @@ int VerifyCommand(const std::vector& args) if (input_file_path.empty()) { std::cerr << "Error: No input set" << std::endl; - return 1; + return EXIT_FAILURE; } DiscIO::Hashes hashes_to_calculate{}; @@ -136,7 +137,7 @@ int VerifyCommand(const std::vector& args) { // optparse should protect from this std::cerr << "Error: No algorithms selected for the operation" << std::endl; - return 1; + return EXIT_FAILURE; } // Open the volume @@ -144,7 +145,7 @@ int VerifyCommand(const std::vector& args) if (!volume) { std::cerr << "Error: Unable to open disc image" << std::endl; - return 1; + return EXIT_FAILURE; } // Verify the volume @@ -173,10 +174,10 @@ int VerifyCommand(const std::vector& args) else { std::cerr << "Error: No hash computed" << std::endl; - return 1; + return EXIT_FAILURE; } } - return 0; + return EXIT_SUCCESS; } } // namespace DolphinTool