Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that only one definition of ASSERT is present #3557

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/chacha20.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ static const size_t test_lengths[2] =
375U
};

/* Make sure no other definition is already present. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A conforming C implementation isn't allowed to define ASSERT: it's in the application namespace.

In this C file, we only include a few standard library headers, some headers of our own, config.h, and possibly platform_alt.h. Where is ASSERT coming from on your build? None of them should define ASSERT, but I realize that some embedded platforms define macros with “convenient” names that are officially reserved for applications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it from other libraries I have with the project. I understand that these macros are only used for testing and maybe you don't want to #undef every macro.
It's just common to #undef common macros before defining them to avoid warnings. I'm okay with it if we drop this patch.

#undef ASSERT

#define ASSERT( cond, args ) \
do \
{ \
Expand Down
3 changes: 3 additions & 0 deletions library/chachapoly.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ static const unsigned char test_mac[1][16] =
}
};

/* Make sure no other definition is already present. */
#undef ASSERT

#define ASSERT( cond, args ) \
do \
{ \
Expand Down
3 changes: 3 additions & 0 deletions library/poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ static const unsigned char test_mac[2][16] =
}
};

/* Make sure no other definition is already present. */
#undef ASSERT

#define ASSERT( cond, args ) \
do \
{ \
Expand Down
3 changes: 3 additions & 0 deletions undef_assert_before_defining_it.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Changes
* Undefine the ASSERT macro before defining it locally, in case it is defined
in a platform header. Contributed by Abdelatif Guettouche in #3557.