public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
To: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH 1/3] infiniband-diags: saquery, exit with ENODEV when queries fail to find results
Date: Fri, 8 Apr 2011 13:45:08 -0700	[thread overview]
Message-ID: <20110408134508.dfd7e8b9.weiny2@llnl.gov> (raw)


Subject: [PATCH 1/3] infiniband-diags: saquery, exit with ENODEV when queries fail to find results

Signed-off-by: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
---
 src/saquery.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/saquery.c b/src/saquery.c
index 03869e3..d7c8e6f 100644
--- a/src/saquery.c
+++ b/src/saquery.c
@@ -876,6 +876,9 @@ static int get_and_dump_any_records(bind_handle_t h, uint16_t attr_id,
 	if (ret)
 		return ret;
 
+	if (result.result_cnt == 0)
+		return ENODEV;
+
 	dump_results(&result, dump_func);
 
 	return 0;
@@ -896,7 +899,14 @@ static int get_and_dump_all_records(bind_handle_t h, uint16_t attr_id,
 	if (ret)
 		return ret;
 
+	if (result.result_cnt == 0) {
+		ret = ENODEV;
+		goto Exit;
+	}
+
 	dump_results(&result, dump_func);
+
+Exit:
 	return_mad();
 	return ret;
 }
@@ -915,7 +925,7 @@ static int get_lid_from_name(bind_handle_t h, const char *name, uint16_t * lid)
 	if (ret)
 		return ret;
 
-	ret = IB_NOT_FOUND;
+	ret = ENODEV;
 	for (i = 0; i < result.result_cnt; i++) {
 		node_record = get_query_rec(result.p_result_madw, i);
 		p_ni = &(node_record->node_info);
@@ -924,7 +934,7 @@ static int get_lid_from_name(bind_handle_t h, const char *name, uint16_t * lid)
 			       sizeof(node_record->node_desc.description)) ==
 		    0) {
 			*lid = cl_ntoh16(node_record->lid);
-			ret = IB_SUCCESS;
+			ret = 0;
 			break;
 		}
 	}
@@ -939,7 +949,7 @@ static uint16_t get_lid(bind_handle_t h, const char *name)
 	if (!name)
 		return 0;
 	if (isalpha(name[0])) {
-		if (get_lid_from_name(h, name, &rc_lid) != IB_SUCCESS) {
+		if (get_lid_from_name(h, name, &rc_lid) != 0) {
 			fprintf(stderr, "Failed to find lid for \"%s\"\n", name);
 			exit(EINVAL);
 		}
@@ -1040,6 +1050,8 @@ static int print_node_records(bind_handle_t h)
 	if (ret)
 		return ret;
 
+	ret = ENODEV;
+
 	if (node_print_desc == ALL_DESC) {
 		printf("   LID \"name\"\n");
 		printf("================\n");
@@ -1049,14 +1061,18 @@ static int print_node_records(bind_handle_t h)
 		node_record = get_query_rec(result.p_result_madw, i);
 		if (node_print_desc == ALL_DESC) {
 			print_node_desc(node_record);
+			ret = 0;
 		} else if (node_print_desc == NAME_OF_LID) {
-			if (requested_lid == cl_ntoh16(node_record->lid))
+			if (requested_lid == cl_ntoh16(node_record->lid)) {
 				print_node_record(node_record);
+				ret = 0;
+			}
 		} 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))
+			if (requested_guid == cl_ntoh64(p_ni->port_guid)) {
 				print_node_record(node_record);
+				ret = 0;
+			}
 		} else {
 			if (!requested_name ||
 			    (strncmp(requested_name,
@@ -1068,6 +1084,7 @@ static int print_node_records(bind_handle_t h)
 					return_mad();
 					exit(0);
 				}
+				ret = 0;
 			}
 		}
 	}
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2011-04-08 20:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-08 20:45 Ira Weiny [this message]
     [not found] ` <20110408134508.dfd7e8b9.weiny2-i2BcT+NCU+M@public.gmane.org>
2011-04-09 12:04   ` [PATCH 1/3] infiniband-diags: saquery, exit with ENODEV when queries fail to find results Hal Rosenstock
     [not found]     ` <4DA04B46.4090400-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2011-04-13 16:41       ` Ira Weiny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110408134508.dfd7e8b9.weiny2@llnl.gov \
    --to=weiny2-i2bct+ncu+m@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox