diff mbox series

[v3,2/6] kunit: use NULL macros

Message ID 20220207211144.1948690-2-ribalda@chromium.org
State Superseded
Headers show
Series None | expand

Commit Message

Ricardo Ribalda Feb. 7, 2022, 9:11 p.m. UTC
Replace the NULL checks with the more specific and idiomatic NULL macros.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 lib/kunit/kunit-example-test.c | 2 ++
 lib/kunit/kunit-test.c         | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Daniel Latypov Feb. 7, 2022, 9:39 p.m. UTC | #1
On Mon, Feb 7, 2022 at 1:11 PM Ricardo Ribalda <ribalda@chromium.org> wrote:
>
> Replace the NULL checks with the more specific and idiomatic NULL macros.
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

Reviewed-by: Daniel Latypov <dlatypov@google.com>

LGTM, thanks!
(This will still need Brendan's RB to go in)

> ---
>  lib/kunit/kunit-example-test.c | 2 ++
>  lib/kunit/kunit-test.c         | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/kunit/kunit-example-test.c b/lib/kunit/kunit-example-test.c
> index 4bbf37c04eba..91b1df7f59ed 100644
> --- a/lib/kunit/kunit-example-test.c
> +++ b/lib/kunit/kunit-example-test.c
> @@ -91,6 +91,8 @@ static void example_all_expect_macros_test(struct kunit *test)
>         KUNIT_EXPECT_NOT_ERR_OR_NULL(test, test);
>         KUNIT_EXPECT_PTR_EQ(test, NULL, NULL);
>         KUNIT_EXPECT_PTR_NE(test, test, NULL);
> +       KUNIT_EXPECT_NULL(test, NULL);
> +       KUNIT_EXPECT_NOT_NULL(test, test);
>
>         /* String assertions */
>         KUNIT_EXPECT_STREQ(test, "hi", "hi");
> diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c
> index 555601d17f79..8e2fe083a549 100644
> --- a/lib/kunit/kunit-test.c
> +++ b/lib/kunit/kunit-test.c
> @@ -435,7 +435,7 @@ static void kunit_log_test(struct kunit *test)
>         KUNIT_EXPECT_NOT_ERR_OR_NULL(test,
>                                      strstr(suite.log, "along with this."));
>  #else
> -       KUNIT_EXPECT_PTR_EQ(test, test->log, (char *)NULL);
> +       KUNIT_EXPECT_NULL(test, test->log);
>  #endif
>  }
>
> --
> 2.35.0.263.gb82422642f-goog
>
diff mbox series

Patch

diff --git a/lib/kunit/kunit-example-test.c b/lib/kunit/kunit-example-test.c
index 4bbf37c04eba..91b1df7f59ed 100644
--- a/lib/kunit/kunit-example-test.c
+++ b/lib/kunit/kunit-example-test.c
@@ -91,6 +91,8 @@  static void example_all_expect_macros_test(struct kunit *test)
 	KUNIT_EXPECT_NOT_ERR_OR_NULL(test, test);
 	KUNIT_EXPECT_PTR_EQ(test, NULL, NULL);
 	KUNIT_EXPECT_PTR_NE(test, test, NULL);
+	KUNIT_EXPECT_NULL(test, NULL);
+	KUNIT_EXPECT_NOT_NULL(test, test);
 
 	/* String assertions */
 	KUNIT_EXPECT_STREQ(test, "hi", "hi");
diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c
index 555601d17f79..8e2fe083a549 100644
--- a/lib/kunit/kunit-test.c
+++ b/lib/kunit/kunit-test.c
@@ -435,7 +435,7 @@  static void kunit_log_test(struct kunit *test)
 	KUNIT_EXPECT_NOT_ERR_OR_NULL(test,
 				     strstr(suite.log, "along with this."));
 #else
-	KUNIT_EXPECT_PTR_EQ(test, test->log, (char *)NULL);
+	KUNIT_EXPECT_NULL(test, test->log);
 #endif
 }