Re: [PATCH RFC 2/2] wcslen() prototype in string.h
From: Nathan Chancellor
Date: Tue Mar 25 2025 - 12:59:07 EST
On Tue, Mar 25, 2025 at 06:17:34PM +0200, Andy Shevchenko wrote:
> On Tue, Mar 25, 2025 at 08:45:19AM -0700, Nathan Chancellor wrote:
> > If this is desired, it should be squashed into the previous change. I
> > wrote it separately because it is slightly more invasive.
> >
> > In order to export wcslen() to the rest of the kernel (should it ever be
> > necessary elsewhere), it needs to be added to string.h, along with nls.h
> > for the typedef of wchar_t. However, dragging in nls.h into string.h
> > causes an error in the efistub due to a conflicting function name:
> >
> > drivers/firmware/efi/libstub/printk.c:27:5: error: static declaration of 'utf8_to_utf32' follows non-static declaration
> > 27 | u32 utf8_to_utf32(const u8 **s8)
> > | ^
> > include/linux/nls.h:55:12: note: previous declaration is here
> > 55 | extern int utf8_to_utf32(const u8 *s, int len, unicode_t *pu);
> > | ^
> > drivers/firmware/efi/libstub/printk.c:85:26: error: too few arguments to function call, expected 3, have 1
> > 85 | c32 = utf8_to_utf32(&s8);
> > | ~~~~~~~~~~~~~ ^
> > include/linux/nls.h:55:12: note: 'utf8_to_utf32' declared here
> > 55 | extern int utf8_to_utf32(const u8 *s, int len, unicode_t *pu);
> > | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 2 errors generated.
> >
> > Rename the efi function to avoid the conflict.
>
> Hmm... Why not split this to two, rename patch as a standalone makes sense to
> me even outside of this series.
How so? If nls.h is not included in printk.c via string.h, which does
not happen without this series, what value does the rename have? I do
not mind splitting it up that way to keep things cleaner, I am just
wondering what would be the justification in the changelog (I guess just
that nls.h may get included in the future for some reason)?
Cheers,
Nathan