Skip to content

Commit

Permalink
Fix CHECK macro
Browse files Browse the repository at this point in the history
  • Loading branch information
XuJiandong committed Apr 24, 2024
1 parent 4253ba8 commit e7f642a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 44 deletions.
35 changes: 19 additions & 16 deletions c/cardano/cardano_lock_inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 16 additions & 14 deletions c/ckb_auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 16 additions & 14 deletions c/ripple.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7f642a

Please sign in to comment.