Skip to content

Commit 6c354a5

Browse files
committed
C library: remove explicit zero initialisers
We initialise (with the default zero) value global variables in multiple model functions, which can result in spurious warnings about those variables already having an initial value. Towards: #8638
1 parent 4a1a325 commit 6c354a5

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/ansi-c/library/cprover_contracts.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#define __CPROVER_contracts_library_defined
88

99
// external dependencies
10-
const void *__CPROVER_alloca_object = 0;
10+
const void *__CPROVER_alloca_object;
1111
extern const void *__CPROVER_deallocated;
12-
const void *__CPROVER_new_object = 0;
12+
const void *__CPROVER_new_object;
1313
extern const void *__CPROVER_memory_leak;
14-
__CPROVER_bool __CPROVER_malloc_is_new_array = 0;
14+
__CPROVER_bool __CPROVER_malloc_is_new_array;
1515
#if defined(_WIN32) && defined(_M_X64)
1616
int __builtin_clzll(unsigned long long);
1717
#else

src/ansi-c/library/getopt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define __CPROVER_STRING_H_INCLUDED
66
#endif
77

8-
char *optarg = NULL;
8+
char *optarg;
99
int optind = 1;
1010

1111
__CPROVER_bool __VERIFIER_nondet___CPROVER_bool(void);

src/ansi-c/library/pthread_lib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ __CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
341341
#ifndef LIBRARY_CHECK
342342
__CPROVER_thread_local unsigned long __CPROVER_thread_id = 0;
343343
#endif
344-
unsigned long __CPROVER_next_thread_id = 0;
344+
unsigned long __CPROVER_next_thread_id;
345345

346346
int pthread_join(pthread_t thread, void **value_ptr)
347347
{
@@ -379,7 +379,7 @@ __CPROVER_HIDE:;
379379
__CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
380380
# ifndef LIBRARY_CHECK
381381
__CPROVER_thread_local unsigned long __CPROVER_thread_id = 0;
382-
unsigned long __CPROVER_next_thread_id = 0;
382+
unsigned long __CPROVER_next_thread_id;
383383
# endif
384384

385385
int _pthread_join(pthread_t thread, void **value_ptr)
@@ -615,7 +615,7 @@ __CPROVER_HIDE:;
615615
#endif
616616

617617
#ifndef LIBRARY_CHECK
618-
unsigned long __CPROVER_next_thread_id = 0;
618+
unsigned long __CPROVER_next_thread_id;
619619
# if 0
620620
__CPROVER_thread_local void (
621621
*__CPROVER_thread_key_dtors[__CPROVER_constant_infinity_uint])(void *);

src/ansi-c/library/stdlib.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ __CPROVER_bool __VERIFIER_nondet___CPROVER_bool(void);
141141
#ifndef __GNUC__
142142
_Bool __builtin_mul_overflow();
143143
#endif
144-
__CPROVER_bool __CPROVER_malloc_is_new_array = 0;
144+
__CPROVER_bool __CPROVER_malloc_is_new_array;
145145

146146
void *calloc(__CPROVER_size_t nmemb, __CPROVER_size_t size)
147147
{
@@ -204,7 +204,7 @@ __CPROVER_HIDE:;
204204

205205
__CPROVER_bool __VERIFIER_nondet___CPROVER_bool(void);
206206
#ifndef LIBRARY_CHECK
207-
__CPROVER_bool __CPROVER_malloc_is_new_array = 0;
207+
__CPROVER_bool __CPROVER_malloc_is_new_array;
208208
#endif
209209

210210
// malloc is marked "inline" for the benefit of goto-analyzer. Really,
@@ -262,9 +262,9 @@ __CPROVER_HIDE:;
262262
/* FUNCTION: __builtin_alloca */
263263

264264
__CPROVER_bool __VERIFIER_nondet___CPROVER_bool(void);
265-
const void *__CPROVER_alloca_object = 0;
265+
const void *__CPROVER_alloca_object;
266266
#ifndef LIBRARY_CHECK
267-
__CPROVER_bool __CPROVER_malloc_is_new_array = 0;
267+
__CPROVER_bool __CPROVER_malloc_is_new_array;
268268
#endif
269269

270270
void *__builtin_alloca(__CPROVER_size_t alloca_size)
@@ -307,11 +307,11 @@ __CPROVER_HIDE:;
307307
void __CPROVER_deallocate(void *);
308308
__CPROVER_bool __VERIFIER_nondet___CPROVER_bool(void);
309309
#ifndef LIBRARY_CHECK
310-
const void *__CPROVER_alloca_object = 0;
310+
const void *__CPROVER_alloca_object;
311311
#endif
312-
const void *__CPROVER_new_object = 0;
312+
const void *__CPROVER_new_object;
313313
#ifndef LIBRARY_CHECK
314-
__CPROVER_bool __CPROVER_malloc_is_new_array = 0;
314+
__CPROVER_bool __CPROVER_malloc_is_new_array;
315315
#endif
316316

317317
void free(void *ptr)

src/ansi-c/library/unistd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int unlink(const char *s)
8383
extern struct __CPROVER_pipet __CPROVER_pipes[__CPROVER_constant_infinity_uint];
8484
// offset to make sure we don't collide with other fds
8585
extern const int __CPROVER_pipe_offset;
86-
unsigned __CPROVER_pipe_count = 0;
86+
unsigned __CPROVER_pipe_count;
8787

8888
__CPROVER_bool __VERIFIER_nondet___CPROVER_bool(void);
8989

0 commit comments

Comments
 (0)