git: b273481f2a84 - main - vtfontcvt: Avoid dead store in add_char
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 20 Jul 2026 20:47:41 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=b273481f2a840a05e4039655be99528e1fa9388c
commit b273481f2a840a05e4039655be99528e1fa9388c
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-05-22 18:08:58 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-07-20 20:46:50 +0000
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
---
usr.bin/vtfontcvt/vtfontcvt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/usr.bin/vtfontcvt/vtfontcvt.c b/usr.bin/vtfontcvt/vtfontcvt.c
index f39076b09be6..29294f589fb5 100644
--- a/usr.bin/vtfontcvt/vtfontcvt.c
+++ b/usr.bin/vtfontcvt/vtfontcvt.c
@@ -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);
}