Skip to content

Commit

Permalink
[tx] wrapped new macros in do...while(0) per feedback from @blueshade7
Browse files Browse the repository at this point in the history
(I used braces in one file and not the other to match the style of other macros in those files.)
  • Loading branch information
cjchapman committed Aug 15, 2019
1 parent 3ddfb41 commit 2f0f7ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 9 additions & 6 deletions c/public/lib/api/tx_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,18 @@ struct txCtx_ {
} while (0)

/* Check that current charstring has enough bytes left. */
#define CHECK_CHARSTRING_BYTES_LEFT(n) \
if (n > left) \
fatal(h, "charstring too short"); \
#define CHECK_CHARSTRING_BYTES_LEFT(n) \
do { \
if (n > left) \
fatal(h, "charstring too short"); \
} while (0)

/* Check that current dict has enough bytes left. */
#define CHECK_DICT_BYTES_LEFT(n) \
if (n > left) \
fatal(h, "dict too short"); \

do { \
if (n > left) \
fatal(h, "dict too short"); \
} while (0)

/* Stack access without check. */
#define INDEX(i) (h->stack.array[i])
Expand Down
8 changes: 5 additions & 3 deletions c/public/lib/source/cffread/cffread.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,11 @@ static void srcOpen(cfrCtx h, long flags, long origin, int ttcIndex) {
while (0)

/* Check that dict has enough bytes left. */
#define CHECK_DICT_BYTES_LEFT(n) \
if ((srcTell(h) + n) > region->end) \
fatal(h, cfrErrSrcStream); \
#define CHECK_DICT_BYTES_LEFT(n) \
do \
if ((srcTell(h) + n) > region->end) \
fatal(h, cfrErrSrcStream); \
while (0)

/* Stack access without check. */
#define INDEX(i) (h->stack.array[i])
Expand Down

0 comments on commit 2f0f7ca

Please sign in to comment.