* [U-Boot] coding style question: when to use __weak function attributes?
@ 2016-05-20 12:23 Robert P. J. Day
0 siblings, 0 replies; only message in thread
From: Robert P. J. Day @ 2016-05-20 12:23 UTC (permalink / raw)
To: u-boot
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
========================================================================
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-05-20 12:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-20 12:23 [U-Boot] coding style question: when to use __weak function attributes? Robert P. J. Day
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox