This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFA 01/67] Add add_cmd function overloads
- From: "Metzger, Markus T" <markus dot t dot metzger at intel dot com>
- To: Tom Tromey <tom at tromey dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Thu, 21 Sep 2017 07:02:08 +0000
- Subject: RE: [RFA 01/67] Add add_cmd function overloads
- Authentication-results: sourceware.org; auth=none
- Dlp-product: dlpe-windows
- Dlp-reaction: no-action
- Dlp-version: 11.0.0.116
- References: <20170921051023.19023-1-tom@tromey.com> <20170921051023.19023-2-tom@tromey.com>
> -----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