Statement macros should be wrapped in do{}while(0)

Description

Certain statement macros like U16_APPEND et al are defined to expand to the form "{ ... }". They should instead expand to the common C idiom of "do { ... } while (0)", such that a semi-colon after them is not deemed redundant by the compiler and they'd work fine in an if-else block. Right now at HarfBuzz we are getting these error from compiler:

hb-icu.cc:261:39: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt]
U16_GET_UNSAFE (normalized, 0, *a);
^
hb-icu.cc:266:42: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt]
U16_NEXT_UNSAFE (normalized, len, *a);
^
hb-icu.cc:267:42: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt]
U16_NEXT_UNSAFE (normalized, len, *b);
^

Status

Assignee

Fredrik Roubert

Reporter

Behdad Esfahbod

Labels

None

Reviewer

Markus Scherer

Time Needed

Hours

Start date

None

Components

Fix versions

Priority

minor