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

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/20250620111907.3395296-1-arnd@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Arnd Bergmann and committed by
Andrew Morton
caf728df 4d71d99f

+45 -32
+45 -32
lib/test_objagg.c
··· 908 908 return err; 909 909 } 910 910 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) 912 913 { 913 914 struct objagg_obj *objagg_obj; 914 - struct objagg_hints *hints; 915 915 struct world world2 = {}; 916 - struct world world = {}; 917 916 struct objagg *objagg2; 918 - struct objagg *objagg; 919 917 const char *errmsg; 920 918 int i; 921 919 int err; 922 - 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 920 949 921 pr_debug_hints_stats(hints); 950 922 err = check_expect_hints_stats(hints, &hints_case->expect_stats_hints, 951 923 &errmsg); 952 924 if (err) { 953 925 pr_err("Hints stats: %s\n", errmsg); 954 - goto err_check_expect_hints_stats; 926 + return err; 955 927 } 956 928 957 929 objagg2 = objagg_create(&delta_ops, hints, &world2); ··· 955 983 world_obj_put(&world2, objagg, hints_case->key_ids[i]); 956 984 i = hints_case->key_ids_count; 957 985 objagg_destroy(objagg2); 958 - err_check_expect_hints_stats: 986 + 987 + return err; 988 + } 989 + 990 + static int test_hints_case(const struct hints_case *hints_case) 991 + { 992 + struct objagg_obj *objagg_obj; 993 + struct objagg_hints *hints; 994 + struct world world = {}; 995 + struct objagg *objagg; 996 + const char *errmsg; 997 + int i; 998 + int err; 999 + 1000 + objagg = objagg_create(&delta_ops, NULL, &world); 1001 + if (IS_ERR(objagg)) 1002 + return PTR_ERR(objagg); 1003 + 1004 + for (i = 0; i < hints_case->key_ids_count; i++) { 1005 + objagg_obj = world_obj_get(&world, objagg, 1006 + hints_case->key_ids[i]); 1007 + if (IS_ERR(objagg_obj)) { 1008 + err = PTR_ERR(objagg_obj); 1009 + goto err_world_obj_get; 1010 + } 1011 + } 1012 + 1013 + pr_debug_stats(objagg); 1014 + err = check_expect_stats(objagg, &hints_case->expect_stats, &errmsg); 1015 + if (err) { 1016 + pr_err("Stats: %s\n", errmsg); 1017 + goto err_check_expect_stats; 1018 + } 1019 + 1020 + hints = objagg_hints_get(objagg, OBJAGG_OPT_ALGO_SIMPLE_GREEDY); 1021 + if (IS_ERR(hints)) { 1022 + err = PTR_ERR(hints); 1023 + goto err_hints_get; 1024 + } 1025 + 1026 + err = test_hints_case2(hints_case, hints, objagg); 1027 + 959 1028 objagg_hints_put(hints); 960 1029 err_hints_get: 961 1030 err_check_expect_stats: