github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/tools/syz-declextract/testdata/functions.c (about)

     1  // Copyright 2024 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  #include "include/fs.h"
     5  #include "include/types.h"
     6  #include "include/syscall.h"
     7  
     8  static void func_foo() {
     9  }
    10  
    11  static void func_bar() {
    12  	func_foo();
    13  }
    14  
    15  int func_baz(int f) {
    16  	func_foo();
    17  	if (f)
    18  		func_bar();
    19  	if (__builtin_constant_p(f))
    20  		func_bar();
    21  	if (f)
    22  		return from_kuid();
    23  	return alloc_fd();
    24  }
    25  
    26  int func_qux() {
    27  	int fd = alloc_fd();
    28  	return fd;
    29  }
    30  
    31  SYSCALL_DEFINE1(functions, long x) {
    32  	__fget_light(x);
    33  	return func_baz(1);
    34  }
    35  
    36  struct Typed {
    37    int a;
    38    int b;
    39    int c;
    40  };
    41  
    42  int typing1(int a, int b) {
    43    return a;
    44  }
    45  
    46  int typing(struct Typed* t1, int i) {
    47    struct Typed t2;
    48    t2.a = t1->b;
    49    int l = typing1(i, t2.a);
    50    t1->c = l;
    51    return l;
    52  }