Re: [PATCH 05/19] reftable: improve const correctness when assigning string constants

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

 



Patrick Steinhardt <ps@xxxxxx> writes:

> diff --git a/reftable/basics_test.c b/reftable/basics_test.c
> index 997c4d9e01..af9209d535 100644
> --- a/reftable/basics_test.c
> +++ b/reftable/basics_test.c
> @@ -58,8 +58,8 @@ static void test_binsearch(void)
>  
>  static void test_names_length(void)
>  {
> -	char *a[] = { "a", "b", NULL };
> -	EXPECT(names_length(a) == 2);
> +	char *names[] = { (char *)"a", (char *)"b", NULL };
> +	EXPECT(names_length(names) == 2);
>  }

I would have preferred to see this kind of rewrite more than
separate and clearly writable variables that are initialied with the
constant contents e.g. branches[] = "refs/heads/*", we saw in
earlier steps.  Wouldn't that approach, combined with making the
literal constants stored in read-only segment to trigger runtime
failure when a bug causes the "unfortunately non-const" variables
to be written, give us a better result?




[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