From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert P. J. Day Date: Fri, 20 May 2016 08:23:31 -0400 (EDT) Subject: [U-Boot] coding style question: when to use __weak function attributes? Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 ========================================================================