Hey Sasha,

If an input into saquery isn't found, saquery still exits with '0'
status, so it poses a problem in scripting.

This patch exits w/ non-zero if the input isn't found by saquery.

The actual status code I selected to return can be revised.  I just sort
of picked one.

Al

-- 
Albert Chu
[EMAIL PROTECTED]
925-422-5311
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory
>From 5c767f65b768863ba4ae6482ff4249c7de80692b Mon Sep 17 00:00:00 2001
From: Albert L. Chu <[EMAIL PROTECTED]>
Date: Tue, 1 Apr 2008 11:19:30 -0700
Subject: [PATCH] exit non-zero if saquery input not found


Signed-off-by: Albert L. Chu <[EMAIL PROTECTED]>
---
 infiniband-diags/src/saquery.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/infiniband-diags/src/saquery.c b/infiniband-diags/src/saquery.c
index ed61721..f801385 100644
--- a/infiniband-diags/src/saquery.c
+++ b/infiniband-diags/src/saquery.c
@@ -839,6 +839,7 @@ print_node_records(osm_bind_handle_t bind_handle)
 	ib_node_record_t *node_record = NULL;
 	ib_net16_t        attr_offset = ib_get_attr_offset(sizeof(*node_record));
 	ib_api_status_t   status;
+	unsigned int      output_count = 0;
 
 	status  = get_all_records(bind_handle, IB_MAD_ATTR_NODE_RECORD, attr_offset, 0);
 	if (status != IB_SUCCESS)
@@ -855,12 +856,14 @@ print_node_records(osm_bind_handle_t bind_handle)
 		} else if (node_print_desc == NAME_OF_LID) {
 			if (requested_lid == cl_ntoh16(node_record->lid)) {
 				print_node_record(node_record);
+				output_count++;
 			}
 		} else if (node_print_desc == NAME_OF_GUID) {
 			ib_node_info_t *p_ni = &(node_record->node_info);
 
 			if (requested_guid == cl_ntoh64(p_ni->port_guid)) {
 				print_node_record(node_record);
+				output_count++;
 			}
 		} else {
 			if (!requested_name ||
@@ -868,6 +871,7 @@ print_node_records(osm_bind_handle_t bind_handle)
 				     (char *)node_record->node_desc.description,
 				     sizeof(node_record->node_desc.description)) == 0)) {
 				print_node_record(node_record);
+				output_count++;
 				if (node_print_desc == UNIQUE_LID_ONLY) {
 					return_mad();
 					exit(0);
@@ -876,6 +880,15 @@ print_node_records(osm_bind_handle_t bind_handle)
 		}
 	}
 	return_mad();
+	if ((requested_lid_flag
+	     || requested_guid_flag
+	     || requested_name)
+	    && !output_count) {
+		/* need non-zero error code to indicate input not matched.
+		 * this seems as good as any other status error code.
+		 */ 
+		status = IB_NOT_FOUND;
+	}
 	return (status);
 }
 
-- 
1.5.1

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to