diff --git a/c/cardano/cardano_lock_inc.h b/c/cardano/cardano_lock_inc.h index 218189b..5ca06ad 100644 --- a/c/cardano/cardano_lock_inc.h +++ b/c/cardano/cardano_lock_inc.h @@ -3,24 +3,27 @@ #include "blake2b.h" #include "nanocbor.h" +#undef CHECK2 #undef CHECK -#define CHECK(code) \ - do { \ - if (code != 0) { \ - err = code; \ - goto exit; \ - } \ - } while (0) - -#ifndef CHECK2 + +#define CHECK(_code) \ + do { \ + int code = (_code); \ + if (code != 0) { \ + printf("error at %s:%d, error code %d", __FILE__, __LINE__, code); \ + err = code; \ + goto exit; \ + } \ + } while (0) + #define CHECK2(cond, code) \ - do { \ - if (!(cond)) { \ - err = code; \ - goto exit; \ - } \ - } while (0) -#endif // CHECK2 + do { \ + if (!(cond)) { \ + printf("error at %s:%d, error code %d", __FILE__, __LINE__, code); \ + err = code; \ + goto exit; \ + } \ + } while (0) #define CARDANO_LOCK_PUBKEY_SIZE 32 #define CARDANO_LOCK_SIGNATURE_SIZE 64 diff --git a/c/ckb_auth.h b/c/ckb_auth.h index 728aa1f..ceb2987 100644 --- a/c/ckb_auth.h +++ b/c/ckb_auth.h @@ -11,22 +11,24 @@ // secp256k1 also defines this macros #undef CHECK2 #undef CHECK -#define CHECK2(cond, code) \ - do { \ - if (!(cond)) { \ - printf("%s:%d, error code = %d", __FILE__, __LINE__, code); \ - err = code; \ - goto exit; \ - } \ + +#define CHECK(_code) \ + do { \ + int code = (_code); \ + if (code != 0) { \ + printf("error at %s:%d, error code %d", __FILE__, __LINE__, code); \ + err = code; \ + goto exit; \ + } \ } while (0) -#define CHECK(code) \ - do { \ - if (code != 0) { \ - printf("%s:%d, error code = %d", __FILE__, __LINE__, code); \ - err = code; \ - goto exit; \ - } \ +#define CHECK2(cond, code) \ + do { \ + if (!(cond)) { \ + printf("error at %s:%d, error code %d", __FILE__, __LINE__, code); \ + err = code; \ + goto exit; \ + } \ } while (0) #define CKB_AUTH_LEN 21 diff --git a/c/ripple.h b/c/ripple.h index 04f4b77..c284510 100644 --- a/c/ripple.h +++ b/c/ripple.h @@ -11,22 +11,24 @@ #undef CHECK2 #undef CHECK -#define CHECK2(cond, code) \ - do { \ - if (!(cond)) { \ - printf("%s:%d, error code = %d", __FILE__, __LINE__, code); \ - err = code; \ - goto exit; \ - } \ + +#define CHECK(_code) \ + do { \ + int code = (_code); \ + if (code != 0) { \ + printf("error at %s:%d, error code %d", __FILE__, __LINE__, code); \ + err = code; \ + goto exit; \ + } \ } while (0) -#define CHECK(code) \ - do { \ - if (code != 0) { \ - printf("%s:%d, error code = %d", __FILE__, __LINE__, code); \ - err = code; \ - goto exit; \ - } \ +#define CHECK2(cond, code) \ + do { \ + if (!(cond)) { \ + printf("error at %s:%d, error code %d", __FILE__, __LINE__, code); \ + err = code; \ + goto exit; \ + } \ } while (0) #define RIPPLE_SIGN_DATA_MAX_SIZE 72