diff mbox series

[6/8] image: Do not #if guard board_fit_config_name_match() prototype

Message ID 20201216000944.2832585-7-mr.nuke.me@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series spl: fit: Play nicely with OP-TEE and Linux | expand

Commit Message

Alex G. Dec. 16, 2020, 12:09 a.m. UTC
There's no point in guarding function prototypes with #ifdefs. If a
function is not defined, the linker will notice. Having the prototype
does not affect code size.

What the #if guard takes away is the ability to use IS_ENABLED:

	if (CONFIG_IS ENABLED(FIT_IMAGE_POST_PROCESS))
		board_fit_config_name_match(...)

When the prototype is guarded, the above form cannot be used. This
leads to the proliferation of #ifdefs, and unreadable code. The
opportunity cost of the #if guard outweighs any benefits. Remove it.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
---
 include/image.h | 3 ---
 1 file changed, 3 deletions(-)

Comments

Simon Glass Dec. 19, 2020, 2:29 a.m. UTC | #1
Hi Alexandru

On Tue, 15 Dec 2020 at 17:10, Alexandru Gagniuc <mr.nuke.me@gmail.com> wrote:
>
> There's no point in guarding function prototypes with #ifdefs. If a
> function is not defined, the linker will notice. Having the prototype
> does not affect code size.
>
> What the #if guard takes away is the ability to use IS_ENABLED:
>
>         if (CONFIG_IS ENABLED(FIT_IMAGE_POST_PROCESS))
>                 board_fit_config_name_match(...)
>
> When the prototype is guarded, the above form cannot be used. This
> leads to the proliferation of #ifdefs, and unreadable code. The
> opportunity cost of the #if guard outweighs any benefits. Remove it.
>
> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
> ---
>  include/image.h | 3 ---
>  1 file changed, 3 deletions(-)

Yes indeed.

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/include/image.h b/include/image.h
index 00bc03bebe..fd8bd43515 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1536,8 +1536,6 @@  bool android_image_print_dtb_contents(ulong hdr_addr);
  */
 int board_fit_config_name_match(const char *name);
 
-#if defined(CONFIG_SPL_FIT_IMAGE_POST_PROCESS) || \
-	defined(CONFIG_FIT_IMAGE_POST_PROCESS)
 /**
  * board_fit_image_post_process() - Do any post-process on FIT binary data
  *
@@ -1552,7 +1550,6 @@  int board_fit_config_name_match(const char *name);
  * @return no return value (failure should be handled internally)
  */
 void board_fit_image_post_process(void **p_image, size_t *p_size);
-#endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */
 
 #define FDT_ERROR	((ulong)(-1))