components/open-fabrics/infiniband-diags/patches/base.patch
branchs11-update
changeset 3679 c058dce9610f
parent 2867 573013b5a562
child 4996 739983ef315c
--- a/components/open-fabrics/infiniband-diags/patches/base.patch	Tue Jan 20 05:18:57 2015 -0800
+++ b/components/open-fabrics/infiniband-diags/patches/base.patch	Fri Jan 23 08:29:14 2015 -0800
@@ -1,3 +1,6 @@
+# This patch was developed in-house. Since it is Solaris-specific,
+# it is not suitable for upstream.
+#
 diff -r -u /tmp/infiniband-diags-1.5.8/Makefile.am infiniband-diags-1.5.8/Makefile.am
 --- /tmp/infiniband-diags-1.5.8/Makefile.am	Wed Feb 16 02:13:21 2011
 +++ infiniband-diags-1.5.8/Makefile.am	Fri Feb 25 03:09:22 2011
@@ -1803,16 +1806,17 @@
 diff -r -u /tmp/infiniband-diags-1.5.8/src/saquery.c infiniband-diags-1.5.8/src/saquery.c
 --- /tmp/infiniband-diags-1.5.8/src/saquery.c	Wed Feb 16 02:13:21 2011
 +++ infiniband-diags-1.5.8/src/saquery.c	Thu Jun 23 10:36:40 2011
-@@ -105,7 +105,7 @@
+@@ -104,8 +104,7 @@
+ /**
   * Declare some globals because I don't want this to be too complex.
   */
- #define MAX_PORTS (8)
+-#define MAX_PORTS (8)
 -#define DEFAULT_SA_TIMEOUT_MS (1000)
 +#define DEFAULT_SA_TIMEOUT_MS (10000)
  static struct query_res result;
  
  enum {
-@@ -1757,7 +1757,7 @@
+@@ -1757,7 +1756,7 @@
  			requested_lid = (uint16_t) strtoul(argv[0], NULL, 0);
  			requested_lid_flag++;
  		} else if (node_print_desc == NAME_OF_GUID) {
@@ -1868,7 +1872,54 @@
 diff -r -u /tmp/infiniband-diags-1.5.8/src/ibstat.c infiniband-diags-1.5.8/src/ibstat.c
 --- /tmp/infiniband-diags-1.5.8/src/ibstat.c	Wed Feb 16 02:13:21 2011
 +++ infiniband-diags-1.5.8/src/ibstat.c	Fri Feb 25 03:09:28 2011
-@@ -245,7 +245,7 @@
+@@ -46,6 +46,7 @@
+ 
+ #include <infiniband/umad.h>
+ #include <infiniband/mad.h>
++#include <infiniband/verbs.h>
+ 
+ #include <ibdiag_common.h>
+ 
+@@ -78,7 +79,7 @@
+ }
+ 
+ static char *port_state_str[] = {
+-	"???",
++	"Unknown",
+ 	"Down",
+ 	"Initializing",
+ 	"Armed",
+@@ -112,10 +113,10 @@
+ 	printf("%sPort %d:\n", hdrpre, port->portnum);
+ 	printf("%sState: %s\n", pre,
+ 	       (unsigned)port->state <=
+-	       4 ? port_state_str[port->state] : "???");
++	       4 ? port_state_str[port->state] : "Unknown");
+ 	printf("%sPhysical state: %s\n", pre,
+ 	       (unsigned)port->phys_state <=
+-	       7 ? port_phy_state_str[port->phys_state] : "???");
++	       7 ? port_phy_state_str[port->phys_state] : "Unknown");
+ 	printf("%sRate: %d\n", pre, port->rate);
+ 	printf("%sBase lid: %d\n", pre, port->base_lid);
+ 	printf("%sLMC: %d\n", pre, port->lmc);
+@@ -167,13 +168,13 @@
+ 
+ static int ports_list(char names[][UMAD_CA_NAME_LEN], int n)
+ {
+-	uint64_t guids[64];
++	uint64_t guids[MAX_PORTS];
+ 	int found, ports, i;
+ 
+-	for (i = 0, found = 0; i < n && found < 64; i++) {
++	for (i = 0, found = 0; i < n && found < MAX_PORTS; i++) {
+ 		if ((ports =
+ 		     umad_get_ca_portguids(names[i], guids + found,
+-					   64 - found)) < 0)
++					   MAX_PORTS - found)) < 0)
+ 			return -1;
+ 		found += ports;
+ 	}
+@@ -245,7 +246,7 @@
  		if (i >= n)
  			IBPANIC("'%s' IB device can't be found", argv[0]);
  
@@ -1880,7 +1931,18 @@
 diff -r -u /tmp/infiniband-diags-1.5.8/src/ibdiag_common.c infiniband-diags-1.5.8/src/ibdiag_common.c
 --- /tmp/infiniband-diags-1.5.8/src/ibdiag_common.c	Wed Feb 16 02:13:21 2011
 +++ infiniband-diags-1.5.8/src/ibdiag_common.c	Tue May  3 13:50:05 2011
-@@ -330,7 +330,7 @@
+@@ -322,15 +322,17 @@
+ 	char buf[512];
+ 	va_list va;
+ 	int n;
++	int bufsz;
+ 
+ 	va_start(va, msg);
+-	n = vsprintf(buf, msg, va);
++	bufsz = strlen(msg) < sizeof (buf) ? strlen(msg) : sizeof (buf);
++	n = vsnprintf(buf, bufsz, msg, va);
+ 	va_end(va);
+ 	buf[n] = 0;
  
  	if (ibdebug)
  		printf("%s: iberror: [pid %d] %s: failed: %s\n",