diff options
| author | martin <martin@NetBSD.org> | 2007-10-12 09:53:07 +0000 |
|---|---|---|
| committer | martin <martin@NetBSD.org> | 2007-10-12 09:53:07 +0000 |
| commit | 28da38cbee146b7fcd367566908ffdc37fbbf077 (patch) | |
| tree | 07854bfcc684e38b205bb38ff73905783dc9672c /sys/ddb/db_command.c | |
| parent | 5b3a72667324a65daf4852ab1c7dc8f9980aef77 (diff) | |
Fix command name matching, avoid jumps to null function pointers and
some minor cosmetics.
Diffstat (limited to 'sys/ddb/db_command.c')
| -rw-r--r-- | sys/ddb/db_command.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 8b17bd2d544..2a4e3247c3c 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.106 2007/10/08 15:06:26 martin Exp $ */ +/* $NetBSD: db_command.c,v 1.107 2007/10/12 09:53:07 martin Exp $ */ /* * Mach Operating System * Copyright (c) 1991,1990 Carnegie Mellon University @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.106 2007/10/08 15:06:26 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.107 2007/10/12 09:53:07 martin Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -335,7 +335,7 @@ static const struct db_command db_command_table[] = { "[/bhl] address value [mask] [,count]",NULL) }, { DDB_ADD_CMD("set", db_set_cmd, CS_OWN, "Set the named variable","$variable [=] expression",NULL) }, - { DDB_ADD_CMD("show", NULL ,CS_SHOW, + { DDB_ADD_CMD("show", NULL, CS_SHOW, "Show kernel stats.", NULL,NULL) }, { DDB_ADD_CMD("sifting", db_sifting_cmd, CS_OWN, "Search the symbol tables ","[/F] string",NULL) }, @@ -590,20 +590,19 @@ db_cmd_search(const char *name,const struct db_command *table, for (cmd = table; cmd->name != 0; cmd++) { const char *lp; const char *rp; - int c; lp = name; rp = cmd->name; - while ((c = *lp) == *rp) { - if (c == 0) { - /* complete match */ - *cmdp = cmd; - return (CMD_UNIQUE); - } - lp++; + while (*lp == *rp) { rp++; + lp++; + } + if (*rp == '\0' && *lp == '\0') { + /* complete match */ + *cmdp = cmd; + return (CMD_UNIQUE); } - if (c == 0) { + if (*lp == '\0') { /* end of name, not end of command - partial match */ if (result == CMD_FOUND) { @@ -789,13 +788,14 @@ db_command(const struct db_command **last_cmdp) switch(db_get_list_type(db_tok_string)) { case DDB_BASE_CMD: - list=&db_base_cmd_list; + list = &db_base_cmd_list; break; + case DDB_SHOW_CMD: - list=&db_show_cmd_list; + list = &db_show_cmd_list; /* need to read show subcommand if show command list is used. */ - t = db_read_token(); + t = db_read_token(); if (t != tIDENT) { /* if only show command is executed, print @@ -806,7 +806,7 @@ db_command(const struct db_command **last_cmdp) } break; case DDB_MACH_CMD: - list=&db_mach_cmd_list; + list = &db_mach_cmd_list; /* need to read machine subcommand if machine level 2 command list is used. */ t = db_read_token(); @@ -826,7 +826,7 @@ db_command(const struct db_command **last_cmdp) } COMPAT_RET: - TAILQ_FOREACH(list_ent,list,db_cmd_next) { + TAILQ_FOREACH(list_ent, list, db_cmd_next) { result = db_cmd_search(db_tok_string, list_ent->db_cmd, &command); @@ -837,7 +837,7 @@ db_command(const struct db_command **last_cmdp) } - /*check compatibility flag*/ + /* check compatibility flag */ if (command && command->flag & CS_COMPAT){ t = db_read_token(); if (t != tIDENT) { @@ -916,7 +916,8 @@ db_command(const struct db_command **last_cmdp) /* * Execute the command. */ - (*command->fcn)(addr, have_addr, count, modif); + if (command->fcn != NULL) + (*command->fcn)(addr, have_addr, count, modif); if (command->flag & CS_SET_DOT) { /* |
