CI_GET_*_INFO_*: add do ... while (0) to avoid -Wextra-semi-stmt warnings

Clears 24 warnings from clang of the form:

TextExt16.c:63:34: warning: empty expression statement has no effect;
 remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
        CI_GET_DEFAULT_INFO_1D (fs, def);
                                        ^

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
This commit is contained in:
Alan Coopersmith 2024-11-10 13:16:41 -08:00
parent 6891228821
commit a53c45d69e
5 changed files with 16 additions and 16 deletions

View file

@ -717,7 +717,7 @@ extern void _XRead32(
* char. * char.
*/ */
#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \ #define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
{ \ do { \
cs = def; \ cs = def; \
if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
if (fs->per_char == NULL) { \ if (fs->per_char == NULL) { \
@ -727,7 +727,7 @@ extern void _XRead32(
if (CI_NONEXISTCHAR(cs)) cs = def; \ if (CI_NONEXISTCHAR(cs)) cs = def; \
} \ } \
} \ } \
} } while (0)
#define CI_GET_DEFAULT_INFO_1D(fs,cs) \ #define CI_GET_DEFAULT_INFO_1D(fs,cs) \
CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs) CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
@ -739,7 +739,7 @@ extern void _XRead32(
* column. This is used for fonts that have more than row zero. * column. This is used for fonts that have more than row zero.
*/ */
#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \ #define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
{ \ do { \
cs = def; \ cs = def; \
if (row >= fs->min_byte1 && row <= fs->max_byte1 && \ if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
@ -753,14 +753,14 @@ extern void _XRead32(
if (CI_NONEXISTCHAR(cs)) cs = def; \ if (CI_NONEXISTCHAR(cs)) cs = def; \
} \ } \
} \ } \
} } while (0)
#define CI_GET_DEFAULT_INFO_2D(fs,cs) \ #define CI_GET_DEFAULT_INFO_2D(fs,cs) \
{ \ do { \
unsigned int r = (fs->default_char >> 8); \ unsigned int r = (fs->default_char >> 8); \
unsigned int c = (fs->default_char & 0xff); \ unsigned int c = (fs->default_char & 0xff); \
CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \ CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
} } while (0)
/* srcvar must be a variable for large architecture version */ /* srcvar must be a variable for large architecture version */

View file

@ -231,10 +231,10 @@ _XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
bzero((char *) &overall, sizeof(XCharStruct)); bzero((char *) &overall, sizeof(XCharStruct));
*num_chars = 0; *num_chars = 0;
CI_GET_DEFAULT_INFO_1D(font, def) CI_GET_DEFAULT_INFO_1D(font, def);
while (length-- > 0) { while (length-- > 0) {
CI_GET_CHAR_INFO_1D(font, *text, def, cs) CI_GET_CHAR_INFO_1D(font, *text, def, cs);
text++; text++;
if (cs == NULL) if (cs == NULL)
continue; continue;

View file

@ -92,20 +92,20 @@ _XomGenericTextPerCharExtents(
} }
if (is_xchar2b) { if (is_xchar2b) {
CI_GET_DEFAULT_INFO_2D(font, def) CI_GET_DEFAULT_INFO_2D(font, def);
xchar2b_ptr = xchar2b_buf; xchar2b_ptr = xchar2b_buf;
} else { } else {
CI_GET_DEFAULT_INFO_1D(font, def) CI_GET_DEFAULT_INFO_1D(font, def);
xchar_ptr = (char *) xchar2b_buf; xchar_ptr = (char *) xchar2b_buf;
} }
while (buf_len-- > 0) { while (buf_len-- > 0) {
if (is_xchar2b) { if (is_xchar2b) {
CI_GET_CHAR_INFO_2D(font, xchar2b_ptr->byte1, CI_GET_CHAR_INFO_2D(font, xchar2b_ptr->byte1,
xchar2b_ptr->byte2, def, cs) xchar2b_ptr->byte2, def, cs);
xchar2b_ptr++; xchar2b_ptr++;
} else { } else {
CI_GET_CHAR_INFO_1D(font, *xchar_ptr, def, cs) CI_GET_CHAR_INFO_1D(font, *xchar_ptr, def, cs);
xchar_ptr++; xchar_ptr++;
} }
if (cs == NULL) if (cs == NULL)

View file

@ -50,7 +50,7 @@ from The Open Group.
*/ */
#define CI_GET_ROWZERO_CHAR_INFO_2D(fs,col,def,cs) \ #define CI_GET_ROWZERO_CHAR_INFO_2D(fs,col,def,cs) \
{ \ do { \
cs = def; \ cs = def; \
if (fs->min_byte1 == 0 && \ if (fs->min_byte1 == 0 && \
col >= fs->min_byte2 && col <= fs->max_byte2) { \ col >= fs->min_byte2 && col <= fs->max_byte2) { \
@ -61,7 +61,7 @@ from The Open Group.
if (CI_NONEXISTCHAR(cs)) cs = def; \ if (CI_NONEXISTCHAR(cs)) cs = def; \
} \ } \
} \ } \
} } while (0)
/* /*

View file

@ -693,10 +693,10 @@ _XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
bzero((char *) &overall, sizeof(XCharStruct)); bzero((char *) &overall, sizeof(XCharStruct));
*num_chars = 0; *num_chars = 0;
CI_GET_DEFAULT_INFO_1D(font, def) CI_GET_DEFAULT_INFO_1D(font, def);
while (length-- > 0) { while (length-- > 0) {
CI_GET_CHAR_INFO_1D(font, *text, def, cs) CI_GET_CHAR_INFO_1D(font, *text, def, cs);
text++; text++;
if (cs == NULL) if (cs == NULL)
continue; continue;