diff --git a/Makefile.in b/Makefile.in index 8dc8df589..2aab6cd61 100644 --- a/Makefile.in +++ b/Makefile.in @@ -508,6 +508,7 @@ check: tests distcheck: $(TARGET) $(TARGET) --capabilities + $(TARGET) --list-modules [ -z "$(GUI_EXE)" ] || $(GUI_EXE) -h # ------------------------------------------------------------------------------------------------- diff --git a/src/lib_common.cpp b/src/lib_common.cpp index b6a87f4ca..34264fd7b 100644 --- a/src/lib_common.cpp +++ b/src/lib_common.cpp @@ -308,7 +308,12 @@ void list_modules(enum library_class cls, int abi_version, bool full) { } } -void list_all_modules() { +/** + * @retval false if there occurs some problem opening one or more modules, true otherwise + */ +bool list_all_modules() { + bool ret = true; + for (auto cls_it = library_class_info.begin(); cls_it != library_class_info.end(); ++cls_it) { cout << cls_it->second.class_name << "\n"; @@ -322,12 +327,15 @@ void list_all_modules() { } if (!lib_errors.empty()) { + ret = false; cout << rang::style::bold << rang::fg::red << "Errors:\n" << rang::fg::reset << rang::style::reset; for (auto && item : lib_errors) { cout << "\t" << rang::fg::red << item.first << rang::fg::reset << "\n\t\t" << item.second << "\n"; } cout << "\n"; } + + return ret; } map get_libraries_for_class(enum library_class cls, int abi_version, bool include_hidden) diff --git a/src/lib_common.h b/src/lib_common.h index 8e1094909..672078ac4 100644 --- a/src/lib_common.h +++ b/src/lib_common.h @@ -86,7 +86,7 @@ enum library_class { const void *load_library(const char *name, enum library_class, int abi_version); void register_library(const char *name, const void *info, enum library_class, int abi_version, int hidden); void list_modules(enum library_class, int abi_version, bool full); -void list_all_modules(); +bool list_all_modules(); #ifdef __cplusplus } #endif diff --git a/src/main.cpp b/src/main.cpp index 72baea08b..6475f4b0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -619,7 +619,7 @@ static bool parse_params(char *optarg) return true; } -#define EXIT(retval) { common_cleanup(init); return retval; } +#define EXIT(expr) { int rc = expr; common_cleanup(init); return rc; } int main(int argc, char *argv[]) { @@ -1068,8 +1068,7 @@ int main(int argc, char *argv[]) video_offset = atoi(optarg) < 0 ? abs(atoi(optarg)) : 0; break; case OPT_LIST_MODULES: - list_all_modules(); - EXIT(EXIT_SUCCESS); + EXIT(list_all_modules() ? EXIT_SUCCESS : EXIT_FAILURE); case OPT_START_PAUSED: start_paused = true; break;