mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kunit: string-stream-test: use KUNIT_DEFINE_ACTION_WRAPPER
@ 2024-04-23 18:27 Ivan Orlov
  2024-04-23 21:35 ` Rae Moar
  2024-04-24  0:08 ` David Gow
  0 siblings, 2 replies; 3+ messages in thread
From: Ivan Orlov @ 2024-04-23 18:27 UTC (permalink / raw)
  To: brendan.higgins, davidgow
  Cc: Ivan Orlov, rmoar, linux-kselftest, kunit-dev, linux-kernel

Use KUNIT_DEFINE_ACTION_WRAPPER macro to define the 'kfree' and
'string_stream_destroy' wrappers for kunit_add_action.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
---
 lib/kunit/string-stream-test.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/lib/kunit/string-stream-test.c b/lib/kunit/string-stream-test.c
index 03fb511826f7..7511442ea98f 100644
--- a/lib/kunit/string-stream-test.c
+++ b/lib/kunit/string-stream-test.c
@@ -22,18 +22,10 @@ struct string_stream_test_priv {
 };
 
 /* Avoids a cast warning if kfree() is passed direct to kunit_add_action(). */
-static void kfree_wrapper(void *p)
-{
-	kfree(p);
-}
+KUNIT_DEFINE_ACTION_WRAPPER(kfree_wrapper, kfree, const void *);
 
 /* Avoids a cast warning if string_stream_destroy() is passed direct to kunit_add_action(). */
-static void cleanup_raw_stream(void *p)
-{
-	struct string_stream *stream = p;
-
-	string_stream_destroy(stream);
-}
+KUNIT_DEFINE_ACTION_WRAPPER(cleanup_raw_stream, string_stream_destroy, struct string_stream *);
 
 static char *get_concatenated_string(struct kunit *test, struct string_stream *stream)
 {
-- 
2.34.1


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

* Re: [PATCH] kunit: string-stream-test: use KUNIT_DEFINE_ACTION_WRAPPER
  2024-04-23 18:27 [PATCH] kunit: string-stream-test: use KUNIT_DEFINE_ACTION_WRAPPER Ivan Orlov
@ 2024-04-23 21:35 ` Rae Moar
  2024-04-24  0:08 ` David Gow
  1 sibling, 0 replies; 3+ messages in thread
From: Rae Moar @ 2024-04-23 21:35 UTC (permalink / raw)
  To: Ivan Orlov
  Cc: brendan.higgins, davidgow, linux-kselftest, kunit-dev, linux-kernel

On Tue, Apr 23, 2024 at 2:27 PM Ivan Orlov <ivan.orlov0322@gmail.com> wrote:
>
> Use KUNIT_DEFINE_ACTION_WRAPPER macro to define the 'kfree' and
> 'string_stream_destroy' wrappers for kunit_add_action.
>
> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>

Hello!

This looks like a good use of the macro. Thanks!

Reviewed-by: Rae Moar <rmoar@google.com>

Thanks!
-Rae

> ---
>  lib/kunit/string-stream-test.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/lib/kunit/string-stream-test.c b/lib/kunit/string-stream-test.c
> index 03fb511826f7..7511442ea98f 100644
> --- a/lib/kunit/string-stream-test.c
> +++ b/lib/kunit/string-stream-test.c
> @@ -22,18 +22,10 @@ struct string_stream_test_priv {
>  };
>
>  /* Avoids a cast warning if kfree() is passed direct to kunit_add_action(). */
> -static void kfree_wrapper(void *p)
> -{
> -       kfree(p);
> -}
> +KUNIT_DEFINE_ACTION_WRAPPER(kfree_wrapper, kfree, const void *);
>
>  /* Avoids a cast warning if string_stream_destroy() is passed direct to kunit_add_action(). */
> -static void cleanup_raw_stream(void *p)
> -{
> -       struct string_stream *stream = p;
> -
> -       string_stream_destroy(stream);
> -}
> +KUNIT_DEFINE_ACTION_WRAPPER(cleanup_raw_stream, string_stream_destroy, struct string_stream *);
>
>  static char *get_concatenated_string(struct kunit *test, struct string_stream *stream)
>  {
> --
> 2.34.1
>

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

* Re: [PATCH] kunit: string-stream-test: use KUNIT_DEFINE_ACTION_WRAPPER
  2024-04-23 18:27 [PATCH] kunit: string-stream-test: use KUNIT_DEFINE_ACTION_WRAPPER Ivan Orlov
  2024-04-23 21:35 ` Rae Moar
@ 2024-04-24  0:08 ` David Gow
  1 sibling, 0 replies; 3+ messages in thread
From: David Gow @ 2024-04-24  0:08 UTC (permalink / raw)
  To: Ivan Orlov
  Cc: brendan.higgins, rmoar, linux-kselftest, kunit-dev, linux-kernel

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

On Wed, 24 Apr 2024 at 02:27, Ivan Orlov <ivan.orlov0322@gmail.com> wrote:
>
> Use KUNIT_DEFINE_ACTION_WRAPPER macro to define the 'kfree' and
> 'string_stream_destroy' wrappers for kunit_add_action.
>
> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
> ---

Acked-by: David Gow <davidgow@google.com>

Thanks,
-- David

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4014 bytes --]

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

end of thread, other threads:[~2024-04-24  0:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 18:27 [PATCH] kunit: string-stream-test: use KUNIT_DEFINE_ACTION_WRAPPER Ivan Orlov
2024-04-23 21:35 ` Rae Moar
2024-04-24  0:08 ` David Gow

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

all inboxes | Powered by JetHome®