This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [RFA 01/67] Add add_cmd function overloads


> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Tom Tromey
> Sent: Thursday, September 21, 2017 7:09 AM
> To: gdb-patches@sourceware.org
> Cc: Tom Tromey <tom@tromey.com>
> Subject: [RFA 01/67] Add add_cmd function overloads

Hello Tom,

>  static void
> +do_const_cfunc (struct cmd_list_element *c, char *args, int from_tty)
> +{
> +  c->function.const_cfunc (args, from_tty); /* Ok.  */
> +}

Ok.?


> +void
> +set_cmd_cfunc (struct cmd_list_element *cmd, cmd_const_cfunc_ftype *cfunc)
> +{
> +  if (cfunc == NULL)
> +    cmd->func = NULL;
> +  else
> +    cmd->func = do_const_cfunc;
> +  cmd->function.const_cfunc = cfunc; /* Ok.  */
> +}

We shouldn't really have the NULL case, anymore.  It is still possible  but I don't expect it to be used.  Should we assert CFUNC != NULL?

Should we also set CMD->FUNCTION.CFUNC to NULL?


> @@ -229,7 +251,6 @@ add_cmd (const char *name, enum command_class
> theclass, cmd_cfunc_ftype *fun,
> 
>    c->name = name;
>    c->theclass = theclass;
> -  set_cmd_cfunc (c, fun);

Should we instead set all the respective fields to NULL?


> +struct cmd_list_element *
> +add_cmd (const char *name, enum command_class theclass,
> +	 const char *doc, struct cmd_list_element **list)
> +{
> +  cmd_list_element *result = do_add_cmd (name, theclass, doc, list);
> +  result->func = NULL;
> +  result->function.cfunc = NULL; /* Ok.  */
> +  return result;
> +}

Should we also set RESULT->FUNCTION.CONST_CFUNC to NULL?


Regards,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]