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.

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20250620111907.3395296-1-arnd@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Arnd Bergmann and committed by
Jakub Kicinski
7df6c024 b04202d6

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