Skip to content

tools: imagetool: Remove unnecessary check from toc0_verify_cert_item()#27

Open
xypron wants to merge 1 commit intoeswincomputing:u-boot-2024.01-EIC7Xfrom
xypron:toc0
Open

tools: imagetool: Remove unnecessary check from toc0_verify_cert_item()#27
xypron wants to merge 1 commit intoeswincomputing:u-boot-2024.01-EIC7Xfrom
xypron:toc0

Conversation

@xypron
Copy link
Copy Markdown

@xypron xypron commented Jan 5, 2025

Add upstream patch to avoid a build warning.

C99 introduced the possibility to mark function parameters declared as
arrays with an extra keyword "static":
	void foo(uint8_t digest[static SHA256_DIGEST_LENGTH]);
This requires the respective function argument to be at least as large
as specified. Passing in random pointers (like NULL) then becomes
undefined behaviour, and compilers warn about this.
Newer GCC compilers (starting with GCC 14) will also automatically mark
those parameters as "nonnull", and thus warn if a (redundant) NULL check
is done inside the function:
tools/sunxi_toc0.o tools/sunxi_toc0.c
tools/sunxi_toc0.c: In function 'toc0_verify_cert_item':
tools/sunxi_toc0.c:447:12: warning: 'nonnull' argument 'digest' compared to NULL [-Wnonnull-compare]
  447 |         if (digest && memcmp(&extension->digest, digest, SHA256_DIGEST_LENGTH)) {
      |            ^

Remove the unnecessary NULL check from toc0_verify_cert_item(), to avoid
the warning.

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
[Andre: extend commit message]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants