Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/tests/core-kunit: remove unused ctx in damon_test_split_regions_of()

damon_test_split_regions_of() dynamically allocates a 'struct damon_ctx'
object, but it is not really being used in the code other than handling
the allocation failure and deallocating it at the end of the function.
Remove the unnecessary allocation and deallocation of the object.

Link: https://lkml.kernel.org/r/20251101182021.74868-23-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
80d725f9 40b11d1e

+2 -12
+2 -12
mm/damon/tests/core-kunit.h
··· 267 267 268 268 static void damon_test_split_regions_of(struct kunit *test) 269 269 { 270 - struct damon_ctx *c = damon_new_ctx(); 271 270 struct damon_target *t; 272 271 struct damon_region *r; 273 272 274 - if (!c) 275 - kunit_skip("ctx alloc fail"); 276 273 t = damon_new_target(); 277 - if (!t) { 278 - damon_destroy_ctx(c); 274 + if (!t) 279 275 kunit_skip(test, "target alloc fail"); 280 - } 281 276 r = damon_new_region(0, 22); 282 277 if (!r) { 283 - damon_destroy_ctx(c); 284 278 damon_free_target(t); 285 279 kunit_skip(test, "region alloc fail"); 286 280 } ··· 284 290 damon_free_target(t); 285 291 286 292 t = damon_new_target(); 287 - if (!t) { 288 - damon_destroy_ctx(c); 293 + if (!t) 289 294 kunit_skip(test, "second target alloc fail"); 290 - } 291 295 r = damon_new_region(0, 220); 292 296 if (!r) { 293 - damon_destroy_ctx(c); 294 297 damon_free_target(t); 295 298 kunit_skip(test, "second region alloc fail"); 296 299 } ··· 295 304 damon_split_regions_of(t, 4, DAMON_MIN_REGION); 296 305 KUNIT_EXPECT_LE(test, damon_nr_regions(t), 4u); 297 306 damon_free_target(t); 298 - damon_destroy_ctx(c); 299 307 } 300 308 301 309 static void damon_test_ops_registration(struct kunit *test)