[ofa-general] [PATCH][TRIVIAL] ibsim: Some cosmetic changes

Hal Rosenstock hnrose at comcast.net
Fri Mar 6 12:50:55 PST 2009


Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>

---
diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c
index ea94fdf..e720f0d 100644
--- a/ibsim/ibsim.c
+++ b/ibsim/ibsim.c
@@ -110,11 +110,10 @@ static size_t make_name(union name_t *name, uint32_t addr, unsigned short port,
 
 static char *get_name(union name_t *name)
 {
-	if (remote_mode) {
+	if (remote_mode)
 		return inet_ntoa(name->name_i.sin_addr);
-	} else {
+	else
 		return name->name_u.sun_path + 1;
-	}
 }
 
 /**
@@ -608,7 +607,7 @@ static int sim_run(int con_fd)
 
 	socket_basename=getenv("IBSIM_SOCKNAME");
 	if(!socket_basename)
-		socket_basename=SIM_BASENAME;
+		socket_basename = SIM_BASENAME;
 
 	if (sim_init_conn(socket_basename) < 0)
 		return -1;
diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index 94e0a14..bbd51b9 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -274,10 +274,9 @@ static void port_change_lid(Port * port, int lid, int lmc)
 	if (lmc > 0)
 		port->lmc = lmc;
 
-	if (port->node->type == SWITCH_NODE) {
-		if (port->node->sw)
-			port->node->sw->portchange = 1;
-	} else if (port->remotenode && port->remotenode->sw)
+	if (port->node->type == SWITCH_NODE && port->node->sw)
+		port->node->sw->portchange = 1;
+	else if (port->remotenode && port->remotenode->sw)
 		port->remotenode->sw->portchange = 1;
 }
 
@@ -580,9 +579,8 @@ static int dump_net(FILE * f, char *line)
 			nports++;
 			dump_switch(f, node->sw);
 		}
-		for (i = 0; i < nports; i++) {
+		for (i = 0; i < nports; i++)
 			dump_port(f, ports + node->portsbase + i, node->type);
-		}
 		nnodes++;
 	}
 
diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
index 15ad8e0..d2c313c 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -222,7 +222,7 @@ static int do_cpi(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 {
 	int status = 0;
 
-	if (op != 1)		// get
+	if (op != IB_MAD_METHOD_GET)
 		status = ERR_METHOD_UNSUPPORTED;
 	memset(data, 0, IB_SMP_DATA_SIZE);
 	mad_set_field(data, 0, IB_CPI_BASEVER_F, 1);
@@ -236,7 +236,7 @@ static int do_nodedesc(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 {
 	int status = 0;
 
-	if (op != 1)		// get
+	if (op != IB_MAD_METHOD_GET)
 		status = ERR_METHOD_UNSUPPORTED;
 	memcpy(data, port->node->nodedesc, IB_SMP_DATA_SIZE);
 
@@ -249,7 +249,7 @@ static int do_nodeinfo(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 	int status = 0;
 	uint64_t portguid = node->nodeguid + port->portnum;
 
-	if (op != IB_MAD_METHOD_GET)	// get
+	if (op != IB_MAD_METHOD_GET)
 		status = ERR_METHOD_UNSUPPORTED;
 	memcpy(data, node->nodeinfo, IB_SMP_DATA_SIZE);
 
@@ -269,7 +269,7 @@ static int do_switchinfo(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 	if (!sw)		// not a Switch?
 		return ERR_ATTR_UNSUPPORTED;
 
-	if (op == 2) {		// Set
+	if (op == IB_MAD_METHOD_SET) {
 		if (mad_get_field(data, 0, IB_SW_STATE_CHANGE_F))
 			sw->portchange = 0;
 		sw->linearFDBtop =
@@ -335,11 +335,10 @@ static int do_sl2vl(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 
 	sl2vl = port->sl2vl + 8 * n;
 
-	if (op == IB_MAD_METHOD_SET) {
+	if (op == IB_MAD_METHOD_SET)
 		memcpy(sl2vl, data, 8);
-	} else {
+	else
 		memcpy(data, sl2vl, 8);
-	}
 
 	return 0;
 }
@@ -374,9 +373,9 @@ static int do_vlarb(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 
 	size *= sizeof(*vlarb);
 
-	if (op == IB_MAD_METHOD_SET) {
+	if (op == IB_MAD_METHOD_SET)
 		memcpy(vlarb, data, size);
-	} else {
+	else {
 		memset(data, 0, IB_SMP_DATA_SIZE);
 		memcpy(data, vlarb, size);
 	}
@@ -421,7 +420,7 @@ do_portinfo(Port * port, unsigned op, uint32_t portnum, uint8_t * data)
 	DEBUG("in node %" PRIx64 " port %" PRIx64 ": port %" PRIx64 " (%d(%d))",
 	      node->nodeguid, port->portguid, p->portguid, p->portnum, portnum);
 
-	if (op == IB_MAD_METHOD_SET) {	// set
+	if (op == IB_MAD_METHOD_SET) {
 		unsigned val;
 		if (node->type != SWITCH_NODE && port->portnum != p->portnum)
 			return ERR_BAD_PARAM;	// on HCA or rtr can't "set" on other port
@@ -497,10 +496,9 @@ static int do_linearforwtbl(Port * port, unsigned op, uint32_t mod,
 	if (mod < 0 || mod > 767)
 		return ERR_BAD_PARAM;
 
-	if (op == IB_MAD_METHOD_SET) {	// Set
+	if (op == IB_MAD_METHOD_SET)
 		mad_get_array(data, 0, IB_LINEAR_FORW_TBL_F,
 			      sw->fdb + mod * 64);
-	}
 
 	mad_set_array(data, 0, IB_LINEAR_FORW_TBL_F, sw->fdb + mod * 64);
 
@@ -527,10 +525,9 @@ static int do_multicastforwtbl(Port * port, unsigned op, uint32_t mod,
 	}
 
 	blockposition = (numBlock32 * NUMBEROFPORTMASK + numPortMsk) * 64;
-	if (op == IB_MAD_METHOD_SET) {	// Set
+	if (op == IB_MAD_METHOD_SET)
 		mad_get_array(data, 0, IB_MULTICAST_FORW_TBL_F,
 			      sw->mfdb + blockposition);
-	}
 	mad_set_array(data, 0, IB_MULTICAST_FORW_TBL_F,
 		      sw->mfdb + blockposition);
 	return 0;
@@ -749,13 +746,10 @@ static int do_portcounters(Port * port, unsigned op, uint32_t unused,
 	memset(&totals, 0, sizeof totals);
 
 	for (i = 0; i <= node->numports; i++) {
-
 		if (!(p = node_get_port(node, i)))
 			return ERR_BAD_PARAM;
-
 		if (op == IB_MAD_METHOD_SET)
 			pc_reset(&p->portcounters, mask);
-
 		pc_sum(&totals, &p->portcounters);
 	}
 
@@ -1117,7 +1111,7 @@ static Port *route_MAD(Port * port, int response, int lid, ib_dr_path_t * path)
 	    direct_route_out_MAD(port, path);
 }
 
-Smpfn *get_handle_fn(ib_rpc_t rpc, int response)
+static Smpfn *get_handle_fn(ib_rpc_t rpc, int response)
 {
 	Smpfn *fn;
 
@@ -1127,14 +1121,14 @@ Smpfn *get_handle_fn(ib_rpc_t rpc, int response)
 	if (rpc.mgtclass == IB_SMI_CLASS || rpc.mgtclass == IB_SMI_DIRECT_CLASS) {
 		if (rpc.attr.id >= IB_ATTR_LAST
 		    || !(fn = attrs[rpc.mgtclass & 0xf][rpc.attr.id]))
-			return 0;	// not supported attribute ???
+			return 0;	// attribute/method not supported ???
 		return fn;
 	}
 
 	if (rpc.mgtclass == IB_PERFORMANCE_CLASS) {
 		if (rpc.attr.id >= IB_GSI_ATTR_LAST
 		    || !(fn = attrs[rpc.mgtclass & 0xf][rpc.attr.id]))
-			return 0;	// not supported attribute ???
+			return 0;	// attribute/method not supported ???
 		return fn;
 	}
 
diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c
index aa91103..13c3b8c 100644
--- a/ibsim/sim_net.c
+++ b/ibsim/sim_net.c
@@ -405,7 +405,7 @@ static int is_linkwidth_valid(int width)
 
 static int is_linkspeed_valid(int speed)
 {
-	/* speed is 2.5G, 5.0G, or 10.0 G */
+	/* speed is 2.5G, 5.0G, or 10.0G */
 	if (speed < 1 || speed > 7) {
 		IBWARN("bad speed %d - should be between 1 to 7", speed);
 		return 0;
diff --git a/umad2sim/sim_client.c b/umad2sim/sim_client.c
index 06bb7a8..eb42a7c 100644
--- a/umad2sim/sim_client.c
+++ b/umad2sim/sim_client.c
@@ -143,11 +143,10 @@ static size_t make_name(union name_t *name, char *host, unsigned port,
 
 static char *get_name(union name_t *name)
 {
-	if (remote_mode) {
+	if (remote_mode)
 		return inet_ntoa(name->name_i.sin_addr);
-	} else {
+	else
 		return name->name_u.sun_path + 1;
-	}
 }
 
 static int sim_attach(int fd, union name_t *name, size_t size)
@@ -159,8 +158,7 @@ static int sim_attach(int fd, union name_t *name, size_t size)
 		DEBUG("attempt to connect to %s (attempt %d)",
 		      get_name(name), retries);
 
-		if ((r =
-		     connect(fd, (struct sockaddr *)name, size)) >= 0)
+		if ((r = connect(fd, (struct sockaddr *)name, size)) >= 0)
 			break;
 
 		if (r < 0 && errno == ECONNREFUSED) {
@@ -217,7 +215,7 @@ static int sim_init(struct sim_client *sc, char *nodeid)
 	socket_basename = getenv("IBSIM_SOCKNAME");
 
 	if(!socket_basename)
-		socket_basename=SIM_BASENAME;
+		socket_basename = SIM_BASENAME;
 
 	if (connect_host && *connect_host)
 		remote_mode = 1;
diff --git a/umad2sim/umad2sim.c b/umad2sim/umad2sim.c
index e13e30a..6b10f28 100644
--- a/umad2sim/umad2sim.c
+++ b/umad2sim/umad2sim.c
@@ -441,8 +441,8 @@ static ssize_t umad2sim_write(struct umad2sim_dev *dev,
 	{ static int err_count;
 	if (++err_count == 15)
 		return -1;
-	if (mad_get_field(umad_get_mad(umad), 0, IB_MAD_METHOD_F) == 0x7) {
-		printf("Drop trap repress...\n");
+	if (mad_get_field(umad_get_mad(umad), 0, IB_MAD_METHOD_F) == IB_MAD_METHOD_TRAP_REPRESS) {
+		printf("Dropping trap repress...\n");
 		return  -1;
 	}
 	}



More information about the general mailing list