[ofa-general] Re: [IBSIM] Parse sim cmds by name not first character
Al Chu
chu11 at llnl.gov
Tue Aug 19 14:22:43 PDT 2008
Hey Sasha,
On Tue, 2008-08-19 at 22:13 +0300, Sasha Khapyorsky wrote:
> On 17:39 Mon 18 Aug , Al Chu wrote:
> > From 8a1f05b353469054564da75663e3a95744a1f8ec Mon Sep 17 00:00:00 2001
> > From: Albert Chu <chu11 at llnl.gov>
> > Date: Wed, 13 Aug 2008 13:53:14 -0700
> > Subject: [PATCH] parse sim cmds via full name
> >
> >
> > Signed-off-by: Albert Chu <chu11 at llnl.gov>
>
> Applied. Thanks.
>
> When testing this, I paid attention that originally "#" command was
> used for printing line. Frankly I have no idea why it was needed, but put
> it back anyway. Also some flow simplification. Looks fine for you?
Looks fine to me. Thanks.
Al
> Sasha
>
>
> From aa5ee3a71a4b3bd39e0d258614be7db6f1d640a6 Mon Sep 17 00:00:00 2001
> From: Sasha Khapyorsky <sashak at voltaire.com>
> Date: Tue, 19 Aug 2008 22:06:50 +0300
> Subject: [PATCH] ibsim/sim_cmd: consolidate flows
>
> Consolidate and simplify flow. Return back line printing on '#' command.
>
> Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
> ---
> ibsim/sim_cmd.c | 22 +++++++---------------
> 1 files changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
> index 4d70517..d55fb4c 100644
> --- a/ibsim/sim_cmd.c
> +++ b/ibsim/sim_cmd.c
> @@ -762,16 +762,14 @@ int do_cmd(char *buf, FILE *f)
>
> for (line = buf; *line && isspace(*line); line++) ;
>
> - /* special cases */
> - if (*line == '!')
> - r = sim_cmd_file(f, line);
> - else if (*line == '#' || *line == '\n' || *line == '\0')
> - goto out;
> -
> while (!isspace(line[cmd_len]))
> cmd_len++;
>
> - if (!strncasecmp(line, "Dump", cmd_len))
> + if (*line == '#')
> + fprintf(f, line);
> + else if (*line == '!')
> + r = sim_cmd_file(f, line);
> + else if (!strncasecmp(line, "Dump", cmd_len))
> r = dump_net(f, line);
> else if (!strncasecmp(line, "Route", cmd_len))
> r = dump_route(f, line);
> @@ -816,14 +814,8 @@ int do_cmd(char *buf, FILE *f)
> *
> * please specify new command support below this comment.
> */
> - else {
> - char cmdbuf[cmd_len+1];
> -
> - memset(cmdbuf, '\0', cmd_len+1);
> - strncpy(cmdbuf, line, cmd_len);
> + else if (*line != '\n' && *line != '\0')
> + fprintf(f, "command \'%s\' unknown - skipped\n", line);
>
> - fprintf(f, "command %s unknown - skipped\n", cmdbuf);
> - }
> -out:
> return r;
> }
--
Albert Chu
chu11 at llnl.gov
925-422-5311
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory
More information about the general
mailing list