Simplify code a bit

This commit is contained in:
Kovid Goyal 2020-07-07 09:44:51 +05:30
parent b81700144d
commit ee47a10b37
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 2 deletions

3
glfw/xkb_glfw.c vendored
View File

@ -508,7 +508,8 @@ format_xkb_mods(_GLFWXKBData *xkb, const char* name, xkb_mod_mask_t mods) {
char *p = buf, *s;
#define pr(x) { \
int num_needed = -1; \
if (sizeof(buf) > (unsigned long)((p - buf) + 1)) num_needed = snprintf(p, sizeof(buf) - (p - buf) - 1, "%s", x); \
ssize_t space_left = sizeof(buf) - (p - buf) - 1; \
if (space_left > 0) num_needed = snprintf(p, space_left, "%s", x); \
if (num_needed > 0) p += num_needed; \
}
pr(name); pr(": ");

View File

@ -497,7 +497,7 @@ static inline bool
render_color_bitmap(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned int cell_width, unsigned int cell_height, unsigned int num_cells, unsigned int baseline) {
(void)baseline;
unsigned short best = 0, diff = USHRT_MAX;
for (short i = 0; i < (unsigned short)self->face->num_fixed_sizes; i++) {
for (short i = 0; i < (short)self->face->num_fixed_sizes; i++) {
unsigned short w = self->face->available_sizes[i].width;
unsigned short d = w > (unsigned short)cell_width ? w - (unsigned short)cell_width : (unsigned short)cell_width - w;
if (d < diff) {