Re: [PATCH 4/5] lsusb: constify!

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

 



On Mon, Oct 25, 2010 at 4:43 AM, Felipe Balbi wrote:
> On Mon, Oct 25, 2010 at 02:09:51AM -0500, Mike Frysinger wrote:
>>
>> +static const char * const encryption_type[] = {
>
> const const ?? -ECONFUSED

this declares a non-const array to a bunch of const pointers:
  const char *foo[] = { "moo" };
this declares a const array to a bunch of const pointers:
  const char * const foo[] = { "moo" };

if that doesnt help, how about this ...

since the array of pointers (but not the data that those pointers
point to) is writable, you can do:
  const char *foo[] = { "moo" };
  foo[0] = NULL;  // works!
  foo[0][0] = 'a'; // error!
but once the array of pointers is const:
  const char * const foo[] = { "moo" };
  foo[0] = NULL;  // error!
  foo[0][0] = 'a'; // error!
-mike
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux