[ofa-general] [PATCH] opensm/console: Enhance perfmgr print_counters for better nodenames
Hal Rosenstock
hnrose at comcast.net
Thu Feb 19 05:06:53 PST 2009
nodenames can have spaces in them
Also, no need for next_token being inlined
Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index 00e2a94..9cad594 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -73,11 +73,16 @@ on: 0, delay_s: 2, loop_function:NULL};
static const struct command console_cmds[];
-static inline char *next_token(char **p_last)
+static char *next_token(char **p_last)
{
return strtok_r(NULL, " \t\n\r", p_last);
}
+static char *name_token(char **p_last)
+{
+ return strtok_r(NULL, "\t\n\r", p_last);
+}
+
static void help_command(FILE * out, int detail)
{
int i;
@@ -1152,7 +1157,7 @@ static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
PERFMGR_EVENT_DB_DUMP_HR);
}
} else if (strcmp(p_cmd, "print_counters") == 0) {
- p_cmd = next_token(p_last);
+ p_cmd = name_token(p_last);
if (p_cmd) {
osm_perfmgr_print_counters(&p_osm->perfmgr,
p_cmd, out);
diff --git a/opensm/opensm/osm_perfmgr.c b/opensm/opensm/osm_perfmgr.c
index 3babe3a..8766f93 100644
--- a/opensm/opensm/osm_perfmgr.c
+++ b/opensm/opensm/osm_perfmgr.c
@@ -1304,9 +1304,9 @@ void
osm_perfmgr_print_counters(osm_perfmgr_t *pm, char *nodename, FILE *fp)
{
uint64_t guid = strtoull(nodename, NULL, 0);
- if (guid == 0 && errno == EINVAL)
+ if (guid == 0 && errno) // name
perfmgr_db_print_by_name(pm->db, nodename, fp);
- else
+ else // guid
perfmgr_db_print_by_guid(pm->db, guid, fp);
}
More information about the general
mailing list