Re: [RFA 38/67] Constify some linespec functions

Pedro Alves
2017-09-26T12:17:20Z

On 09/23/2017 05:03 AM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>
> Pedro> In several places you followed a pattern like:
>
>>> static void
>>> -foo_command (char *args, int from_tty)
>>> +foo_command (char *args_in, int from_tty)
>
> Pedro> ... and then args_in wasn't used.
>
> Hmm... normally I think it should be used.
> Like in this patch (#38):
>
> -info_scope_command (char *args, int from_tty)
> +info_scope_command (char *args_in, int from_tty)
> ...
> - char *save_args = args;
> + const char *save_args = args_in;
> ...
> + const char *args = args_in;
>

I meant, used other than for immediately initializating a const version.

> Pedro> I'd be nice to mention in the commit log the reason for this.
> Pedro> I assume that it's because we don't have the corresponding
> Pedro> constified add_cmd variant?
>
> In this case I believe the reason is that info_scope_command could not
> be constified yet, because add_info isn't constified; but on the other
> hand it calls string_to_event_location, which is now constified, and it
> didn't seem worthwhile to overload that.
>

Makes sense, and that's exactly the sort of info I was looking for.

> I think all the cases *should* be things like this, but of course there
> may be errors.

Thanks,
Pedro Alves