Skip to contentSkip to conversation

opensm/osm_torus.c: Consolidate some parsing with parse_unsigned

PATCH In review Hal Rosenstock 2 participants 2 messages Jan 7, 2013 – Jan 30, 2013 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 opensm/osm_torus.c: Consolidate some parsing with parse_unsigned

---

opensm/osm_torus.c +4 -16
index 1d847b3..ff83edb 100644
@@ -853,14 +853,14 @@ out:
 }
 
 static
-bool parse_port(unsigned *pnum, const char *parse_sep)
+bool parse_unsigned(unsigned *result, const char *parse_sep)
 {
 	char *val, *nextchar;
 
 	val = strtok(NULL, parse_sep);
 	if (!val)
 		return false;
-	*pnum = strtoul(val, &nextchar, 0);
+	*result = strtoul(val, &nextchar, 0);
 	return true;
 }
 
@@ -870,7 +870,7 @@ bool parse_port_order(struct torus *t, unsigned port_order[], const char *parse_
 	unsigned i, j, k, n;
 
 	for (i = 0; i < ARRAY_SIZE(port_order); i++) {
-		if (!parse_port(&(port_order[i]), parse_sep))
+		if (!parse_unsigned(&(port_order[i]), parse_sep))
 			break;
 
 		for (j = 0; j < i; j++) {
@@ -898,18 +898,6 @@ bool parse_port_order(struct torus *t, unsigned port_order[], const char *parse_
 }
 
 static
-bool parse_pg_max_ports(struct torus *t, const char *parse_sep)
-{
-	char *val, *nextchar;
-
-	val = strtok(NULL, parse_sep);
-	if (!val)
-		return false;
-	t->portgrp_sz = strtoul(val, &nextchar, 0);
-	return true;
-}
-
-static
 bool parse_guid(struct torus *t, guid_t *guid, const char *parse_sep)
 {
 	char *val;
@@ -1094,7 +1082,7 @@ next_line:
 		kw_success = grow_seed_array(t, 1);
 		t->seed_cnt++;
 	} else if (strcmp("portgroup_max_ports", keyword) == 0) {
-		kw_success = parse_pg_max_ports(t, parse_sep);
+		kw_success = parse_unsigned(&t->portgrp_sz, parse_sep);
 	} else if (strcmp("xp_link", keyword) == 0) {
 		if (!t->seed_cnt)
 			t->seed_cnt++;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 50EB26FF.5080507-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org