[PATCH v5 2/4] fs: split rootargs into root and options
Sascha Hauer
s.hauer at pengutronix.de
Wed Dec 3 08:07:50 PST 2025
Hi Fabian,
On Mon, Dec 01, 2025 at 08:20:58AM +0100, Fabian Pflug wrote:
> +void fsdev_get_linux_root_options(struct fs_device *fsdev, char **root, char **rootopts)
> +{
> + if (fsdev) {
> + *root = dev_get_param(&fsdev->dev, "linux.bootargs.root");
> + *rootopts = dev_get_param(&fsdev->dev, "linux.bootargs.rootopts");
> + }
> +}
dev_get_param() returns a const char *, so arguments should be const
char **. The compiler should have warned you about this. Unfortunately
YOCTO hides these warnings when the build succeeds, so in case you build
with YOCTO it's worth building barebox standalone once before sending.
When fixing this several other warnings pop up with similar issues...
> +
> +char *format_root_bootarg(const char *root_arg, char *root, char *rootopts) {
...when fixing these you end up with making these arguments const char *
> + char *bootarg;
> + if (rootopts)
> + bootarg = xasprintf("%s=%s %s", root_arg, root, rootopts);
> + else
> + bootarg = xasprintf("%s=%s", root_arg, root);
> + free(root);
> + free(rootopts);
... which then gives you a warning that you pass a const char * to
free(). Here the strings are really not allocated and the free() should
be dropped.
I fixed this up this time, but please look for compiler warnings next
time.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list