aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/codesearch/testdata/source0.c
blob: 4d90dddbfe3d68ff7af12097387844880a2bac2e (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
53
// Copyright 2025 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 "source0.h"

struct struct_in_c_file {
	int X;
	struct some_struct by_value;
};

/*
 * Comment about open.
 */
int open()
{
	return 0;
}

int close()
{
	return 0;
}

void function_with_comment_in_header()
{
	same_name_in_several_files();
}

int func_accepting_a_struct(struct some_struct* p)
{
	return ((some_struct_t*)p)->x +
	       ((union some_union*)p)->x;
}

void function_with_quotes_in_type(void __attribute__((btf_type_tag("user"))) *)
{
}

int field_refs(struct some_struct* p, union some_union* u)
{
	p->x = p->y;
	*(&p->x) = 1;
	u->p = 0;
	u->s.x = 2;
	return p->x;
}

// compile_commands.json we create for tests defines KBUILD_BASENAME.
// If it's not defined, compile_commands.json is not properly loaded.
// This is supposed to fail builds, if that happens.
#ifndef KBUILD_BASENAME
#error "compile_commands.json is not loaded"
#endif