diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-02-12 16:33:32 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2025-02-12 16:33:32 -0500 |
commit | 4e8732a2ad94982dcde175a6518da33021d2b6e8 (patch) | |
tree | 15007ccd3d06e41060b26f36fca3da24023f550e | |
parent | afecc407fd0d36061169ae64164703382656cafe (diff) | |
download | stasis-4e8732a2ad94982dcde175a6518da33021d2b6e8.tar.gz |
Encapsulate macro arguments in parentheses
-rw-r--r-- | src/cli/stasis_indexer/include/helpers.h | 4 | ||||
-rw-r--r-- | src/lib/core/include/conda.h | 2 | ||||
-rw-r--r-- | src/lib/core/include/core.h | 3 | ||||
-rw-r--r-- | src/lib/core/include/core_mem.h | 2 | ||||
-rw-r--r-- | tests/include/testing.h | 12 |
5 files changed, 11 insertions, 12 deletions
diff --git a/src/cli/stasis_indexer/include/helpers.h b/src/cli/stasis_indexer/include/helpers.h index d493f75..46705d2 100644 --- a/src/cli/stasis_indexer/include/helpers.h +++ b/src/cli/stasis_indexer/include/helpers.h @@ -5,12 +5,12 @@ #define ARRAY_COUNT_DYNAMIC(X, COUNTER) \ do { \ - for (COUNTER = 0; X && X[COUNTER] != NULL; COUNTER++) {} \ + for ((COUNTER) = 0; (X) && (X)[COUNTER] != NULL; (COUNTER)++) {} \ } while(0) #define ARRAY_COUNT_BY_STRUCT_MEMBER(X, MEMBER, COUNTER) \ do { \ - for (COUNTER = 0; X[COUNTER].MEMBER != NULL; COUNTER++) {} \ + for ((COUNTER) = 0; (X)[COUNTER].MEMBER != NULL; (COUNTER)++) {} \ } while(0) struct StrList *get_architectures(struct Delivery ctx[], size_t nelem); diff --git a/src/lib/core/include/conda.h b/src/lib/core/include/conda.h index b8d0caa..8b4a0bd 100644 --- a/src/lib/core/include/conda.h +++ b/src/lib/core/include/conda.h @@ -24,7 +24,7 @@ #define PKG_INDEX_PROVIDES_E_MANAGER_RUNTIME (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 3) #define PKG_INDEX_PROVIDES_E_MANAGER_SIGNALED (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 4) #define PKG_INDEX_PROVIDES_E_MANAGER_EXEC (PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET + 5) -#define PKG_INDEX_PROVIDES_FAILED(ECODE) (ECODE <= PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET) +#define PKG_INDEX_PROVIDES_FAILED(ECODE) ((ECODE) <= PKG_INDEX_PROVIDES_ERROR_MESSAGE_OFFSET) struct MicromambaInfo { char *micromamba_prefix; //!< Path to write micromamba binary diff --git a/src/lib/core/include/core.h b/src/lib/core/include/core.h index 362ac8d..f0586fa 100644 --- a/src/lib/core/include/core.h +++ b/src/lib/core/include/core.h @@ -26,7 +26,7 @@ #define COE_CHECK_ABORT(COND, MSG) \ do {\ - if (!globals.continue_on_error && COND) { \ + if (!globals.continue_on_error && (COND)) { \ msg(STASIS_MSG_ERROR, MSG ": Aborting execution (--continue-on-error/-C is not enabled)\n"); \ exit(1); \ } \ @@ -76,7 +76,6 @@ extern const char *VERSION; extern const char *AUTHOR; extern const char *BANNER; - /** * Free memory allocated in global configuration structure */ diff --git a/src/lib/core/include/core_mem.h b/src/lib/core/include/core_mem.h index bd50e9d..362715f 100644 --- a/src/lib/core/include/core_mem.h +++ b/src/lib/core/include/core_mem.h @@ -5,7 +5,7 @@ #include "environment.h" #include "strlist.h" -#define guard_runtime_free(X) do { if (X) { runtime_free(X); X = NULL; } } while (0) +#define guard_runtime_free(X) do { if (X) { runtime_free(X); (X) = NULL; } } while (0) #define guard_strlist_free(X) do { if ((*X)) { strlist_free(X); (*X) = NULL; } } while (0) #define guard_free(X) do { if (X) { free(X); X = NULL; } } while (0) #define GENERIC_ARRAY_FREE(ARR) do { \ diff --git a/tests/include/testing.h b/tests/include/testing.h index 4c97bf2..5ff847b 100644 --- a/tests/include/testing.h +++ b/tests/include/testing.h @@ -211,7 +211,7 @@ inline void stasis_testing_teardown_workspace() { .lineno = __LINE__, \ .status = (COND), \ .msg_assertion = "ASSERT(" #COND ")", \ - .msg_reason = REASON } ); \ + .msg_reason = (REASON) } ); \ } while (0) #define STASIS_ASSERT_FATAL(COND, REASON) do { \ @@ -221,7 +221,7 @@ inline void stasis_testing_teardown_workspace() { .lineno = __LINE__, \ .status = (COND), \ .msg_assertion = "ASSERT FATAL (" #COND ")", \ - .msg_reason = REASON } \ + .msg_reason = (REASON) } \ ); \ if (stasis_test_results[stasis_test_results_i ? stasis_test_results_i - 1 : stasis_test_results_i].status == false) {\ exit(STASIS_TEST_SUITE_FATAL); \ @@ -236,7 +236,7 @@ inline void stasis_testing_teardown_workspace() { .status = true, \ .skip = (COND), \ .msg_assertion = "SKIP (" #COND ")", \ - .msg_reason = REASON } \ + .msg_reason = (REASON) } \ ); \ if (stasis_test_results[stasis_test_results_i ? stasis_test_results_i - 1 : stasis_test_results_i].skip == true) {\ return; \ @@ -244,9 +244,9 @@ inline void stasis_testing_teardown_workspace() { } while (0) #define STASIS_TEST_RUN(X) do { \ - for (size_t i = 0; i < sizeof(X) / sizeof(*X); i++) { \ - if (X[i]) { \ - X[i](); \ + for (size_t i = 0; i < sizeof(X) / sizeof(*(X)); i++) { \ + if ((X)[i]) { \ + (X)[i](); \ } \ } \ } while (0) |