public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] test: fix a couple NULL vs IS_ERR() checks
@ 2023-07-31 14:08 Dan Carpenter
  2023-07-31 17:07 ` Simon Glass
  2023-08-09  1:40 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-07-31 14:08 UTC (permalink / raw)
  To: AKASHI Takahiro; +Cc: u-boot

The x509_cert_parse() and pkcs7_parse_message() functions return error
pointers.  They don't return NULL.  Update the checks accordingly.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 test/lib/asn1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/lib/asn1.c b/test/lib/asn1.c
index 8661fdd30687..a66cdd77df0a 100644
--- a/test/lib/asn1.c
+++ b/test/lib/asn1.c
@@ -120,7 +120,7 @@ static int lib_asn1_x509(struct unit_test_state *uts)
 
 	cert = x509_cert_parse(cert_data, cert_data_len);
 
-	ut_assertf(cert != NULL, "decoding failed\n");
+	ut_assertf(!IS_ERR(cert), "decoding failed\n");
 	ut_assertf(!strcmp(cert->subject, "Linaro: Tester"),
 		   "subject doesn't match\n");
 	ut_assertf(!strcmp(cert->issuer, "Linaro: Tester"),
@@ -313,7 +313,7 @@ static int lib_asn1_pkcs7(struct unit_test_state *uts)
 
 	pkcs7 = pkcs7_parse_message(image_pk7, image_pk7_len);
 
-	ut_assertf(pkcs7 != NULL, "decoding failed\n");
+	ut_assertf(!IS_ERR(pkcs7), "decoding failed\n");
 	ut_assertf(pkcs7->data_len == 104, "signature size doesn't match\n");
 	ut_assertf(pkcs7->signed_infos != NULL, "sign-info doesn't exist\n");
 	ut_assertf(pkcs7->signed_infos->msgdigest_len == 32,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] test: fix a couple NULL vs IS_ERR() checks
  2023-07-31 14:08 [PATCH] test: fix a couple NULL vs IS_ERR() checks Dan Carpenter
@ 2023-07-31 17:07 ` Simon Glass
  2023-08-09  1:40 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2023-07-31 17:07 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: AKASHI Takahiro, u-boot

Hi Dan,

On Mon, 31 Jul 2023 at 08:08, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The x509_cert_parse() and pkcs7_parse_message() functions return error
> pointers.  They don't return NULL.  Update the checks accordingly.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  test/lib/asn1.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

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

> diff --git a/test/lib/asn1.c b/test/lib/asn1.c
> index 8661fdd30687..a66cdd77df0a 100644
> --- a/test/lib/asn1.c
> +++ b/test/lib/asn1.c
> @@ -120,7 +120,7 @@ static int lib_asn1_x509(struct unit_test_state *uts)
>
>         cert = x509_cert_parse(cert_data, cert_data_len);
>
> -       ut_assertf(cert != NULL, "decoding failed\n");
> +       ut_assertf(!IS_ERR(cert), "decoding failed\n");

But how about creating ut_assertnoerr() or something like that?

>         ut_assertf(!strcmp(cert->subject, "Linaro: Tester"),
>                    "subject doesn't match\n");
>         ut_assertf(!strcmp(cert->issuer, "Linaro: Tester"),
> @@ -313,7 +313,7 @@ static int lib_asn1_pkcs7(struct unit_test_state *uts)
>
>         pkcs7 = pkcs7_parse_message(image_pk7, image_pk7_len);
>
> -       ut_assertf(pkcs7 != NULL, "decoding failed\n");
> +       ut_assertf(!IS_ERR(pkcs7), "decoding failed\n");
>         ut_assertf(pkcs7->data_len == 104, "signature size doesn't match\n");
>         ut_assertf(pkcs7->signed_infos != NULL, "sign-info doesn't exist\n");
>         ut_assertf(pkcs7->signed_infos->msgdigest_len == 32,
> --
> 2.39.2
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] test: fix a couple NULL vs IS_ERR() checks
  2023-07-31 14:08 [PATCH] test: fix a couple NULL vs IS_ERR() checks Dan Carpenter
  2023-07-31 17:07 ` Simon Glass
@ 2023-08-09  1:40 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-08-09  1:40 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: AKASHI Takahiro, u-boot

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

On Mon, Jul 31, 2023 at 05:08:41PM +0300, Dan Carpenter wrote:

> The x509_cert_parse() and pkcs7_parse_message() functions return error
> pointers.  They don't return NULL.  Update the checks accordingly.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-09  1:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-31 14:08 [PATCH] test: fix a couple NULL vs IS_ERR() checks Dan Carpenter
2023-07-31 17:07 ` Simon Glass
2023-08-09  1:40 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox