diff mbox

[1/1] opensm/main.c: opensm cannot be killed while asking for port guid

Message ID 4AF46DEB.7090105@sgi.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Michael Reed Nov. 6, 2009, 6:41 p.m. UTC
None
diff mbox

Patch

--- /tmp/OFED-1.5-rc2/main.c	2009-11-06 08:56:59.089100487 -0800
+++ opensm/main.c	2009-11-06 09:42:34.698963811 -0800
@@ -434,15 +434,19 @@  static ib_net64_t get_port_guid(IN osm_o
 			       i + 1, cl_ntoh64(attr_array[i].port_guid),
 			       attr_array[i].lid,
 			       ib_get_port_state_str(attr_array[i].link_state));
-		printf("\nEnter choice (1-%u): ", i);
+		printf("\n\t0: Exit\n");
+		printf("\nEnter choice (0-%u): ", i);
 		fflush(stdout);
 		if (scanf("%u", &choice) <= 0) {
 			char junk[128];
 			if (scanf("%s", junk) <= 0)
 				printf("\nError: Cannot scan!\n");
-		} else if (choice && choice <= num_ports)
+		}
+		else if (choice == 0)
+			return (0);
+		else if (choice <= num_ports)
 			break;
-		printf("\nError: Lame choice!\n");
+		printf("\nError: Please try again.\n");
 	}
 	choice--;
 	printf("Choice guid=0x%" PRIx64 "\n",
@@ -1039,6 +1043,9 @@  int main(int argc, char *argv[])
 	if (opt.guid == 0 || cl_hton64(opt.guid) == CL_HTON64(INVALID_GUID))
 		opt.guid = get_port_guid(&osm, opt.guid);
 
+	if (opt.guid == 0)
+		goto Exit;
+
 	status = osm_opensm_bind(&osm, opt.guid);
 	if (status != IB_SUCCESS) {
 		printf("\nError from osm_opensm_bind (0x%X)\n", status);