[openib-general] [PATCH 2/13] osm: port to WinIB stack : opensm/osm_prtn_config.c

Eitan Zahavi eitan at mellanox.co.il
Sun Sep 17 08:59:22 PDT 2006


Hi Hal

1. Avoid varargs macros not supported by win
2. Some explicit casting required

Thanks

Eitan

Signed-off-by:  Eitan Zahavi <eitan at mellanox.co.il>

Index: opensm/osm_prtn_config.c
===================================================================
--- opensm/osm_prtn_config.c	(revision 9502)
+++ opensm/osm_prtn_config.c	(working copy)
@@ -66,17 +66,6 @@
 #define STRTO_IB_NET64(str, end, base) strtoull(str, end, base)
 #endif
 
-#define  PARSERR(log, lnum, fmt, arg...) { \
-	osm_log(log, OSM_LOG_ERROR, \
-		"PARSE ERROR: line %d: " fmt , (lnum), ##arg ); \
-	fprintf(stderr, \
-		"\nPARSE ERROR: line %d: " fmt "\n", (lnum), ##arg ); \
-}
-
-#define  PARSEWARN(log, lnum, fmt, arg...) \
-	osm_log(log, OSM_LOG_VERBOSE, \
-		"PARSE WARN: line %d: " fmt , (lnum), ##arg )
-
 /*
  */
 struct part_conf {
@@ -112,7 +101,7 @@ static int partition_create(unsigned lin
 
 	if (id) {
 		char *end;
-		pkey = strtoul(id, &end, 0);
+		pkey = (uint16_t)strtoul(id, &end, 0);
 		if (end == id || *end)
 			return -1;
 	} else
@@ -131,11 +120,11 @@ static int partition_create(unsigned lin
 		  conf->sl = OSM_DEFAULT_SL;
 		}
 	}
-	conf->p_prtn->sl = conf->sl;
+	conf->p_prtn->sl = (uint8_t)conf->sl;
 
 	if (conf->is_ipoib)
 		osm_prtn_add_mcgroup(conf->p_log, conf->p_subn, conf->p_prtn,
-			     conf->is_ipoib, conf->rate, conf->mtu);
+			     conf->is_ipoib, (uint8_t)conf->rate, (uint8_t)conf->mtu);
 
 	return 0;
 }
@@ -148,29 +137,33 @@ static int partition_add_flag(unsigned l
 		conf->is_ipoib = 1;
 	} else if (!strncmp(flag, "mtu", len)) {
 		if (!val || (conf->mtu = strtoul(val, NULL, 0)) == 0)
-			PARSEWARN(conf->p_log, lineno,
-				"flag \'mtu\' requires valid value"
-				" - skipped.\n");
+			osm_log(conf->p_log, OSM_LOG_VERBOSE,
+					  "PARSE WARN: line %d: "
+					  "flag \'mtu\' requires valid value"
+					  " - skipped.\n", lineno);
 	} else if (!strncmp(flag, "rate", len)) {
 		if (!val || (conf->rate = strtoul(val, NULL, 0)) == 0)
-			PARSEWARN(conf->p_log, lineno,
-				"flag \'rate\' requires valid value"
-				" - skipped.\n");
+			osm_log(conf->p_log, OSM_LOG_VERBOSE,
+					  "PARSE WARN: line %d: "
+					  "flag \'rate\' requires valid value"
+					  " - skipped.\n", lineno);
 	} else if (!strncmp(flag, "sl", len)) {
 		unsigned sl;
 		char *end;
 
 		if (!val || !*val || (sl = strtoul(val, &end, 0)) > 15 ||
 		    (*end && !isspace(*end)))
-			PARSEWARN(conf->p_log, lineno,
-				"flag \'sl\' requires valid value"
-				" - skipped.\n");
+			osm_log(conf->p_log, OSM_LOG_VERBOSE,
+					  "PARSE WARN: line %d: "
+					  "flag \'sl\' requires valid value"
+					  " - skipped.\n", lineno);
 		else
 			conf->sl = sl;
 	} else {
-		PARSEWARN(conf->p_log, lineno,
-			"unrecognized partition flag \'%s\'"
-			" - ignored.\n", flag);
+			osm_log(conf->p_log, OSM_LOG_VERBOSE,
+					  "PARSE WARN: line %d: "
+					  "unrecognized partition flag \'%s\'"
+					  " - ignored.\n", lineno, flag);
 	}
 	return 0;
 }
@@ -189,9 +182,10 @@ static int partition_add_port(unsigned l
 		if (!strncmp(flag, "full", strlen(flag)))
 			full = TRUE;
 		else if (strncmp(flag, "limited", strlen(flag))) {
-			PARSEWARN(conf->p_log, lineno,
-				"unrecognized port flag \'%s\'." 
-				" Assume \'limited\'\n", flag);
+			osm_log(conf->p_log, OSM_LOG_VERBOSE,
+					  "PARSE WARN: line %d: "
+					  "unrecognized port flag \'%s\'." 
+					  " Assume \'limited\'\n", lineno, flag);
 		}
 	}
 
@@ -305,8 +299,9 @@ static int parse_part_conf(struct part_c
 
 	q = strchr(p, ':');
 	if (!q) {
-		PARSERR(conf->p_log, lineno,
-			"no partition definition found\n");
+		osm_log(conf->p_log, OSM_LOG_ERROR, 
+				  "PARSE ERROR: line %d: "
+				  "no partition definition found\n", lineno);
 		return -1;
 	}
 
@@ -330,8 +325,9 @@ static int parse_part_conf(struct part_c
 			*q++ = '\0';
 		ret = parse_name_token(p, &flag, &flval);
 		if (!flag) {
-			PARSERR(conf->p_log, lineno,
-				"bad partition flags\n");
+			osm_log(conf->p_log, OSM_LOG_ERROR, 
+					  "PARSE ERROR: line %d: "
+					  "bad partition flags\n",lineno);
 			return -1;
 		}
 		p += ret;
@@ -341,8 +337,9 @@ static int parse_part_conf(struct part_c
 
 	if (p != str || (partition_create(lineno, conf,
 					name, id, flag, flval) < 0)) {
-		PARSERR(conf->p_log, lineno,
-			"bad partition definition\n");
+		osm_log(conf->p_log, OSM_LOG_ERROR, 
+				  "PARSE ERROR: line %d: "	
+				  "bad partition definition\n", lineno);
 		return -1;
 	}
 
@@ -354,8 +351,9 @@ static int parse_part_conf(struct part_c
 			*q++ = '\0';
 		ret = parse_name_token(p, &name, &flag);
 		if (partition_add_port(lineno, conf, name, flag) < 0) {
-			PARSERR(conf->p_log, lineno,
-				"bad PortGUID\n");
+			osm_log(conf->p_log, OSM_LOG_ERROR, 
+					  "PARSE ERROR: line %d: "
+					  "bad PortGUID\n", lineno);
 			return -1;
 		}
 		p += ret;
@@ -404,8 +402,9 @@ int osm_prtn_config_parse_file(osm_log_t
 
 			if (!conf &&
 				!(conf = new_part_conf(p_log, p_subn))) {
-				PARSERR(p_log, lineno,
-					"internal: cannot create config.\n");
+				osm_log(conf->p_log, OSM_LOG_ERROR, 
+						  "PARSE ERROR: line %d: "
+						  "internal: cannot create config.\n", lineno);
 				break;
 			}
 





More information about the general mailing list