From: David Gow <davidgow@google.com>
To: Nathan Chancellor <nathan@kernel.org>,
Kees Cook <keescook@chromium.org>,
Brendan Higgins <brendan.higgins@linux.dev>,
Rae Moar <rmoar@google.com>,
dlatypov@google.com, Maxime Ripard <mripard@kernel.org>,
Arthur Grillo <arthurgrillo@riseup.net>,
Shuah Khan <skhan@linuxfoundation.org>
Cc: "David Gow" <davidgow@google.com>,
"Maíra Canal" <mairacanal@riseup.net>,
"Sami Tolvanen" <samitolvanen@google.com>,
kunit-dev@googlegroups.com, llvm@lists.linux.dev,
linux-hardening@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Benjamin Berg" <benjamin.berg@intel.com>,
"Richard Fitzgerald" <rf@opensource.cirrus.com>,
linux-kernel@vger.kernel.org,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Emma Anholt" <emma@anholt.net>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org
Subject: [PATCH 3/3] drm/vc4: tests: Use KUNIT_DEFINE_ACTION_WRAPPER
Date: Sat, 11 Nov 2023 04:08:28 +0800 [thread overview]
Message-ID: <20231110200830.1832556-3-davidgow@google.com> (raw)
In-Reply-To: <20231110200830.1832556-1-davidgow@google.com>
In order to pass functions to kunit_add_action(), they need to be of the
kunit_action_t type. While casting the function pointer can work, it
will break control-flow integrity.
vc4_mock already defines such a wrapper for drm_dev_unregister(), but it
involves less boilerplate to use the new macro, so replace the manual
implementation.
Signed-off-by: David Gow <davidgow@google.com>
---
This patch should be a no-op, just moving to use a standard macro to
implement these wrappers rather than hand-coding them.
Let me know if you'd prefer to take these in separately via the drm
trees, or if you're okay with having this whole series go via
kselftest/kunit.
Cheers,
-- David
---
drivers/gpu/drm/vc4/tests/vc4_mock.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock.c b/drivers/gpu/drm/vc4/tests/vc4_mock.c
index 63ca46f4cb35..becb3dbaa548 100644
--- a/drivers/gpu/drm/vc4/tests/vc4_mock.c
+++ b/drivers/gpu/drm/vc4/tests/vc4_mock.c
@@ -153,12 +153,9 @@ static int __build_mock(struct kunit *test, struct drm_device *drm,
return 0;
}
-static void kunit_action_drm_dev_unregister(void *ptr)
-{
- struct drm_device *drm = ptr;
-
- drm_dev_unregister(drm);
-}
+KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_drm_dev_unregister,
+ drm_dev_unregister,
+ struct drm_device *);
static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5)
{
--
2.42.0.869.gea05f2083d-goog
WARNING: multiple messages have this Message-ID (diff)
From: David Gow <davidgow@google.com>
To: Nathan Chancellor <nathan@kernel.org>,
Kees Cook <keescook@chromium.org>,
Brendan Higgins <brendan.higgins@linux.dev>,
Rae Moar <rmoar@google.com>,
dlatypov@google.com, Maxime Ripard <mripard@kernel.org>,
Arthur Grillo <arthurgrillo@riseup.net>,
Shuah Khan <skhan@linuxfoundation.org>
Cc: linux-kselftest@vger.kernel.org,
"David Gow" <davidgow@google.com>,
"Emma Anholt" <emma@anholt.net>,
"Benjamin Berg" <benjamin.berg@intel.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org,
"Maíra Canal" <mairacanal@riseup.net>,
"Richard Fitzgerald" <rf@opensource.cirrus.com>,
linux-hardening@vger.kernel.org,
"Sami Tolvanen" <samitolvanen@google.com>,
kunit-dev@googlegroups.com
Subject: [PATCH 3/3] drm/vc4: tests: Use KUNIT_DEFINE_ACTION_WRAPPER
Date: Sat, 11 Nov 2023 04:08:28 +0800 [thread overview]
Message-ID: <20231110200830.1832556-3-davidgow@google.com> (raw)
In-Reply-To: <20231110200830.1832556-1-davidgow@google.com>
In order to pass functions to kunit_add_action(), they need to be of the
kunit_action_t type. While casting the function pointer can work, it
will break control-flow integrity.
vc4_mock already defines such a wrapper for drm_dev_unregister(), but it
involves less boilerplate to use the new macro, so replace the manual
implementation.
Signed-off-by: David Gow <davidgow@google.com>
---
This patch should be a no-op, just moving to use a standard macro to
implement these wrappers rather than hand-coding them.
Let me know if you'd prefer to take these in separately via the drm
trees, or if you're okay with having this whole series go via
kselftest/kunit.
Cheers,
-- David
---
drivers/gpu/drm/vc4/tests/vc4_mock.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock.c b/drivers/gpu/drm/vc4/tests/vc4_mock.c
index 63ca46f4cb35..becb3dbaa548 100644
--- a/drivers/gpu/drm/vc4/tests/vc4_mock.c
+++ b/drivers/gpu/drm/vc4/tests/vc4_mock.c
@@ -153,12 +153,9 @@ static int __build_mock(struct kunit *test, struct drm_device *drm,
return 0;
}
-static void kunit_action_drm_dev_unregister(void *ptr)
-{
- struct drm_device *drm = ptr;
-
- drm_dev_unregister(drm);
-}
+KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_drm_dev_unregister,
+ drm_dev_unregister,
+ struct drm_device *);
static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5)
{
--
2.42.0.869.gea05f2083d-goog
next prev parent reply other threads:[~2023-11-10 20:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 20:08 [PATCH 1/3] kunit: Add a macro to wrap a deferred action function David Gow
2023-11-10 20:08 ` David Gow
2023-11-10 20:08 ` [PATCH 2/3] drm/tests: Use KUNIT_DEFINE_ACTION_WRAPPER() David Gow
2023-11-10 20:08 ` David Gow
2023-11-15 15:50 ` Maxime Ripard
2023-11-15 15:50 ` Maxime Ripard
2023-11-10 20:08 ` David Gow [this message]
2023-11-10 20:08 ` [PATCH 3/3] drm/vc4: tests: Use KUNIT_DEFINE_ACTION_WRAPPER David Gow
2023-11-15 15:23 ` [PATCH 1/3] kunit: Add a macro to wrap a deferred action function Nathan Chancellor
2023-11-15 15:23 ` Nathan Chancellor
2023-11-15 15:51 ` Maxime Ripard
2023-11-15 15:51 ` Maxime Ripard
2023-11-15 16:00 ` Daniel Vetter
2023-11-15 16:00 ` Daniel Vetter
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=20231110200830.1832556-3-davidgow@google.com \
--to=davidgow@google.com \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=benjamin.berg@intel.com \
--cc=brendan.higgins@linux.dev \
--cc=daniel@ffwll.ch \
--cc=dlatypov@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emma@anholt.net \
--cc=keescook@chromium.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=mripard@kernel.org \
--cc=nathan@kernel.org \
--cc=rf@opensource.cirrus.com \
--cc=rmoar@google.com \
--cc=samitolvanen@google.com \
--cc=skhan@linuxfoundation.org \
--cc=tzimmermann@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.