From: Robert P. J. Day <rpjday@crashcourse.ca>
To: u-boot@lists.denx.de
Subject: [U-Boot] coding style question: when to use __weak function attributes?
Date: Fri, 20 May 2016 08:23:31 -0400 (EDT) [thread overview]
Message-ID: <alpine.LFD.2.20.1605200813430.7605@localhost.localdomain> (raw)
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
========================================================================
reply other threads:[~2016-05-20 12:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.2.20.1605200813430.7605@localhost.localdomain \
--to=rpjday@crashcourse.ca \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox