Skip to content

Commit caf728d

Browse files
arndbakpm00
authored andcommitted
lib: test_objagg: split test_hints_case() into two functions
With sanitizers enabled, this function uses a lot of stack, causing a harmless warning: lib/test_objagg.c: In function 'test_hints_case.constprop': lib/test_objagg.c:994:1: error: the frame size of 1440 bytes is larger than 1408 bytes [-Werror=frame-larger-than=] Most of this is from the two 'struct world' structures. Since most of the work in this function is duplicated for the two, split it up into separate functions that each use one of them. The combined stack usage is still the same here, but there is no warning any more, and the code is still safe because of the known call chain. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4d71d99 commit caf728d

File tree

1 file changed

+45
-32
lines changed

1 file changed

+45
-32
lines changed

lib/test_objagg.c

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -908,50 +908,22 @@ static int check_expect_hints_stats(struct objagg_hints *objagg_hints,
908908
return err;
909909
}
910910

911-
static int test_hints_case(const struct hints_case *hints_case)
911+
static int test_hints_case2(const struct hints_case *hints_case,
912+
struct objagg_hints *hints, struct objagg *objagg)
912913
{
913914
struct objagg_obj *objagg_obj;
914-
struct objagg_hints *hints;
915915
struct world world2 = {};
916-
struct world world = {};
917916
struct objagg *objagg2;
918-
struct objagg *objagg;
919917
const char *errmsg;
920918
int i;
921919
int err;
922920

923-
objagg = objagg_create(&delta_ops, NULL, &world);
924-
if (IS_ERR(objagg))
925-
return PTR_ERR(objagg);
926-
927-
for (i = 0; i < hints_case->key_ids_count; i++) {
928-
objagg_obj = world_obj_get(&world, objagg,
929-
hints_case->key_ids[i]);
930-
if (IS_ERR(objagg_obj)) {
931-
err = PTR_ERR(objagg_obj);
932-
goto err_world_obj_get;
933-
}
934-
}
935-
936-
pr_debug_stats(objagg);
937-
err = check_expect_stats(objagg, &hints_case->expect_stats, &errmsg);
938-
if (err) {
939-
pr_err("Stats: %s\n", errmsg);
940-
goto err_check_expect_stats;
941-
}
942-
943-
hints = objagg_hints_get(objagg, OBJAGG_OPT_ALGO_SIMPLE_GREEDY);
944-
if (IS_ERR(hints)) {
945-
err = PTR_ERR(hints);
946-
goto err_hints_get;
947-
}
948-
949921
pr_debug_hints_stats(hints);
950922
err = check_expect_hints_stats(hints, &hints_case->expect_stats_hints,
951923
&errmsg);
952924
if (err) {
953925
pr_err("Hints stats: %s\n", errmsg);
954-
goto err_check_expect_hints_stats;
926+
return err;
955927
}
956928

957929
objagg2 = objagg_create(&delta_ops, hints, &world2);
@@ -983,7 +955,48 @@ static int test_hints_case(const struct hints_case *hints_case)
983955
world_obj_put(&world2, objagg, hints_case->key_ids[i]);
984956
i = hints_case->key_ids_count;
985957
objagg_destroy(objagg2);
986-
err_check_expect_hints_stats:
958+
959+
return err;
960+
}
961+
962+
static int test_hints_case(const struct hints_case *hints_case)
963+
{
964+
struct objagg_obj *objagg_obj;
965+
struct objagg_hints *hints;
966+
struct world world = {};
967+
struct objagg *objagg;
968+
const char *errmsg;
969+
int i;
970+
int err;
971+
972+
objagg = objagg_create(&delta_ops, NULL, &world);
973+
if (IS_ERR(objagg))
974+
return PTR_ERR(objagg);
975+
976+
for (i = 0; i < hints_case->key_ids_count; i++) {
977+
objagg_obj = world_obj_get(&world, objagg,
978+
hints_case->key_ids[i]);
979+
if (IS_ERR(objagg_obj)) {
980+
err = PTR_ERR(objagg_obj);
981+
goto err_world_obj_get;
982+
}
983+
}
984+
985+
pr_debug_stats(objagg);
986+
err = check_expect_stats(objagg, &hints_case->expect_stats, &errmsg);
987+
if (err) {
988+
pr_err("Stats: %s\n", errmsg);
989+
goto err_check_expect_stats;
990+
}
991+
992+
hints = objagg_hints_get(objagg, OBJAGG_OPT_ALGO_SIMPLE_GREEDY);
993+
if (IS_ERR(hints)) {
994+
err = PTR_ERR(hints);
995+
goto err_hints_get;
996+
}
997+
998+
err = test_hints_case2(hints_case, hints, objagg);
999+
9871000
objagg_hints_put(hints);
9881001
err_hints_get:
9891002
err_check_expect_stats:

0 commit comments

Comments
 (0)