[ofa-general] [PATCH] ibsim: Handle sim_init_net errors better

Hal Rosenstock hnrose at comcast.net
Fri Feb 20 12:33:36 PST 2009


Use define rather than constant
Also, cosmetic formatting and fixed some typos

Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
 ibsim/ibsim.c   |    7 ++++---
 ibsim/sim_cmd.c |    6 ++++--
 ibsim/sim_mad.c |    8 ++++----
 ibsim/sim_net.c |    2 +-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c
index 7cea9de..bfc58f5 100644
--- a/ibsim/ibsim.c
+++ b/ibsim/ibsim.c
@@ -379,7 +379,6 @@ static int sim_ctl_get_pkeys(Client * cl, struct sim_ctl * ctl)
 	memcpy(ctl->data, port->pkey_tbl, size);
 	if (size < sizeof(ctl->data))
 		memset(ctl->data + size, 0, sizeof(ctl->data) - size);
-
 	return 0;
 }
 
@@ -730,6 +729,7 @@ int main(int argc, char **argv)
 	extern void free_core(void);
 	char *outfname = 0, *netfile;
 	FILE *infile, *outfile;
+	int status;
 
 	static char const str_opts[] = "rf:dpvIsN:S:P:L:M:l:Vhu";
 	static const struct option long_opts[] = {
@@ -818,8 +818,9 @@ int main(int argc, char **argv)
 		IBPANIC("not enough memory for core structure");
 
 	DEBUG("initializing net \"%s\"", netfile);
-	if (sim_init_net(netfile, outfile) < 0)
-		IBPANIC("sim_init failed");
+	status = sim_init_net(netfile, outfile);
+	if (status < 0)
+		IBPANIC("sim_init failed, status %d", status);
 
 	sim_init_console(outfile);
 
diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index c683224..94e0a14 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -203,7 +203,8 @@ static int do_relink(FILE * f, char *line)
 			return -1;
 		}
 
-		rport = node_get_port(lport->previous_remotenode, lport->previous_remoteport);
+		rport = node_get_port(lport->previous_remotenode,
+				      lport->previous_remoteport);
 
 		if (link_ports(lport, rport) < 0)
 			return -fprintf(f,
@@ -220,7 +221,8 @@ static int do_relink(FILE * f, char *line)
 		if (!lport->previous_remotenode)
 			continue; 
 
-		rport = node_get_port(lport->previous_remotenode, lport->previous_remoteport);
+		rport = node_get_port(lport->previous_remotenode,
+				      lport->previous_remoteport);
 
 		if (link_ports(lport, rport) < 0)
 			continue;
diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
index 6e08031..2fbf96f 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -379,7 +379,7 @@ static int do_vlarb(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 	if (op == IB_MAD_METHOD_SET) {
 		memcpy(vlarb, data, size);
 	} else {
-		memset(data, 0, 64);
+		memset(data, 0, IB_SMP_DATA_SIZE);
 		memcpy(data, vlarb, size);
 	}
 
@@ -395,7 +395,7 @@ static int do_guidinfo(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 	if (op != IB_MAD_METHOD_GET)    // only get currently supported (non compliant)
 		status = ERR_METHOD_UNSUPPORTED;
 
-	memset(data, 0, 64);
+	memset(data, 0, IB_SMP_DATA_SIZE);
 	if (mod == 0) {
 		if (node->type == SWITCH_NODE)
 			mad_encode_field(data, IB_GUID_GUID0_F, &node->nodeguid);
@@ -613,7 +613,7 @@ static int pc_updated(Port ** srcport, Port * destport)
 	uint32_t madsize_div_4 = 72;	//real data divided by 4
 
 	if (*srcport != destport) {
-		//PKT get out of port ..
+		//PKT got out of port ..
 		srcpc->flow_xmt_pkts =
 		    addval(srcpc->flow_xmt_pkts, 1, GS_PERF_XMT_PKTS_LIMIT);
 		srcpc->flow_xmt_bytes =
@@ -629,7 +629,7 @@ static int pc_updated(Port ** srcport, Port * destport)
 			VERB("drop pkt due error rate %d", destport->errrate);
 			return 0;
 		}
-		//PKT get in to the port ..
+		//PKT got into the port ..
 		destpc->flow_rcv_pkts =
 		    addval(destpc->flow_rcv_pkts, 1, GS_PERF_RCV_PKTS_LIMIT);
 		destpc->flow_rcv_bytes =
diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c
index f0628ec..fa05c35 100644
--- a/ibsim/sim_net.c
+++ b/ibsim/sim_net.c
@@ -1116,7 +1116,7 @@ int link_ports(Port * lport, Port * rport)
 	rport->remoteport = lport->portnum;
 	set_portinfo(rport, rnode->type == SWITCH_NODE ? swport : hcaport);
 	memcpy(rport->remotenodeid, lnode->nodeid, sizeof(rport->remotenodeid));
-	lport->state = rport->state = 2;	// Initialilze
+	lport->state = rport->state = 2;	// Initialize
 	lport->physstate = rport->physstate = 5;	// LinkUP
 	if (lnode->sw)
 		lnode->sw->portchange = 1;
-- 
1.5.6.4




More information about the general mailing list