[U-Boot] coding style question: when to use __weak function attributes?
Robert P. J. Day
rpjday at crashcourse.ca
Fri May 20 14:23:31 CEST 2016
pardon yet another question on coding style and pedantry, but i'm
curious about the following. i'm crawling through the code in
common/image-fdt.c, specifically in image_setup_libfdt(), and first i
see the following:
__weak int arch_fixup_fdt(void *blob)
{
return 0;
}
... snip ...
if (arch_fixup_fdt(blob) < 0) {
printf("ERROR: arch-specific fdt fixup failed\n");
goto err;
}
which is perfectly understandable -- use the weak function attribute,
and let each architecture decide if it wants to override that. same
thing here in that same file:
__weak int ft_verify_fdt(void *fdt)
{
return 1;
}
... snip ...
if (!ft_verify_fdt(blob))
goto err;
which then makes me wonder why the same approach wasn't used for these
routines as well:
if (IMAGE_OF_BOARD_SETUP) {
fdt_ret = ft_board_setup(blob, gd->bd);
if (fdt_ret) {
printf("ERROR: board-specific fdt fixup failed: %s\n",
fdt_strerror(fdt_ret));
goto err;
}
}
if (IMAGE_OF_SYSTEM_SETUP) {
fdt_ret = ft_system_setup(blob, gd->bd);
if (fdt_ret) {
printf("ERROR: system-specific fdt fixup failed: %s\n",
fdt_strerror(fdt_ret));
goto err;
}
}
couldn't ft_board_setup() and ft_system_setup() have been defined the
same way? or is there something different about those two routines
that wouldn't allow the weak function attribute and do away with all
the OF_BOARD_SETUP and OF_SYSTEM_SETUP usage?
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
More information about the U-Boot
mailing list