Kevin Wolf <[email protected]> writes:
> This renames the type for HMP monitor commands and the tables holding
> the commands to make clear that they are related to HMP and to allow
> making them public later:
>
> * mon_cmd_t -> HMPCommand (fixing use of a reserved name, too)
> * mon_cmds -> hmp_cmds
> * info_cmds -> hmp_info_cmds
>
> Signed-off-by: Kevin Wolf <[email protected]>
checkpatch.pl gripes:
> ---
> monitor.c | 68 ++++++++++++++++++++++++-------------------------
> hmp-commands.hx | 2 +-
> 2 files changed, 35 insertions(+), 35 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 5eacaa48a6..006c650761 100644
> --- a/monitor.c
> +++ b/monitor.c
[...]
> @@ -4531,20 +4531,20 @@ static void monitor_event(void *opaque, int event)
> static int
> compare_mon_cmd(const void *a, const void *b)
> {
> - return strcmp(((const mon_cmd_t *)a)->name,
> - ((const mon_cmd_t *)b)->name);
> + return strcmp(((const HMPCommand *)a)->name,
> + ((const HMPCommand *)b)->name);
> }
>
> static void sortcmdlist(void)
> {
> int array_num;
> - int elem_size = sizeof(mon_cmd_t);
> + int elem_size = sizeof(HMPCommand);
>
> - array_num = sizeof(mon_cmds)/elem_size-1;
> - qsort((void *)mon_cmds, array_num, elem_size, compare_mon_cmd);
> + array_num = sizeof(hmp_cmds)/elem_size-1;
229: ERROR: spaces required around that '/' (ctx:VxV)
229: ERROR: spaces required around that '-' (ctx:VxV)
> + qsort((void *)hmp_cmds, array_num, elem_size, compare_mon_cmd);
>
> - array_num = sizeof(info_cmds)/elem_size-1;
> - qsort((void *)info_cmds, array_num, elem_size, compare_mon_cmd);
> + array_num = sizeof(hmp_info_cmds)/elem_size-1;
Likewise.
I figure we should simply use ARRAY_SIZE().
static void sortcmdlist(void)
{
qsort(hmp_cmds, ARRAY_SIZE(hmp_cmds), sizeof(*hmp_cmds),
compare_mon_cmd);
qsort(hmp_info_cmds, ARRAY_SIZE(hmp_info_cmds), sizeof(*hmp_info_cmds),
compare_mon_cmd);
}
Can touch up in my tree.
> + qsort((void *)hmp_info_cmds, array_num, elem_size, compare_mon_cmd);
> }
>
> static void monitor_iothread_init(void)
[...]