From c33068fef96835a03f27e23f4ccff04f8171b75b Mon Sep 17 00:00:00 2001 From: marktwtn Date: Fri, 3 Jan 2020 15:16:28 +0800 Subject: [PATCH] fix: Add brackets to avoid unexpected macro behavior --- docs/naming-convention.md | 2 +- src/constants.h | 2 +- src/pow_avx.h | 2 +- src/pow_c.h | 2 +- src/pow_sse.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/naming-convention.md b/docs/naming-convention.md index b3e6b30..ac59096 100644 --- a/docs/naming-convention.md +++ b/docs/naming-convention.md @@ -21,7 +21,7 @@ dcurl uses the **[snake case](https://en.wikipedia.org/wiki/Snake_case)** naming - Macro: Use capital letters ``` - #define MIN_TRYTE_VALUE -13 + #define MIN_TRYTE_VALUE (-13) #define MAX_TRYTE_VALUE 13 ``` diff --git a/src/constants.h b/src/constants.h index a0fa32d..3e12130 100644 --- a/src/constants.h +++ b/src/constants.h @@ -9,7 +9,7 @@ #ifndef CONSTANTS_H_ #define CONSTANTS_H_ -#define MIN_TRYTE_VALUE -13 +#define MIN_TRYTE_VALUE (-13) #define MAX_TRYTE_VALUE 13 #define SIGNATURE_SIZE 6561 #define DEPTH 3 diff --git a/src/pow_avx.h b/src/pow_avx.h index 346aca0..a654331 100644 --- a/src/pow_avx.h +++ b/src/pow_avx.h @@ -49,7 +49,7 @@ struct pow_avx_context_s { #include #endif -#define INCR_START HASH_TRITS_LENGTH - NONCE_TRITS_LENGTH + 4 + 27 +#define INCR_START (HASH_TRITS_LENGTH - NONCE_TRITS_LENGTH + 4 + 27) #ifdef __AVX2__ #define HBITS 0xFFFFFFFFFFFFFFFFuLL diff --git a/src/pow_c.h b/src/pow_c.h index a99e798..0851dfb 100644 --- a/src/pow_c.h +++ b/src/pow_c.h @@ -54,7 +54,7 @@ struct pow_c_context_s { #define HBITS 0xFFFFFFFFFFFFFFFFuLL #define LBITS 0x0000000000000000uLL -#define INCR_START HASH_TRITS_LENGTH - NONCE_TRITS_LENGTH + 4 + 27 +#define INCR_START (HASH_TRITS_LENGTH - NONCE_TRITS_LENGTH + 4 + 27) #define LOW0 \ 0xDB6DB6DB6DB6DB6DuLL // 0b1101101101101101101101101101101101101101101101101101101101101101L; #define HIGH0 \ diff --git a/src/pow_sse.h b/src/pow_sse.h index c08f5ad..088dce3 100644 --- a/src/pow_sse.h +++ b/src/pow_sse.h @@ -59,7 +59,7 @@ struct pow_sse_context_s { #define HBITS 0xFFFFFFFFFFFFFFFFuLL #define LBITS 0x0000000000000000uLL -#define INCR_START HASH_TRITS_LENGTH - NONCE_TRITS_LENGTH + 4 + 27 +#define INCR_START (HASH_TRITS_LENGTH - NONCE_TRITS_LENGTH + 4 + 27) #define LOW00 \ 0xDB6DB6DB6DB6DB6DuLL // 0b1101101101101101101101101101101101101101101101101101101101101101L; #define HIGH00 \