Re: [PATCH] dcache: use QSTR() instead of QSTR_INIT()

From: Jan Kara

Date: Wed Apr 22 2026 - 11:12:33 EST


On Wed 22-04-26 15:34:37, Al Viro wrote:
> On Wed, Apr 22, 2026 at 02:33:46PM +0200, Thorsten Blum wrote:
> > Drop the hard-coded length arguments and use the simpler QSTR().
>
> ... which is not a constant expression. NAK.
>
> QSTR_INIT() is an initializer list for struct qstr; QSTR() is a
> compound literal for the same. IOW, its value is an anonymous
> local variable with given contents.
>
> C grammar allows both
> struct foo x = {.bar = y};
> and
> struct foo x = (struct foo){.bar = y};
> for auto variables, and compiler is able to figure out that they
> are equivalent. But the second form is not legal for the static-duration
> variables.

Hum, I understand your reasoning but if it isn't legal, I'd expect the
compiler to complain. Which it doesn't and the generated binary of a sample
test program with both constructs is exactly the same...

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR