aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-declextract/testdata/functions.c
blob: 30e5447021a18cbcecdfbb0667408bcdeec3b477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2024 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

#include "include/fs.h"
#include "include/types.h"
#include "include/syscall.h"

static void func_foo() {
}

static void func_bar() {
	func_foo();
}

int func_baz(int f) {
	func_foo();
	if (f)
		func_bar();
	if (__builtin_constant_p(f))
		func_bar();
	if (f)
		return from_kuid();
	return alloc_fd();
}

int func_qux() {
	int fd = alloc_fd();
	return fd;
}

SYSCALL_DEFINE1(functions, long x) {
	__fget_light(x);
	return func_baz(1);
}

struct Typed {
  int a;
  int b;
  int c;
};

int typing1(int a, int b) {
  return a;
}

int typing(struct Typed* t1, int i) {
  struct Typed t2;
  t2.a = t1->b;
  int l = typing1(i, t2.a);
  t1->c = l;
  return l;
}