[ofa-general] Re: [IBSIM] Parse sim cmds by name not first character
Sasha Khapyorsky
sashak at voltaire.com
Mon Aug 18 13:39:46 PDT 2008
Hi Al,
On 14:07 Wed 13 Aug , Al Chu wrote:
>
> I was looking into adding a new command to ibsim,
Cool :)
> but since the original
> cmd-parsing function only checks for the first char of the inputted
> command, it limits the ability to add a reasonable-sounding new command
> name. The patch changes the function to check the entire command name.
This would break a lot of existing test scripts, so basically I disagree
with such radical change. However we could do something less destructive
and achieve your goal - lets compare string partially as provided:
strncasecmp(line, "Dump", strlen(line))
(or 'strncasecmp(line, "Dump", cmd_len)' if you don't want to put '\0'
into line buffer)
Looks fine?
Also some comment is below.
[snip...]
> From 5871b81d1ebdf86f9a9fcf79c8d8a558fd2600b1 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>
> ---
> ibsim/sim_cmd.c | 105 +++++++++++++++++++++----------------------------------
> 1 files changed, 40 insertions(+), 65 deletions(-)
>
> diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
> index 1f6ba88..a35d0f4 100644
> --- a/ibsim/sim_cmd.c
> +++ b/ibsim/sim_cmd.c
> @@ -757,91 +757,66 @@ int netstarted = 0;
>
> int do_cmd(char *buf, FILE *f)
> {
> + char cmdbuf[4096];
Why this huge buffer? Actually we don't need to copy there just find
appropriate length for comparison, no?
Sasha
More information about the general
mailing list