vtfontcvt: Avoid dead store in add_char

The fallback glyph is stored at index 0, and does not need to be
inserted into a mapping.

Previously there was a dead store of add_glyph's return value for the
fallback case, which upset Clang's static analyzer.  Now, cast the
return value to (void) to make it clear this is intentional.

Also change add_glyph's fallback parameter to a c99 bool to make its use
more clear.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57174
This commit is contained in:
Ed Maste committed 2026-07-20 16:46:50 -04:00
1 parent 6dbeaf1afa
commit b273481f2a
1 file changed
+4 -4
+4 -4
View File
@@ -254,7 +254,7 @@ dedup_mapping(unsigned int map_idx)
}
static struct glyph *
add_glyph(const uint8_t *bytes, unsigned int map_idx, int fallback)
add_glyph(const uint8_t *bytes, unsigned int map_idx, bool fallback)
{
struct glyph *gl;
int hash;
@@ -321,13 +321,13 @@ add_char(unsigned curchar, unsigned map_idx, uint8_t *bytes, uint8_t *bytes_r)
/* Prevent adding two glyphs for 0xFFFD */
if (curchar == 0xFFFD) {
if (map_idx < VFNT_MAP_BOLD)
gl = add_glyph(bytes, 0, 1);
(void)add_glyph(bytes, 0, true);
} else if (filter == false || curchar >= 0x20) {
gl = add_glyph(bytes, map_idx, 0);
gl = add_glyph(bytes, map_idx, false);
if (add_mapping(gl, curchar, map_idx) != 0)
return (1);
if (bytes_r != NULL) {
gl = add_glyph(bytes_r, map_idx + 1, 0);
gl = add_glyph(bytes_r, map_idx + 1, false);
if (add_mapping(gl, curchar, map_idx + 1) != 0)
return (1);
}