FIT: compare key name hint with streq_ptr for clarity
PATCH 1/1 FIT: compare key name hint with streq_ptr for clarity
When given a key name hint, we first attempt verification using the key it describes and fall through to verifying with all other keys.
The code implementing this is not necessarily intuitive and strcmp() makes it harder to understand.
As we check for NULL pointer anyway, let's use streq_ptr, which returns true instead of 0 on equality.
--- common/image-fit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
common/image-fit.c +2 -1
@@ -290,7 +290,8 @@ static int fit_check_signature(struct fit_handle *handle, struct device_node *sifor_each_public_key (key) { fail_reason ="verification failed" ; -if (key_name && !strcmp (key->key_name_hint, key_name)) +/* Don't recheck with same key as before */ +if (streq_ptr (key->key_name_hint, key_name))continue ; ret =public_key_verify (key, sig_value, sig_len, hash, algo);
Signature · 1 line
2.47.3
Quoted 10 lines · Ahmad Fatoum
When given a key name hint, we first attempt verification using the key it describes and fall through to verifying with all other keys.
The code implementing this is not necessarily intuitive and
strcmp()makes it harder to understand.As we check for NULL pointer anyway, let's use
streq_ptr, which returns true instead of 0 on equality.Signed-off-by Ahmad Fatoum <[email protected]>
Quoted 23 lines
--- common/image-fit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)common/image-fit.c +2
-1@@ -290,7 +290,8 @@ static int fit_check_signature(struct fit_handle *handle, struct device_node *sifor_each_public_key (key) { fail_reason ="verification failed" ; -if (key_name && !strcmp (key->key_name_hint, key_name)) +/* Don't recheck with same key as before */ +if (streq_ptr (key->key_name_hint, key_name))continue ; ret =public_key_verify (key, sig_value, sig_len, hash, algo);Signature · 1 line
2.47.3
Sascha Hauer
AppliedQuoted 10 lines · Ahmad Fatoum
When given a key name hint, we first attempt verification using the key it describes and fall through to verifying with all other keys.
The code implementing this is not necessarily intuitive and
strcmp()makes it harder to understand.As we check for NULL pointer anyway, let's use
streq_ptr, which returns true instead of 0 on equality.[...]
Applied, thanks!
[1/1] FIT: compare key name hint with streq_ptr for clarity
https://git.pengutronix.de/cgit/barebox/commit/?id=3138d4988d33 (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>