Make default output less verbose (source/object paths)
[ghc.git] / utils / coverity / model.c
1 /* Coverity Scan model
2 * This is a modeling file for Coverity Scan. Modeling helps to avoid false
3 * positives.
4 *
5 * - A model file can't import any header files. Some built-in primitives are
6 * available but not wchar_t, NULL etc.
7 * - Modeling doesn't need full structs and typedefs. Rudimentary structs
8 * and similar types are sufficient.
9 * - An uninitialized local variable signifies that the variable could be
10 * any value.
11 *
12 * The model file must be uploaded by an admin in the analysis settings of
13 * http://scan.coverity.com/projects/1919
14 */
15
16 #define NULL ((void*)0)
17 #define assert(x) if (!(x)) __coverity_panic__();
18
19 /* type decls */
20 typedef struct {} va_list;
21
22 /* glibc functions */
23 void *malloc (size_t);
24 void *calloc (size_t, size_t);
25 void *realloc (void *, size_t);
26 void free (void *);
27
28 /* rts allocation functions */
29
30 void* stgMallocBytes(int n, char *msg)
31 {
32 void *mem;
33 __coverity_negative_sink__((size_t)n);
34 mem = malloc((size_t)n);
35 assert(mem != NULL);
36 return mem;
37 }
38
39 void* stgReallocBytes(void *p, int n, char *msg)
40 {
41 void *mem;
42 __coverity_negative_sink__((size_t)n);
43
44 /* man 3 realloc: if p == NULL, then realloc is equivalent to malloc() */
45 if (p == NULL) {
46 mem = malloc((size_t)n);
47 assert(mem != NULL);
48 return mem;
49 }
50
51 /* man 3 realloc: if n == 0, then realloc is equivalent to free() */
52 if (n == 0) {
53 free(p);
54 return NULL;
55 } else {
56 mem = realloc(p, (size_t)n);
57 assert(mem != NULL);
58 return mem;
59 }
60 }
61
62 void* stgCallocBytes(int n, int m, char *msg)
63 {
64 void *mem;
65 __coverity_negative_sink__((size_t)n);
66 __coverity_negative_sink__((size_t)m);
67 mem = calloc(n, m);
68 assert(mem != NULL);
69 return mem;
70 }
71
72 void stgFree(void* p)
73 {
74 free(p);
75 }
76
77 /* Kill paths */
78
79 void stg_exit(int n)
80 {
81 __coverity_panic__();
82 }
83
84 void shutdownThread(void)
85 {
86 __coverity_panic__();
87 }
88
89 void shutdownHaskellAndExit(int exitCode, int fastExit)
90 {
91 __coverity_panic__();
92 }
93
94 void shutdownHaskellAndSignal(int sig, int fastExit)
95 {
96 __coverity_panic__();
97 }
98
99 void _assertFail(const char *filename, unsigned int linenum)
100 {
101 __coverity_panic__();
102 }
103
104 void barf(const char *s, ...)
105 {
106 __coverity_panic__();
107 }
108
109 void vbarf(const char *s, va_list ap)
110 {
111 __coverity_panic__();
112 }