Skip to content

Commit

Permalink
refactor: fix linter and code style warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
abdes committed Jul 14, 2023
1 parent 62ebb7a commit e123836
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion contract-ut/test/contract_ut_gtest_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void NestedViolator(const int* ptr)
CHECK_VIOLATES_CONTRACT(TestAssertDefault(ptr));
TestEnsureDefault(nullptr);
}
void Violator(int* ptr)
void Violator(const int* ptr)
{
CHECK_VIOLATES_CONTRACT(TestAssertDefault(ptr));
CHECK_VIOLATES_CONTRACT(NestedViolator(ptr));
Expand Down
18 changes: 9 additions & 9 deletions contract/include/contract/contract.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ ASAP_CONTRACT_API auto GetViolationHandler() -> ViolationHandler&;
message, \
return_value) \
std::ostringstream debug; \
debug << message; \
debug << message; /*NOLINT*/ \
const auto& message_str = debug.str(); \
const struct asap::contract::Violation violation = { \
__FILE__, \
Expand Down Expand Up @@ -406,34 +406,34 @@ ASAP_CONTRACT_API auto GetViolationHandler() -> ViolationHandler&;
# if defined ASAP_CONTRACT_DEFAULT
# error At most one of ASAP_CONTRACT_OFF, ASAP_CONTRACT_DEFAULT, ASAP_CONTRACT_AUDIT must be specified
# endif
# define ASAP_CONTRACT_BUILD__ ASAP_CONTRACT_BUILD_MODE_OFF_
# define ASAP_CONTRACT_BUILD_ ASAP_CONTRACT_BUILD_MODE_OFF_
# elif defined ASAP_CONTRACT_DEFAULT
# if defined ASAP_CONTRACT_AUDIT
# error At most one of ASAP_CONTRACT_OFF, ASAP_CONTRACT_DEFAULT, ASAP_CONTRACT_AUDIT must be specified
# endif
# define ASAP_CONTRACT_BUILD__ ASAP_CONTRACT_BUILD_MODE_DEFAULT_
# define ASAP_CONTRACT_BUILD_ ASAP_CONTRACT_BUILD_MODE_DEFAULT_
# elif defined ASAP_CONTRACT_AUDIT
# define ASAP_CONTRACT_BUILD__ ASAP_CONTRACT_BUILD_MODE_AUDIT_
# define ASAP_CONTRACT_BUILD_ ASAP_CONTRACT_BUILD_MODE_AUDIT_
# else /* Default build */
# define ASAP_CONTRACT_BUILD__ ASAP_CONTRACT_BUILD_MODE_DEFAULT_
# define ASAP_CONTRACT_BUILD_ ASAP_CONTRACT_BUILD_MODE_DEFAULT_
# endif

# define ASAP_CONTRACT_BUILD_MODE_OFF__ 0
# define ASAP_CONTRACT_BUILD_MODE_OFF_ 0
# define ASAP_CONTRACT_BUILD_MODE_DEFAULT_ 1
# define ASAP_CONTRACT_BUILD_MODE_AUDIT_ 2

/* Standard build configurations */
# if ASAP_CONTRACT_BUILD__ == ASAP_CONTRACT_BUILD_MODE_OFF_
# if ASAP_CONTRACT_BUILD_ == ASAP_CONTRACT_BUILD_MODE_OFF_
# define ASAP_CONTRACT_MODE_DEFAULT_ ASAP_CONTRACT_IGNORE_
# define ASAP_C_A_MODE_DEFAULT_ ASAP_C_A_IGNORE_
# define ASAP_A_U_MODE_DEFAULT_ ASAP_A_U_IGNORE_
# define ASAP_CONTRACT_MODE_AUDIT_ ASAP_CONTRACT_IGNORE_
# elif ASAP_CONTRACT_BUILD__ == ASAP_CONTRACT_BUILD_MODE_DEFAULT_
# elif ASAP_CONTRACT_BUILD_ == ASAP_CONTRACT_BUILD_MODE_DEFAULT_
# define ASAP_CONTRACT_MODE_DEFAULT_ ASAP_CONTRACT_CHECK_NEVER_CONTINUE_
# define ASAP_C_A_MODE_DEFAULT_ ASAP_C_A_CHECK_NEVER_CONTINUE_
# define ASAP_A_U_MODE_DEFAULT_ ASAP_A_U_CHECK_NEVER_CONTINUE_
# define ASAP_CONTRACT_MODE_AUDIT_ ASAP_CONTRACT_IGNORE_
# elif ASAP_CONTRACT_BUILD__ == ASAP_CONTRACT_BUILD_MODE_AUDIT_
# elif ASAP_CONTRACT_BUILD_ == ASAP_CONTRACT_BUILD_MODE_AUDIT_
# define ASAP_CONTRACT_MODE_DEFAULT_ ASAP_CONTRACT_CHECK_NEVER_CONTINUE_
# define ASAP_C_A_MODE_DEFAULT_ ASAP_C_A_CHECK_NEVER_CONTINUE_
# define ASAP_A_U_MODE_DEFAULT_ ASAP_A_U_CHECK_NEVER_CONTINUE_
Expand Down
2 changes: 0 additions & 2 deletions contract/test/contract_handlers_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include "contract/contract.h"

#include <sstream>

#include <gmock/gmock.h>
#include <gtest/gtest.h>

Expand Down
1 change: 1 addition & 0 deletions contract/test/contracts_audit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ void Unreachable(int value)
{
if (value == 5) {
value += 2;
(void)value;
}
ASAP_ASSERT_UNREACHABLE("")
}
Expand Down
1 change: 1 addition & 0 deletions contract/test/contracts_default_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ void Unreachable(int value)
{
if (value == 5) {
value += 2;
(void)value;
}
ASAP_ASSERT_UNREACHABLE("unreachable code")
}
1 change: 1 addition & 0 deletions contract/test/contracts_off_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void Unreachable(int value)
{
if (value == 5) {
value += 2;
(void)value;
} else {
ASAP_ASSERT_UNREACHABLE()
}
Expand Down

0 comments on commit e123836

Please sign in to comment.