Re: [PATCH] ext4: avoid -Wformat-security warning

From: Jan Kara
Date: Thu Apr 24 2025 - 09:50:45 EST


On Thu 24-04-25 14:31:02, Arnd Bergmann wrote:
> On Thu, Apr 24, 2025, at 13:39, Jan Kara wrote:
> > On Wed 23-04-25 18:43:49, Arnd Bergmann wrote:
> >> From: Arnd Bergmann <arnd@xxxxxxxx>
> >>
> >> check_igot_inode() prints a variable string, which causes a harmless
> >> warning with 'make W=1':
> >>
> >> fs/ext4/inode.c:4763:45: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
> >> 4763 | ext4_error_inode(inode, function, line, 0, err_str);
> >>
> >> Use a trivial "%s" format string instead.
> >>
> >> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> >
> > Frankly I don't care much either way but if my memory serves me well year
> > or two ago someone was going through the kernel and was replacing pointless
> > ("%s", str) cases with printing the string directly. So we should make up
> > our minds how we want this... In my opinion this is one of the warnings
> > which may be useful but have false positives too often (like here where
> > err_str is just a selection from several string literals) so I'm not sure
> > it's worth the effort to try to silence it.
>
> I had a look at the git log now and see no evidence of those
> patches getting merged, but plenty of patches going the same way
> as my patch.

OK, so maybe I'm just confused or the patch indeed got discarded. Thanks
for having a look! With this clarification feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

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