command: print BUG warning when usage is missing

These error messages will prompt patches to be submitted for missing
.usage or empty fields. All of the below must be resolved before next
release.

The Jim defined commands are excluded from this checklist because the
help text can be set later than during command registration.

strlen(.usage) == 0 means that the command expects no arguments.

Updates to this patch in Gerrit to fix problems below are most
welcome. Anyone can push updated versions of a patch to Gerrit. If
there are no further updates to this patch within a week, it will be
pushed to the master branch to prompt more fixes.

These were caught by launching OpenOCD.

Error: BUG: command 'command' does not have the '.usage' field filled out
Error: BUG: command 'script' does not have the '.usage' field filled out
Error: BUG: command 'power_restore' does not have the '.usage' field filled out
Error: BUG: command 'srst_deasserted' does not have the '.usage' field filled out
Error: BUG: command 'measure_clk' does not have the '.usage' field filled out
Error: BUG: command 'exit' does not have the '.usage' field filled out
Error: BUG: command 'shutdown' does not have the '.usage' field filled out
Error: BUG: command 'gdb_sync' does not have the '.usage' field filled out
Error: BUG: command 'interface_list' does not have the '.usage' field filled out
Error: BUG: command 'target' does not have the '.usage' field filled out
Error: BUG: command 'target init' does not have the '.usage' field filled out
Error: BUG: command 'flash' does not have the '.usage' field filled out
Error: BUG: command 'flash init' does not have the '.usage' field filled out
Error: BUG: command 'flash banks' does not have the '.usage' field filled out
Error: BUG: command 'nand' does not have the '.usage' field filled out
Error: BUG: command 'nand drivers' does not have the '.usage' field filled out
Error: BUG: command 'nand init' does not have the '.usage' field filled out
Error: BUG: command 'pld' does not have the '.usage' field filled out
Error: BUG: command 'pld init' does not have the '.usage' field filled out
Error: BUG: command 'mflash' does not have the '.usage' field filled out
Error: BUG: command 'mflash init' does not have the '.usage' field filled out
Error: BUG: command 'dummy' does not have the '.usage' field filled out
Error: BUG: command 'dummy foo' does not have the '.usage' field filled out
Error: BUG: command 'scan_chain' does not have the '.usage' field filled out
Error: BUG: command 'jtag' does not have the '.usage' field filled out
Error: BUG: command 'jtag init' does not have the '.usage' field filled out
Error: BUG: command 'arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'etm' does not have the '.usage' field filled out
Error: BUG: command 'arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu etm' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'target_request' does not have the '.usage' field filled out
^C
oyvind@fierce:~/openocd$ openocd -c "interface dummy" -f board/at91eb40a.cfg 2>&1 | grep -w BUG
Error: BUG: command 'command' does not have the '.usage' field filled out
Error: BUG: command 'script' does not have the '.usage' field filled out
Error: BUG: command 'power_restore' does not have the '.usage' field filled out
Error: BUG: command 'srst_deasserted' does not have the '.usage' field filled out
Error: BUG: command 'measure_clk' does not have the '.usage' field filled out
Error: BUG: command 'exit' does not have the '.usage' field filled out
Error: BUG: command 'shutdown' does not have the '.usage' field filled out
Error: BUG: command 'gdb_sync' does not have the '.usage' field filled out
Error: BUG: command 'interface_list' does not have the '.usage' field filled out
Error: BUG: command 'target' does not have the '.usage' field filled out
Error: BUG: command 'target init' does not have the '.usage' field filled out
Error: BUG: command 'flash' does not have the '.usage' field filled out
Error: BUG: command 'flash init' does not have the '.usage' field filled out
Error: BUG: command 'flash banks' does not have the '.usage' field filled out
Error: BUG: command 'nand' does not have the '.usage' field filled out
Error: BUG: command 'nand drivers' does not have the '.usage' field filled out
Error: BUG: command 'nand init' does not have the '.usage' field filled out
Error: BUG: command 'pld' does not have the '.usage' field filled out
Error: BUG: command 'pld init' does not have the '.usage' field filled out
Error: BUG: command 'mflash' does not have the '.usage' field filled out
Error: BUG: command 'mflash init' does not have the '.usage' field filled out
Error: BUG: command 'dummy' does not have the '.usage' field filled out
Error: BUG: command 'dummy foo' does not have the '.usage' field filled out
Error: BUG: command 'scan_chain' does not have the '.usage' field filled out
Error: BUG: command 'jtag' does not have the '.usage' field filled out
Error: BUG: command 'jtag init' does not have the '.usage' field filled out
Error: BUG: command 'arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'etm' does not have the '.usage' field filled out
Error: BUG: command 'arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu etm' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'target_request' does not have the '.usage' field filled out

Change-Id: I2c3e529530a15d2295a1950ffc59e8f2fc661012
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Signed-off-by: Mathias K <kesmtp@freenet.de>
Reviewed-on: http://openocd.zylin.com/299
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
Mathias K 2011-12-24 15:26:12 +01:00 committed by Spencer Oliver
parent 59cd1c892d
commit 54d6330b78
5 changed files with 27 additions and 3 deletions

View File

@ -323,6 +323,22 @@ static struct command *command_new(struct command_context *cmd_ctx,
{ {
assert(cr->name); assert(cr->name);
/*
If it is a non-jim command with no .usage specified,
log an error.
strlen(.usage) == 0 means that the command takes no
arguments.
*/
if ((cr->jim_handler == NULL) &&
(cr->usage == NULL)) {
LOG_DEBUG("BUG: command '%s%s%s' does not have the "
"'.usage' field filled out",
parent && parent->name ? parent->name : "",
parent && parent->name ? " " : "",
cr->name);
}
struct command *c = calloc(1, sizeof(struct command)); struct command *c = calloc(1, sizeof(struct command));
if (NULL == c) if (NULL == c)
return NULL; return NULL;

View File

@ -195,6 +195,7 @@ static const struct command_registration openocd_command_handlers[] = {
.handler = &handle_noinit_command, .handler = &handle_noinit_command,
.mode = COMMAND_CONFIG, .mode = COMMAND_CONFIG,
.help = "Prevent 'init' from being called at startup.", .help = "Prevent 'init' from being called at startup.",
.usage = ""
}, },
{ {
.name = "init", .name = "init",
@ -204,14 +205,14 @@ static const struct command_registration openocd_command_handlers[] = {
"Changes command mode from CONFIG to EXEC. " "Changes command mode from CONFIG to EXEC. "
"Unless 'noinit' is called, this command is " "Unless 'noinit' is called, this command is "
"called automatically at the end of startup.", "called automatically at the end of startup.",
.usage = ""
}, },
{ {
.name = "add_script_search_dir", .name = "add_script_search_dir",
.handler = &handle_add_script_search_dir_command, .handler = &handle_add_script_search_dir_command,
.mode = COMMAND_ANY, .mode = COMMAND_ANY,
.help = "dir to search for config files and scripts", .help = "dir to search for config files and scripts",
.usage = "<directory>"
}, },
COMMAND_REGISTRATION_DONE COMMAND_REGISTRATION_DONE
}; };

View File

@ -5534,11 +5534,13 @@ static const struct command_registration target_exec_command_handlers[] = {
.mode = COMMAND_EXEC, .mode = COMMAND_EXEC,
.help = "loads active fast load image to current target " .help = "loads active fast load image to current target "
"- mainly for profiling purposes", "- mainly for profiling purposes",
.usage = "",
}, },
{ {
.name = "profile", .name = "profile",
.handler = handle_profile_command, .handler = handle_profile_command,
.mode = COMMAND_EXEC, .mode = COMMAND_EXEC,
.usage = "seconds filename",
.help = "profiling samples the CPU PC", .help = "profiling samples the CPU PC",
}, },
/** @todo don't register virt2phys() unless target supports it */ /** @todo don't register virt2phys() unless target supports it */
@ -5599,6 +5601,7 @@ static const struct command_registration target_exec_command_handlers[] = {
.name = "soft_reset_halt", .name = "soft_reset_halt",
.handler = handle_soft_reset_halt_command, .handler = handle_soft_reset_halt_command,
.mode = COMMAND_EXEC, .mode = COMMAND_EXEC,
.usage = "",
.help = "halt the target and do a soft reset", .help = "halt the target and do a soft reset",
}, },
{ {
@ -5655,7 +5658,7 @@ static const struct command_registration target_exec_command_handlers[] = {
.handler = handle_bp_command, .handler = handle_bp_command,
.mode = COMMAND_EXEC, .mode = COMMAND_EXEC,
.help = "list or set hardware or software breakpoint", .help = "list or set hardware or software breakpoint",
.usage = "usage: bp <address> [<asid>]<length> ['hw'|'hw_ctx']", .usage = "<address> [<asid>]<length> ['hw'|'hw_ctx']",
}, },
{ {
.name = "rbp", .name = "rbp",

View File

@ -179,6 +179,7 @@ static const struct command_registration trace_command_handlers[] = {
.name = "trace", .name = "trace",
.mode = COMMAND_EXEC, .mode = COMMAND_EXEC,
.help = "trace command group", .help = "trace command group",
.usage = "",
.chain = trace_exec_command_handlers, .chain = trace_exec_command_handlers,
}, },
COMMAND_REGISTRATION_DONE COMMAND_REGISTRATION_DONE

View File

@ -336,12 +336,14 @@ static const struct command_registration transport_commands[] = {
*/ */
.mode = COMMAND_ANY, .mode = COMMAND_ANY,
.help = "Initialize this session's transport", .help = "Initialize this session's transport",
.usage = ""
}, },
{ {
.name = "list", .name = "list",
.handler = handle_transport_list, .handler = handle_transport_list,
.mode = COMMAND_ANY, .mode = COMMAND_ANY,
.help = "list all built-in transports", .help = "list all built-in transports",
.usage = ""
}, },
{ {
.name = "select", .name = "select",
@ -359,6 +361,7 @@ static const struct command_registration transport_group[] = {
.mode = COMMAND_ANY, .mode = COMMAND_ANY,
.help = "Transport command group", .help = "Transport command group",
.chain = transport_commands, .chain = transport_commands,
.usage = ""
}, },
COMMAND_REGISTRATION_DONE COMMAND_REGISTRATION_DONE
}; };