linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v10 1/2] fs: New zonefs file system
@ 2020-02-04  9:46 Markus Elfring
  2020-02-05  1:35 ` Damien Le Moal
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2020-02-04  9:46 UTC (permalink / raw)
  To: Damien Le Moal, linux-fsdevel, linux-xfs
  Cc: linux-kernel, Darrick J. Wong, Hannes Reinecke,
	Johannes Thumshirn, Linus Torvalds, Naohiro Aota

…
> +++ 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" };

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v10 1/2] fs: New zonefs file system
  2020-02-04  9:46 [PATCH v10 1/2] fs: New zonefs file system Markus Elfring
@ 2020-02-05  1:35 ` Damien Le Moal
  2020-02-05  7:16   ` [v10 " Markus Elfring
  0 siblings, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2020-02-05  1:35 UTC (permalink / raw)
  To: Markus.Elfring, linux-fsdevel, linux-xfs
  Cc: darrick.wong, torvalds, jth, linux-kernel, hare, Naohiro Aota

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v10 1/2] fs: New zonefs file system
  2020-02-05  1:35 ` Damien Le Moal
@ 2020-02-05  7:16   ` Markus Elfring
  2020-02-05  7:46     ` Damien Le Moal
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2020-02-05  7:16 UTC (permalink / raw)
  To: Damien Le Moal, linux-fsdevel, linux-xfs
  Cc: linux-kernel, Darrick J. Wong, Hannes Reinecke,
	Johannes Thumshirn, Linus Torvalds, Naohiro Aota

> Declaring it as
>
> static const char * const zgroups_name[] = { "cnv", "seq" };
>
> is probably what you are suggesting,

Yes.


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

I propose to define this array also as a completely immutable data structure.

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v10 1/2] fs: New zonefs file system
  2020-02-05  7:16   ` [v10 " Markus Elfring
@ 2020-02-05  7:46     ` Damien Le Moal
  2020-02-05 10:44       ` Markus Elfring
  0 siblings, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2020-02-05  7:46 UTC (permalink / raw)
  To: Markus Elfring, linux-fsdevel, linux-xfs
  Cc: linux-kernel, Darrick J. Wong, Hannes Reinecke,
	Johannes Thumshirn, Linus Torvalds, Naohiro Aota

On 2020/02/05 16:17, Markus Elfring wrote:
>> Declaring it as
>>
>> static const char * const zgroups_name[] = { "cnv", "seq" };
>>
>> is probably what you are suggesting,
> 
> Yes.
> 
> 
>> but since the string literals are already constants by default,
>> I do not think there is any difference.
> 
> I propose to define this array also as a completely immutable data structure.

I understood that and pointed out that the added "const" does not change a
thing. I think that as is, it already is immutable. But sure, I can add
that const, no problem.

> 
> Regards,
> Markus
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v10 1/2] fs: New zonefs file system
  2020-02-05  7:46     ` Damien Le Moal
@ 2020-02-05 10:44       ` Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2020-02-05 10:44 UTC (permalink / raw)
  To: Damien Le Moal, linux-fsdevel, linux-xfs
  Cc: linux-kernel, Darrick J. Wong, Hannes Reinecke,
	Johannes Thumshirn, Linus Torvalds, Naohiro Aota

>> I propose to define this array also as a completely immutable data structure.
>
> I understood that and pointed out that the added "const" does not change a thing.

Should the stored pointers be constants (besides the corresponding string literals)?


> I think that as is, it already is immutable.

Would you like to distinguish the scope for items in this variable a bit more?


Are any other software components similarly affected?

Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-05 10:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-04  9:46 [PATCH v10 1/2] fs: New zonefs file system Markus Elfring
2020-02-05  1:35 ` Damien Le Moal
2020-02-05  7:16   ` [v10 " Markus Elfring
2020-02-05  7:46     ` Damien Le Moal
2020-02-05 10:44       ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).