xref: /linux/tools/testing/selftests/bpf/progs/verifier_may_goto_2.c (revision d0d106a2bd21499901299160744e5fe9f4c83ddb)
1*14a627feSYonghong Song // SPDX-License-Identifier: GPL-2.0
2*14a627feSYonghong Song /* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
3*14a627feSYonghong Song 
4*14a627feSYonghong Song #include "bpf_misc.h"
5*14a627feSYonghong Song #include "bpf_experimental.h"
6*14a627feSYonghong Song 
7*14a627feSYonghong Song int gvar;
8*14a627feSYonghong Song 
9*14a627feSYonghong Song SEC("raw_tp")
10*14a627feSYonghong Song __description("C code with may_goto 0")
11*14a627feSYonghong Song __success
may_goto_c_code(void)12*14a627feSYonghong Song int may_goto_c_code(void)
13*14a627feSYonghong Song {
14*14a627feSYonghong Song 	int i, tmp[3];
15*14a627feSYonghong Song 
16*14a627feSYonghong Song 	for (i = 0; i < 3 && can_loop; i++)
17*14a627feSYonghong Song 		tmp[i] = 0;
18*14a627feSYonghong Song 
19*14a627feSYonghong Song 	for (i = 0; i < 3 && can_loop; i++)
20*14a627feSYonghong Song 		tmp[i] = gvar - i;
21*14a627feSYonghong Song 
22*14a627feSYonghong Song 	for (i = 0; i < 3 && can_loop; i++)
23*14a627feSYonghong Song 		gvar += tmp[i];
24*14a627feSYonghong Song 
25*14a627feSYonghong Song 	return 0;
26*14a627feSYonghong Song }
27*14a627feSYonghong Song 
28*14a627feSYonghong Song char _license[] SEC("license") = "GPL";
29