From e317436e8dd02eb7e0f000a25181c9b5870b9a98 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 19 Jan 2025 12:40:28 -0800 Subject: [PATCH] static analyzer lint for glyphs.c --- src/glyphs.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/glyphs.c b/src/glyphs.c index d95764060..8b6a77854 100644 --- a/src/glyphs.c +++ b/src/glyphs.c @@ -121,6 +121,7 @@ glyphrep_to_custom_map_entries( if (!glyphid_cache) reslt = 1; /* for debugger use only; no cache available */ + nhUse(reslt); Snprintf(buf, sizeof buf, "%s", op); c_unicode = c_colorval = (char *) 0; @@ -470,6 +471,7 @@ glyphrep(const char *op) if (!glyphid_cache) reslt = 1; /* for debugger use only; no cache available */ + nhUse(reslt); reslt = glyphrep_to_custom_map_entries(op, &glyph); if (reslt) return 1; @@ -908,30 +910,26 @@ parse_id( } else if (glyph_is_body(glyph)) { /* buf2 will hold the distinguishing prefix */ /* buf3 will hold the base name */ - buf2 = ""; /* superfluous */ + buf2 = glyph_is_body_piletop(glyph) + ? "piletop_body_" + : "body_"; buf3 = monsdump[glyph_to_body_corpsenm(glyph)].nm; - if (glyph_is_body_piletop(glyph)) { - buf2 = "piletop_body_"; - } else { - buf2 = "body_"; - } Strcpy(buf[0], "G_"); Strcat(buf[0], buf2); Strcat(buf[0], buf3); } else if (glyph_is_statue(glyph)) { /* buf2 will hold the distinguishing prefix */ /* buf3 will hold the base name */ - buf2 = ""; + buf2 = glyph_is_fem_statue_piletop(glyph) + ? "piletop_statue_of_female_" + : glyph_is_fem_statue(glyph) + ? "statue_of_female_" + : glyph_is_male_statue_piletop(glyph) + ? "piletop_statue_of_male_" + : glyph_is_male_statue(glyph) + ? "statue_of_male_" + : ""; /* shouldn't happen */ buf3 = monsdump[glyph_to_statue_corpsenm(glyph)].nm; - if (glyph_is_fem_statue_piletop(glyph)) { - buf2 = "piletop_statue_of_female_"; - } else if (glyph_is_fem_statue(glyph)) { - buf2 = "statue_of_female_"; - } else if (glyph_is_male_statue_piletop(glyph)) { - buf2 = "piletop_statue_of_male_"; - } else if (glyph_is_male_statue(glyph)) { - buf2 = "statue_of_male_"; - } Strcpy(buf[0], "G_"); Strcat(buf[0], buf2); Strcat(buf[0], buf3); @@ -939,8 +937,6 @@ parse_id( i = glyph_to_obj(glyph); /* buf2 will hold the distinguishing prefix */ /* buf3 will hold the base name */ - buf2 = ""; - buf3 = ""; if (((i > SCR_STINKING_CLOUD) && (i < SCR_MAIL)) || ((i > WAN_LIGHTNING) && (i < GOLD_PIECE))) skip_this_one = TRUE; @@ -960,6 +956,8 @@ parse_id( buf2 = "ring of "; else if (i == LAND_MINE) buf2 = "unset "; + else + buf2 = ""; buf3 = (i == SCR_BLANK_PAPER) ? "blank scroll" : (i == SPE_BLANK_PAPER) ? "blank spellbook" : (i == SLIME_MOLD) ? "slime mold" @@ -1049,7 +1047,6 @@ parse_id( j = glyph - GLYPH_SWALLOW_OFF; cmap = glyph_to_swallow(glyph); mnum = j / ((S_sw_br - S_sw_tl) + 1); - i = cmap - S_sw_tl; Strcpy(buf[3], "swallow "); Strcat(buf[3], monsdump[mnum].nm); Strcat(buf[3], " ");