linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Latypov <dlatypov@google.com>
To: brendanhiggins@google.com, davidgow@google.com
Cc: rmoar@google.com, linux-kernel@vger.kernel.org,
	kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org,
	skhan@linuxfoundation.org, Daniel Latypov <dlatypov@google.com>
Subject: [PATCH] kunit: remove KUNIT_INIT_MEM_ASSERTION macro
Date: Wed,  9 Nov 2022 13:20:32 -0800	[thread overview]
Message-ID: <20221109212032.123021-1-dlatypov@google.com> (raw)

Commit 870f63b7cd78 ("kunit: eliminate KUNIT_INIT_*_ASSERT_STRUCT
macros") removed all the other macros of this type.

But it raced with commit b8a926bea8b1 ("kunit: Introduce
KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros"), which added another
instance.

Remove KUNIT_INIT_MEM_ASSERTION and just use the generic
KUNIT_INIT_ASSERT macro instead.
Rename the `size` arg to avoid conflicts by appending a "_" (like we did
in the previous commit).

Signed-off-by: Daniel Latypov <dlatypov@google.com>
---
 include/kunit/assert.h |  7 -------
 include/kunit/test.h   | 12 ++++++------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/include/kunit/assert.h b/include/kunit/assert.h
index 43144cfddc19..24c2b9fa61e8 100644
--- a/include/kunit/assert.h
+++ b/include/kunit/assert.h
@@ -192,13 +192,6 @@ void kunit_binary_str_assert_format(const struct kunit_assert *assert,
 				    const struct va_format *message,
 				    struct string_stream *stream);
 
-#define KUNIT_INIT_MEM_ASSERT_STRUCT(text_, left_val, right_val, size_) {      \
-	.text = text_,							       \
-	.left_value = left_val,						       \
-	.right_value = right_val,				       	       \
-	.size = size_						       	       \
-}
-
 /**
  * struct kunit_mem_assert - An expectation/assertion that compares two
  *	memory blocks.
diff --git a/include/kunit/test.h b/include/kunit/test.h
index d7f60e8aab30..4666a4d199ea 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -666,13 +666,13 @@ do {									       \
 			    left,					       \
 			    op,						       \
 			    right,					       \
-			    size,					       \
+			    size_,					       \
 			    fmt,					       \
 			    ...)					       \
 do {									       \
 	const void *__left = (left);					       \
 	const void *__right = (right);					       \
-	const size_t __size = (size);					       \
+	const size_t __size = (size_);					       \
 	static const struct kunit_binary_assert_text __text = {		       \
 		.operation = #op,					       \
 		.left_text = #left,					       \
@@ -686,10 +686,10 @@ do {									       \
 		      assert_type,					       \
 		      kunit_mem_assert,					       \
 		      kunit_mem_assert_format,				       \
-		      KUNIT_INIT_MEM_ASSERT_STRUCT(&__text,		       \
-						   __left,		       \
-						   __right,		       \
-						   __size),		       \
+		      KUNIT_INIT_ASSERT(.text = &__text,		       \
+					.left_value = __left,		       \
+					.right_value = __right,		       \
+					.size = __size),		       \
 		      fmt,						       \
 		      ##__VA_ARGS__);					       \
 } while (0)

base-commit: 870f63b7cd78d0055902d839a60408f7428b4e84
-- 
2.38.1.431.g37b22c650d-goog


             reply	other threads:[~2022-11-09 21:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 21:20 Daniel Latypov [this message]
2022-11-19  8:24 ` [PATCH] kunit: remove KUNIT_INIT_MEM_ASSERTION macro David Gow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221109212032.123021-1-dlatypov@google.com \
    --to=dlatypov@google.com \
    --cc=brendanhiggins@google.com \
    --cc=davidgow@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=rmoar@google.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).