Skip to content

Commit

Permalink
Eliminate UTILS_UNUSED_PARAM(..) macro
Browse files Browse the repository at this point in the history
Unlike C, C++ has the ability to omit parameter names in implemented
interfaces when the parameter is unused, aka "unnamed parameters".

This change does the following:
1. Mechanically replace `UTILS_UNUSED_PARAM(x)` with `/* x */`.
2. Removes all doxygen directives that reference `unused_*`.
3. Removes the `UTILS_UNUSED_PARAM(x)` macro.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
  • Loading branch information
ngie-eign authored and jmmv committed Apr 1, 2019
1 parent 244eb9a commit 892bbc8
Show file tree
Hide file tree
Showing 37 changed files with 103 additions and 308 deletions.
2 changes: 0 additions & 2 deletions Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ JAVADOC_AUTOBRIEF = YES
MACRO_EXPANSION = YES
OUTPUT_DIRECTORY = @top_builddir@/api-docs
OUTPUT_LANGUAGE = English
PREDEFINED = "KYUA_DEFS_UNUSED_PARAM(name)=unused_ ## name"
PREDEFINED += "KYUA_DEFS_NORETURN="
PREDEFINED += "KYUA_DEFS_FORMAT_PRINTF(x, y)="
PREDEFINED += "UTILS_UNUSED_PARAM(name)=unused_ ## name"
PROJECT_NAME = "@PACKAGE_NAME@"
PROJECT_NUMBER = @VERSION@
QUIET = YES
Expand Down
4 changes: 2 additions & 2 deletions admin/check-style-cpp.awk
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ BEGIN {
warn("Use \\n instead of std::endl");
}

/\/\*/ {
warn("Do not use C-style comments");
/\/\*/ && ! /\*\// {
warn("Do not use multi-line C-style comments");
}

END {
Expand Down
12 changes: 3 additions & 9 deletions bootstrap/plain_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ namespace {

/// Prints a fake but valid test case list and then aborts.
///
/// \param unused_argc The original argument count of the program.
/// \param argv The original arguments of the program.
///
/// \return Nothing because this dies before returning.
static int
helper_abort_test_cases_list(int UTILS_UNUSED_PARAM(argc), char** argv)
helper_abort_test_cases_list(int /* argc */, char** argv)
{
for (const char* const* arg = argv; *arg != NULL; arg++) {
if (std::strcmp(*arg, "-l") == 0) {
Expand All @@ -59,26 +58,21 @@ helper_abort_test_cases_list(int UTILS_UNUSED_PARAM(argc), char** argv)

/// Just returns without printing anything as the test case list.
///
/// \param unused_argc The original argument count of the program.
/// \param unused_argv The original arguments of the program.
///
/// \return Always 0, as required for test programs.
static int
helper_empty_test_cases_list(int UTILS_UNUSED_PARAM(argc),
char** UTILS_UNUSED_PARAM(argv))
helper_empty_test_cases_list(int /* argc */, char** /* argv */)
{
return EXIT_SUCCESS;
}


/// Prints a correctly-formatted test case list but empty.
///
/// \param unused_argc The original argument count of the program.
/// \param argv The original arguments of the program.
///
/// \return Always 0, as required for test programs.
static int
helper_zero_test_cases(int UTILS_UNUSED_PARAM(argc), char** argv)
helper_zero_test_cases(int /* argc */, char** argv)
{
for (const char* const* arg = argv; *arg != NULL; arg++) {
if (std::strcmp(*arg, "-l") == 0)
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,12 @@ cmd_about::cmd_about(void) : cli_command(
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if any of the necessary documents cannot be
/// opened.
int
cmd_about::run(cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline,
const config::tree& UTILS_UNUSED_PARAM(user_config))
const config::tree& /* user_config */)
{
const fs::path docdir(utils::getenv_with_default(
"KYUA_DOCDIR", KYUA_DOCDIR));
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd_db_exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,12 @@ cmd_db_exec::cmd_db_exec(void) : cli_command(
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if the statement is invalid or if there is
/// any other problem.
int
cmd_db_exec::run(cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline,
const config::tree& UTILS_UNUSED_PARAM(user_config))
const config::tree& /* user_config */)
{
try {
const fs::path results_file = layout::find_results(
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd_db_migrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ cmd_db_migrate::cmd_db_migrate(void) : cli_command(
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if the statement is invalid or if there is
/// any other problem.
int
cmd_db_migrate::run(cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline,
const config::tree& UTILS_UNUSED_PARAM(user_config))
const config::tree& /* user_config */)
{
try {
const fs::path results_file = layout::find_results(
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,11 @@ cmd_help::cmd_help(const cmdline::options_vector* options_,
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 to indicate success.
int
cmd_help::run(utils::cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline,
const config::tree& UTILS_UNUSED_PARAM(user_config))
const config::tree& /* user_config */)
{
if (cmdline.arguments().empty()) {
general_help(ui, _options, _commands);
Expand Down
22 changes: 6 additions & 16 deletions cli/cmd_help_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,11 @@ class cmd_mock_simple : public cli::cli_command {

/// Runs the mock command.
///
/// \param unused_ui Object to interact with the I/O of the program.
/// \param unused_cmdline Representation of the command line to the
/// subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return Nothing because this function is never called.
int
run(cmdline::ui* UTILS_UNUSED_PARAM(ui),
const cmdline::parsed_cmdline& UTILS_UNUSED_PARAM(cmdline),
const config::tree& UTILS_UNUSED_PARAM(user_config))
run(cmdline::ui* /* ui */,
const cmdline::parsed_cmdline& /* cmdline */,
const config::tree& /* user_config */)
{
UNREACHABLE;
}
Expand All @@ -111,16 +106,11 @@ class cmd_mock_complex : public cli::cli_command {

/// Runs the mock command.
///
/// \param unused_ui Object to interact with the I/O of the program.
/// \param unused_cmdline Representation of the command line to the
/// subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return Nothing because this function is never called.
int
run(cmdline::ui* UTILS_UNUSED_PARAM(ui),
const cmdline::parsed_cmdline& UTILS_UNUSED_PARAM(cmdline),
const config::tree& UTILS_UNUSED_PARAM(user_config))
run(cmdline::ui* /* ui */,
const cmdline::parsed_cmdline& /* cmdline */,
const config::tree& /* user_config */)
{
UNREACHABLE;
}
Expand Down
7 changes: 2 additions & 5 deletions cli/cmd_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,8 @@ class report_console_hooks : public drivers::scan_results::base_hooks {
}

/// Prints the tests summary.
///
/// \param unused_r Result of the scan_results driver execution.
void
end(const drivers::scan_results::result& UTILS_UNUSED_PARAM(r))
end(const drivers::scan_results::result& /* r */)
{
typedef std::map< model::test_result_type, const char* > types_map;

Expand Down Expand Up @@ -398,14 +396,13 @@ cmd_report::cmd_report(void) : cli_command(
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if the statement is invalid or if there is
/// any other problem.
int
cmd_report::run(cmdline::ui* ui,
const cmdline::parsed_cmdline& cmdline,
const config::tree& UTILS_UNUSED_PARAM(user_config))
const config::tree& /* user_config */)
{
std::auto_ptr< std::ostream > output = utils::open_ostream(
cmdline.get_option< cmdline::path_option >("output"));
Expand Down
3 changes: 1 addition & 2 deletions cli/cmd_report_html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,13 @@ cli::cmd_report_html::cmd_report_html(void) : cli_command(
///
/// \param ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if the statement is invalid or if there is
/// any other problem.
int
cli::cmd_report_html::run(cmdline::ui* ui,
const cmdline::parsed_cmdline& cmdline,
const config::tree& UTILS_UNUSED_PARAM(user_config))
const config::tree& /* user_config */)
{
const result_types types = get_result_types(cmdline);

Expand Down
6 changes: 2 additions & 4 deletions cli/cmd_report_junit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,14 @@ cmd_report_junit::cmd_report_junit(void) : cli_command(

/// Entry point for the "report" subcommand.
///
/// \param unused_ui Object to interact with the I/O of the program.
/// \param cmdline Representation of the command line to the subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return 0 if everything is OK, 1 if the statement is invalid or if there is
/// any other problem.
int
cmd_report_junit::run(cmdline::ui* UTILS_UNUSED_PARAM(ui),
cmd_report_junit::run(cmdline::ui* /* ui */,
const cmdline::parsed_cmdline& cmdline,
const config::tree& UTILS_UNUSED_PARAM(user_config))
const config::tree& /* user_config */)
{
const fs::path results_file = layout::find_results(
results_file_open(cmdline));
Expand Down
29 changes: 8 additions & 21 deletions cli/main_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,11 @@ class cmd_mock_crash : public cli::cli_command {

/// Runs the mock command.
///
/// \param unused_ui Object to interact with the I/O of the program.
/// \param unused_cmdline Representation of the command line to the
/// subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return Nothing because this function always aborts.
int
run(cmdline::ui* UTILS_UNUSED_PARAM(ui),
const cmdline::parsed_cmdline& UTILS_UNUSED_PARAM(cmdline),
const config::tree& UTILS_UNUSED_PARAM(user_config))
run(cmdline::ui* /* ui */,
const cmdline::parsed_cmdline& /* cmdline */,
const config::tree& /* user_config */)
{
utils::abort_without_coredump();
}
Expand Down Expand Up @@ -117,19 +112,14 @@ class cmd_mock_error : public cli::cli_command {

/// Runs the mock command.
///
/// \param unused_ui Object to interact with the I/O of the program.
/// \param unused_cmdline Representation of the command line to the
/// subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return Nothing because this function always aborts.
///
/// \throw std::logic_error If _unhandled is true.
/// \throw std::runtime_error If _unhandled is false.
int
run(cmdline::ui* UTILS_UNUSED_PARAM(ui),
const cmdline::parsed_cmdline& UTILS_UNUSED_PARAM(cmdline),
const config::tree& UTILS_UNUSED_PARAM(user_config))
run(cmdline::ui* /* ui */,
const cmdline::parsed_cmdline& /* cmdline */,
const config::tree& /* user_config */)
{
if (_unhandled)
throw std::logic_error("This is unhandled");
Expand All @@ -153,15 +143,12 @@ class cmd_mock_write : public cli::cli_command {
/// Runs the mock command.
///
/// \param ui Object to interact with the I/O of the program.
/// \param unused_cmdline Representation of the command line to the
/// subcommand.
/// \param unused_user_config The runtime configuration of the program.
///
/// \return Nothing because this function always aborts.
int
run(cmdline::ui* ui,
const cmdline::parsed_cmdline& UTILS_UNUSED_PARAM(cmdline),
const config::tree& UTILS_UNUSED_PARAM(user_config))
const cmdline::parsed_cmdline& /* cmdline */,
const config::tree& /* user_config */)
{
ui->out("stdout message from subcommand");
ui->err("stderr message from subcommand");
Expand Down
5 changes: 1 addition & 4 deletions drivers/report_junit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,8 @@ drivers::report_junit_hooks::got_result(store::results_iterator& iter)


/// Finalizes the report.
///
/// \param unused_r The result of the driver execution.
void
drivers::report_junit_hooks::end(
const drivers::scan_results::result& UTILS_UNUSED_PARAM(r))
drivers::report_junit_hooks::end(const drivers::scan_results::result& /* r */)
{
_output << "</testsuite>\n";
}
5 changes: 1 addition & 4 deletions drivers/scan_results.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ drivers::scan_results::base_hooks::begin(void)


/// Callback executed after all operations are performed.
///
/// \param unused_r A structure with all results computed by this driver. Note
/// that this is also returned by the drive operation.
void
drivers::scan_results::base_hooks::end(const result& UTILS_UNUSED_PARAM(r))
drivers::scan_results::base_hooks::end(const result& /* r */)
{
}

Expand Down
12 changes: 3 additions & 9 deletions engine/atf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,12 @@ engine::atf_interface::exec_test(const model::test_program& test_program,
/// \param test_program The test program to execute.
/// \param test_case_name Name of the test case to invoke.
/// \param vars User-provided variables to pass to the test program.
/// \param unused_control_directory Directory where the interface may place
/// control files.
void
engine::atf_interface::exec_cleanup(
const model::test_program& test_program,
const std::string& test_case_name,
const config::properties_map& vars,
const fs::path& UTILS_UNUSED_PARAM(control_directory)) const
const fs::path& /* control_directory */) const
{
utils::setenv("__RUNNING_INSIDE_ATF_RUN", "internal-yes-value");

Expand All @@ -231,18 +229,14 @@ engine::atf_interface::exec_cleanup(
/// the exec_test() method or none if the test timed out.
/// \param control_directory Directory where the interface may have placed
/// control files.
/// \param unused_stdout_path Path to the file containing the stdout of the
/// test.
/// \param unused_stderr_path Path to the file containing the stderr of the
/// test.
///
/// \return A test result.
model::test_result
engine::atf_interface::compute_result(
const optional< process::status >& status,
const fs::path& control_directory,
const fs::path& UTILS_UNUSED_PARAM(stdout_path),
const fs::path& UTILS_UNUSED_PARAM(stderr_path)) const
const fs::path& /* stdout_path */,
const fs::path& /* stderr_path */) const
{
return calculate_atf_result(status, control_directory / result_name);
}
Loading

0 comments on commit 892bbc8

Please sign in to comment.