Re: [PATCH] Make remaining usage strings and string tables const

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx> writes:

> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx>
> ---

I've looked at these changes (I wouldn't claim with fine toothed
comb, though) and they looked correct.  Most of the changes are to
ensure not just the strings are not writable through the pointers in
the arrays but the arrays themselves cannot be modified to hold
pionters that point elsewhere.

Functions like parse_revision_opt() declare their parameter for the
usage string array as

	const char *const usagestr[]

but that merely promises to the caller that the function would not
touch the strings or the pointers in the incoming array, so the
callers declaring the array they pass, like blame_opt_usage[] here,

> -static const char *blame_opt_usage[] = {
> +static const char *const blame_opt_usage[] = {
>  	blame_usage,
>  	"",
>  	N_("<rev-opts> are documented in git-rev-list(1)"),
>  	NULL
>  };

much looser to allow swapping the pointers in the array is *not* a
problem per-se, but as long as the compiler would not barf after
this patch, we know these callers that use these arrays are not
doing such mutations to these arrays themselves, so it is good.

Thanks.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux