summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2024-08-01 10:01:00 +0900
committerAndre Przywara <andre.przywara@arm.com>2024-08-06 00:19:57 +0100
commit59fff91f2bea2215c7b16415b9a0e6714fac5573 (patch)
treec945bdad10c18f624017402c8d991e51cf0907d4
parent6becf9ba1ab82af6f4fcf9f4d0da38f9c75212d2 (diff)
downloadu-boot-59fff91f2bea2215c7b16415b9a0e6714fac5573.tar.gz
u-boot-59fff91f2bea2215c7b16415b9a0e6714fac5573.tar.bz2
u-boot-59fff91f2bea2215c7b16415b9a0e6714fac5573.zip
tools: imagetool: Remove unnecessary check from toc0_verify_cert_item()
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>
-rw-r--r--tools/sunxi_toc0.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/sunxi_toc0.c b/tools/sunxi_toc0.c
index 292649fe90..76693647a0 100644
--- a/tools/sunxi_toc0.c
+++ b/tools/sunxi_toc0.c
@@ -444,7 +444,7 @@ static int toc0_verify_cert_item(const uint8_t *buf, uint32_t len, RSA *fw_key,
/* If a digest was provided, compare it to the embedded digest. */
extension = &totalSequence->mainSequence.explicit3.extension;
- if (digest && memcmp(&extension->digest, digest, SHA256_DIGEST_LENGTH)) {
+ if (memcmp(&extension->digest, digest, SHA256_DIGEST_LENGTH)) {
pr_err("Wrong firmware digest in certificate\n");
goto err;
}