kunit: use kmemdup in kunit_filter_tests(), take suite as const
kmemdup() is easier than kmalloc() + memcpy(), per lkp bot.
Also make the input `suite` as const since we're now always making
copies after commit a127b154a8
("kunit: tool: allow filtering test
cases via glob").
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
parent
671007281d
commit
d2fbdde838
|
@ -55,7 +55,7 @@ static void kunit_parse_filter_glob(struct kunit_test_filter *parsed,
|
||||||
|
|
||||||
/* Create a copy of suite with only tests that match test_glob. */
|
/* Create a copy of suite with only tests that match test_glob. */
|
||||||
static struct kunit_suite *
|
static struct kunit_suite *
|
||||||
kunit_filter_tests(struct kunit_suite *const suite, const char *test_glob)
|
kunit_filter_tests(const struct kunit_suite *const suite, const char *test_glob)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
struct kunit_case *filtered, *test_case;
|
struct kunit_case *filtered, *test_case;
|
||||||
|
@ -69,11 +69,9 @@ kunit_filter_tests(struct kunit_suite *const suite, const char *test_glob)
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Use memcpy to workaround copy->name being const. */
|
copy = kmemdup(suite, sizeof(*copy), GFP_KERNEL);
|
||||||
copy = kmalloc(sizeof(*copy), GFP_KERNEL);
|
|
||||||
if (!copy)
|
if (!copy)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
memcpy(copy, suite, sizeof(*copy));
|
|
||||||
|
|
||||||
filtered = kcalloc(n + 1, sizeof(*filtered), GFP_KERNEL);
|
filtered = kcalloc(n + 1, sizeof(*filtered), GFP_KERNEL);
|
||||||
if (!filtered)
|
if (!filtered)
|
||||||
|
|
Loading…
Reference in New Issue