Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit 2b3022e

Browse files
committed
Resolving conflicting definitions of assert macro
With the insertion of `assert(0)` into the body of `reach_error` it was necessary to include the `assert.h` system header. Some tasks, however, already defined the `assert` macro themselves (expanding to calls to `reach_error()`). To avoid compiler/preprocessor warnings about conflicting macro definitions, prefix the local `assert` definitions by `#undef assert` to disable the prior definition. The changes were done using the following command: ``` for f in c/aws-c-common/prelude.h c/*/*.c do perl -i -e \ '$p = 0; $e = 0; while(<>) { if(/^#define\s+assert\(\w+\)/) { print "#undef assert\n"; } print; }' \ $f done ```
1 parent 3d31787 commit 2b3022e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+67
-0
lines changed

c/aws-c-common/prelude.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void __VERIFIER_assert(_Bool cond) {
2323

2424
#define __CPROVER_size_t unsigned long
2525

26+
#undef assert
2627
#define assert(cond) \
2728
__VERIFIER_assert(cond)
2829

c/pthread-atomic/dekker.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ void reach_error() { assert(0); }
1111
*/
1212

1313
#include <pthread.h>
14+
#undef assert
1415
#define assert(e) if (!(e)) ERROR: reach_error()
1516

1617
int flag1 = 0, flag2 = 0; // boolean flags

c/pthread-atomic/lamport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void reach_error() { assert(0); }
77
*/
88

99
#include <pthread.h>
10+
#undef assert
1011
#define assert(e) if (!(e)) ERROR: reach_error()
1112

1213
int x, y;

c/pthread-atomic/peterson.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void reach_error() { assert(0); }
77
*/
88

99
#include <pthread.h>
10+
#undef assert
1011
#define assert(e) if (!(e)) ERROR: reach_error()
1112

1213
int flag1 = 0, flag2 = 0; // boolean flags

c/pthread-atomic/qrcu-1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extern int __VERIFIER_nondet_int();
1616
*/
1717

1818
#include <pthread.h>
19+
#undef assert
1920
#define assert(e) if (!(e)) ERROR: reach_error()
2021

2122
int idx=0; // boolean to control which of the two elements will be used by readers

c/pthread-atomic/qrcu-2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extern int __VERIFIER_nondet_int();
1616
*/
1717

1818
#include <pthread.h>
19+
#undef assert
1920
#define assert(e) if (!(e)) ERROR: reach_error()
2021

2122
int idx=0; // boolean to control which of the two elements will be used by readers

c/pthread-atomic/read_write_lock-1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void reach_error() { assert(0); }
1515
*/
1616

1717
#include <pthread.h>
18+
#undef assert
1819
#define assert(e) if (!(e)) ERROR: reach_error()
1920

2021
int w=0, r=0, x, y;

c/pthread-atomic/read_write_lock-2.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void reach_error() { assert(0); }
1515
*/
1616

1717
#include <pthread.h>
18+
#undef assert
1819
#define assert(e) if (!(e)) ERROR: reach_error()
1920

2021
int w=0, r=0, x, y;

c/pthread-atomic/scull.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ extern int __VERIFIER_nondet_int();
8383

8484

8585

86+
#undef assert
8687
#define assert(e) if (!(e)) ERROR: reach_error()
8788

8889
inode i;

c/pthread-atomic/szymanski.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void reach_error() { assert(0); }
77
*/
88

99
#include <pthread.h>
10+
#undef assert
1011
#define assert(e) if (!(e)) ERROR: reach_error()
1112

1213
int flag1 = 0, flag2 = 0; // integer flags

0 commit comments

Comments
 (0)