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

Pedro Alves
2017-09-21T10:25:22Z

On 09/21/2017 08:02 AM, Metzger, Markus T wrote:

>> +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?

If that's possible, then it'd be nice to add ATTRIBUTE_NONNULL
on the declaration too.

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

I think not, because it's a union.

Thanks,
Pedro Alves