[openib-general] [PATCHv2 2/13] osm: port to WinIB stack : opensm/osm_prtn_config.c
Yevgeny Kliteynik
kliteyn at dev.mellanox.co.il
Mon Oct 9 23:25:29 PDT 2006
Hi Hal
This is the re-submission of the patch that was
originally sibmitted by Eitan - avoiding varargs
macros not supported by Windows.
Yevgeny
Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
Index: osm_prtn_config.c
===================================================================
--- osm_prtn_config.c (revision 9759)
+++ 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 {
@@ -150,29 +139,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;
}
@@ -191,9 +184,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);
}
}
@@ -307,8 +301,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;
}
@@ -332,8 +327,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;
@@ -343,8 +339,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;
}
@@ -356,8 +353,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;
@@ -406,8 +404,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