From patchwork Tue Aug 23 23:41:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 1090422 X-Patchwork-Delegate: ira.weiny@intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7NNfNR6008915 for ; Tue, 23 Aug 2011 23:41:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755990Ab1HWXlS (ORCPT ); Tue, 23 Aug 2011 19:41:18 -0400 Received: from nspiron-3.llnl.gov ([128.115.41.83]:60579 "EHLO smtp.llnl.gov" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755736Ab1HWXlR (ORCPT ); Tue, 23 Aug 2011 19:41:17 -0400 X-Attachments: None Received: from eris.llnl.gov (HELO trebuchet) ([134.9.2.84]) by smtp.llnl.gov with SMTP; 23 Aug 2011 16:41:17 -0700 Date: Tue, 23 Aug 2011 16:41:16 -0700 From: Ira Weiny To: "linux-rdma@vger.kernel.org" Subject: [PATCH] infiniband-diags: ibqueryerrors Clean up exit codes Message-Id: <20110823164116.b624d553.weiny2@llnl.gov> X-Mailer: Sylpheed 3.1.1 (GTK+ 2.18.9; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 23 Aug 2011 23:41:41 +0000 (UTC) Update man page for exit status Signed-off-by: Ira Weiny --- man/ibqueryerrors.8.in | 6 ++++++ src/ibqueryerrors.c | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/man/ibqueryerrors.8.in b/man/ibqueryerrors.8.in index d190715..78323c7 100644 --- a/man/ibqueryerrors.8.in +++ b/man/ibqueryerrors.8.in @@ -97,6 +97,12 @@ for information on caching ibnetdiscover output. .PP \-t override the default timeout for the solicited mads. +.SH EXIT STATUS + +If a failure to scan the fabric occurs return -1. If the scan succeeds without +errors beyond thresholds return 0. If errors are found on ports beyond +thresholds return 1. + .SH FILES @IBDIAG_CONFIG_PATH@/error_thresholds diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c index 6de3d6f..9ea9810 100644 --- a/src/ibqueryerrors.c +++ b/src/ibqueryerrors.c @@ -273,7 +273,7 @@ static void report_suppressed(void) printf("\n"); } -static void print_summary(void) +static int print_summary(void) { printf("\n## Summary: %d nodes checked, %d bad nodes found\n", summary.nodes_checked, summary.bad_nodes); @@ -281,6 +281,7 @@ static void print_summary(void) summary.ports_checked, summary.bad_ports); printf("## %s\n", threshold_str); report_suppressed(); + return (summary.bad_ports); } static int query_and_dump(char *buf, size_t size, ib_portid_t * portid, @@ -879,7 +880,7 @@ int main(int argc, char **argv) if (dr_path && load_cache_file) { fprintf(stderr, "Cannot specify cache and direct route path\n"); - exit(1); + exit(-1); } /* limit the scan the fabric around the target */ @@ -901,7 +902,7 @@ int main(int argc, char **argv) if (load_cache_file) { if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) { fprintf(stderr, "loading cached fabric failed\n"); - exit(1); + exit(-1); } } else { if (resolved >= 0) { @@ -918,7 +919,7 @@ int main(int argc, char **argv) NULL, &config))) { fprintf(stderr, "discover failed\n"); - rc = 1; + rc = -1; goto close_port; } } @@ -951,7 +952,9 @@ int main(int argc, char **argv) } else ibnd_iter_nodes(fabric, print_node, NULL); - print_summary(); + rc = print_summary(); + if (rc) + rc = 1; destroy_fabric: ibnd_destroy_fabric(fabric);