[PATCH v3 2/5] misc: fs_loader: allow using long script name in request_firmware_into_buf_via_script()
Lothar Waßmann
LW at KARO-electronics.de
Fri Sep 5 07:35:28 CEST 2025
Hi,
On Fri, 5 Sep 2025 09:26:05 +0800 Weijie Gao wrote:
[...]
> > > We'll get compiler warning if using const char *[]:
> > >
> > > CC drivers/misc/fs_loader.o
> > > drivers/misc/fs_loader.c: In function
> > > 'request_firmware_into_buf_via_script':
> > > drivers/misc/fs_loader.c:243:33: warning: passing argument 3 of
> > > 'cmd_process' from incompatible pointer type [-Wincompatible-
> > > pointer-
> > > types]
> > > 243 | ret = cmd_process(0, 2, args, &repeatable, NULL);
> > > | ^~~~
> > > | |
> > > | const char **
> > >
> >
> > OK. But at least:
> > char *args[2] = { "run", (char *)script_name };
> > should work...
>
> You're right. I thought string literals are always const.
>
> >
> >
> > NB: The right fix would be to change the argument type of
> > cmd_process()
> > (and all functions with similar semantics...) to
> > "const char *const argv[]", since cmd_process() need not and should
> > not
> > be able to modify any of the strings within argv[].
>
> I agree. But this should be sent in another patch series.
>
Above all, this should be considered when designing a new API.
There is no reason why a function like cmd_process() should ever be
able to modify the strings it gets passed in the argument list, so they
should always be declared as 'const char *...'.
Lothar Waßmann
More information about the U-Boot
mailing list