[ofa-general] Re: ibsim parsing question
Sasha Khapyorsky
sashak at voltaire.com
Mon May 12 16:18:31 PDT 2008
On 23:12 Mon 12 May , Sasha Khapyorsky wrote:
> On 13:02 Mon 12 May , Hal Rosenstock wrote:
> >
> > In your previous post, you wrote:
> > "node description value is ignored by ibsim parser in those lines
> > anyway"
> > so that seems like it should be "skipped" rather than treating it like
> > some keyword preceeds it.
>
> Yes, that is correct.
Something like this should help (eg ignore "unknown" options).
Sasha
diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c
index 2a9c19b..6e3c0e9 100644
--- a/ibsim/sim_net.c
+++ b/ibsim/sim_net.c
@@ -432,32 +432,31 @@ static int parse_port_lid_and_lmc(Port * port, char *line)
static int parse_port_opt(Port * port, char *opt, char *val)
{
- int width;
- int speed;
+ int v;
- if (*opt == 'w') {
- width = strtoul(val, 0, 0);
- if (!is_linkwidth_valid(width))
+ switch (*opt) {
+ case 'w':
+ v = strtoul(val, 0, 0);
+ if (!is_linkwidth_valid(v))
return -1;
- port->linkwidthena = width;
+ port->linkwidthena = v;
DEBUG("port %p linkwidth enabled set to %d", port,
port->linkwidthena);
- return 0;
- } else if (*opt == 's') {
- speed = strtoul(val, 0, 0);
-
- if (!is_linkspeed_valid(speed))
+ break;
+ case 's':
+ v = strtoul(val, 0, 0);
+ if (!is_linkspeed_valid(v))
return -1;
- port->linkspeedena = speed;
+ port->linkspeedena = v;
DEBUG("port %p linkspeed enabled set to %d", port,
port->linkspeedena);
- return 0;
- } else {
- IBWARN("unknown opt %c", *opt);
- return -1;
+ break;
+ default:
+ break;
}
+ return 0;
}
static void init_ports(Node * node, int type, int maxports)
More information about the general
mailing list