diff --git a/src/report/report.c b/src/report/report.c index fad7fdf363..6909f78455 100644 --- a/src/report/report.c +++ b/src/report/report.c @@ -197,7 +197,7 @@ static int metrics_query(void) { if (!d) { if (errno != ENOENT) return log_error_errno(errno, "Failed to open metrics directory %s: %m", metrics_path); - } else { + } else FOREACH_DIRENT(de, d, return log_warning_errno(errno, "Failed to read %s: %m", metrics_path)) { @@ -215,7 +215,6 @@ static int metrics_query(void) { (void) metrics_call(&context, p); } - } if (set_isempty(context.links)) log_info("No metrics sources found."); @@ -227,18 +226,17 @@ static int metrics_query(void) { r = metrics_output_sorted(&context); if (r < 0) return r; - - if (n_skipped_sources > 0) - log_warning("Too many metrics sources, only %u sources contacted, %zu sources skipped.", set_size(context.links), n_skipped_sources); - if (context.n_skipped_metrics > 0) - log_warning("Too many metrics, only %zu metrics collected, %zu metrics skipped.", context.n_metrics, context.n_skipped_metrics); - - if (n_skipped_sources > 0 || - context.n_skipped_metrics > 0) - return EXIT_FAILURE; } - return EXIT_SUCCESS; + if (n_skipped_sources > 0) + return log_warning_errno(SYNTHETIC_ERRNO(EUCLEAN), + "Too many metrics sources, only %u sources contacted, %zu sources skipped.", + set_size(context.links), n_skipped_sources); + if (context.n_skipped_metrics > 0) + return log_warning_errno(SYNTHETIC_ERRNO(EUCLEAN), + "Too many metrics, only %zu metrics collected, %zu metrics skipped.", + context.n_metrics, context.n_skipped_metrics); + return 0; } static int help(void) { @@ -339,4 +337,4 @@ static int run(int argc, char *argv[]) { return metrics_query(); } -DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run); +DEFINE_MAIN_FUNCTION(run);