lkml.org 
[lkml]   [2020]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v10 1/2] fs: New zonefs file system
Date
On Tue, 2020-02-04 at 10:46 +0100, Markus Elfring wrote:
> …
> > +++ b/fs/zonefs/super.c
> …
> > +static const char *zgroups_name[ZONEFS_ZTYPE_MAX] = { "cnv", "seq" };
>
> Can this array be treated as immutable?
> How do you think about to use the following code variant?
>
> +static const char const *zgroups_name[ZONEFS_ZTYPE_MAX] = { "cnv", "seq" };

That does not compile: duplicated const.
In any case, I am not sure what this would achieve since string
literals are constants by default and the pointer to the array is
declared as a constant too. This ends up completely with read-only text
section.

Declaring it as

static const char * const zgroups_name[] = { "cnv", "seq" };

is probably what you are suggesting, but since the string literals are
already constants by default, I do not think there is any difference.

>
> Regards,
> Markus

--
Damien Le Moal
Western Digital Research
\
 
 \ /
  Last update: 2020-02-05 02:37    [W:0.055 / U:2.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site