From: PatR Date: Thu, 20 Sep 2018 21:06:17 +0000 (-0700) Subject: build bits X-Git-Tag: NetHack-3.6.2_Released~197^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=792eb64af5b86ede4f8945dd6e4775f398001b18;p=nethack build bits Eliminate a few warnings: array name used as boolean is always true, parameter 'flags' shadows (blocks access to) global struct 'flags', initializer discards 'const' (assigning string literal to 'char *'). Plus a couple of simplifications. --- diff --git a/src/do_name.c b/src/do_name.c index ef1870742..4c7653776 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 do_name.c $NHDT-Date: 1519420054 2018/02/23 21:07:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.128 $ */ +/* NetHack 3.6 do_name.c $NHDT-Date: 1537477563 2018/09/20 21:06:03 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.132 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1700,10 +1700,7 @@ boolean called; if (do_saddle && (mtmp->misc_worn_check & W_SADDLE) && !Blind && !Hallucination) Strcat(buf, "saddled "); - if (buf[0] != 0) - has_adjectives = TRUE; - else - has_adjectives = FALSE; + has_adjectives = (buf[0] != '\0'); /* Put the actual monster name or type into the buffer now */ /* Be sure to remember whether the buffer starts with a name */ @@ -2096,14 +2093,13 @@ christen_orc(mtmp, gang) struct monst *mtmp; char *gang; { - size_t sz = 0; + int sz = 0; char buf[BUFSZ], buf2[BUFSZ], *orcname; orcname = rndorcname(buf2); - sz = strlen(gang) + strlen(orcname) + strlen(" of "); - if (buf && gang && orcname && (sz < (BUFSZ - 1))) { - Sprintf(buf, "%s of %s", - upstart(orcname), upstart(gang)); + sz = (int) (strlen(gang) + strlen(orcname) + sizeof " of " - sizeof ""); + if (gang && orcname && sz < BUFSZ) { + Sprintf(buf, "%s of %s", upstart(orcname), upstart(gang)); mtmp = christen_monst(mtmp, buf); } return mtmp; diff --git a/src/mkmaze.c b/src/mkmaze.c index 539f380e0..8282205f8 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkmaze.c $NHDT-Date: 1518718417 2018/02/15 18:13:37 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.55 $ */ +/* NetHack 3.6 mkmaze.c $NHDT-Date: 1537477570 2018/09/20 21:06:10 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.61 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -628,20 +628,15 @@ check_ransacked(s) char *s; { /* this kludge only works as long as orctown is minetn-1 */ - if (dungeons[u.uz.dnum].dname - && !strcmp(dungeons[u.uz.dnum].dname, "The Gnomish Mines") - && !strcmp(s, "minetn-1")) - ransacked = 1; - else - ransacked = 0; + ransacked = (u.uz.dnum == mines_dnum && !strcmp(s, "minetn-1")); } #define ORC_LEADER 1 void -migrate_orc(mtmp, flags) +migrate_orc(mtmp, mflags) struct monst *mtmp; -unsigned long flags; +unsigned long mflags; { int nlev, max_depth, cur_depth; d_level dest; @@ -649,7 +644,7 @@ unsigned long flags; cur_depth = (int) depth(&u.uz); max_depth = dunlevs_in_dungeon(&u.uz) + (dungeons[u.uz.dnum].depth_start - 1); - if (flags == ORC_LEADER) { + if (mflags == ORC_LEADER) { /* Note that the orc leader will take possession of any * remaining stuff not already delivered to other * orcs between here and the bottom of the mines. diff --git a/src/pager.c b/src/pager.c index 6ef7bf6ce..d3163750c 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pager.c $NHDT-Date: 1523142395 2018/04/07 23:06:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.123 $ */ +/* NetHack 3.6 pager.c $NHDT-Date: 1537477571 2018/09/20 21:06:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.129 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1229,7 +1229,7 @@ coord *click_cc; Strcpy(temp_buf, firstmatch); checkfile(temp_buf, pm, FALSE, (boolean) (ans == LOOK_VERBOSE), supplemental_name); - if (supplemental_pm && supplemental_name) + if (supplemental_pm) do_supplemental_info(supplemental_name, supplemental_pm, (boolean) (ans == LOOK_VERBOSE)); } @@ -1364,19 +1364,20 @@ boolean without_asking; if (yes_to_moreinfo) { int i, subs = 0; char *gang = bp + 4; - char *text[] = { - "%s is a member of a marauding horde of orcs", - "rumored to have brutally attacked and plundered the ordinarily", - "sheltered town that is located deep within The Gnomish Mines.", - "", - "The members of that vicious horde proudly and defiantly acclaim their", - "allegiance to their leader %s in their names.", + static const char *text[] = { + "%s is a member of a marauding horde of orcs", + "rumored to have brutally attacked and plundered the ordinarily", + "sheltered town that is located deep within The Gnomish Mines.", + "", + "The members of that vicious horde proudly and defiantly acclaim", + "their allegiance to their leader %s in their names.", }; *bp = '\0'; datawin = create_nhwindow(NHW_MENU); for (i = 0; i < SIZE(text); i++) { - char buf[BUFSZ], *txt; + char buf[BUFSZ]; + const char *txt; if (strstri(text[i], "%s") != 0) { Sprintf(buf, text[i],