From: PatR Date: Sun, 25 Nov 2018 22:31:20 +0000 (-0800) Subject: warning fixups X-Git-Tag: nmake-explicit-path~145^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5226de8c7407e979f11f42e638297a1828506af1;p=nethack warning fixups Non-const string literals. --- diff --git a/include/extern.h b/include/extern.h index ccd54c605..e4c2f82fe 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1542798602 2018/11/21 11:10:02 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.650 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1543185068 2018/11/25 22:31:08 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.663 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -431,7 +431,8 @@ E struct obj *FDECL(realloc_obj, (struct obj *, int, genericptr_t, int, const char *)); E char *FDECL(coyotename, (struct monst *, char *)); E char *FDECL(rndorcname, (char *)); -E struct monst *FDECL(christen_orc, (struct monst *, char *, char *)); +E struct monst *FDECL(christen_orc, (struct monst *, const char *, + const char *)); E const char *FDECL(noveltitle, (int *)); E const char *FDECL(lookup_novel, (const char *, int *)); diff --git a/src/do_name.c b/src/do_name.c index e2e249b93..88735f6e1 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1,4 +1,4 @@ -/* 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 $ */ +/* NetHack 3.6 do_name.c $NHDT-Date: 1543185069 2018/11/25 22:31:09 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.136 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2090,19 +2090,21 @@ char *s; struct monst * christen_orc(mtmp, gang, other) struct monst *mtmp; -char *gang, *other; +const char *gang, *other; { int sz = 0; char buf[BUFSZ], buf2[BUFSZ], *orcname; orcname = rndorcname(buf2); sz = (int) ((gang ? strlen(gang) : other ? strlen(other) : 0) - + strlen(orcname) + sizeof " of " - sizeof ""); + + strlen(orcname) + sizeof " of " - sizeof ""); if (sz < BUFSZ) { + char gbuf[BUFSZ]; boolean nameit = FALSE; if (gang && orcname) { - Sprintf(buf, "%s of %s", upstart(orcname), upstart(gang)); + Sprintf(buf, "%s of %s", upstart(orcname), + upstart(strcpy(gbuf, gang))); nameit = TRUE; } else if (other && orcname) { Sprintf(buf, "%s%s", upstart(orcname), other); diff --git a/src/dokick.c b/src/dokick.c index 3274b15e9..68eb49c24 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dokick.c $NHDT-Date: 1541842623 2018/11/10 09:37:03 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.122 $ */ +/* NetHack 3.6 dokick.c $NHDT-Date: 1543185070 2018/11/25 22:31:10 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.128 $ */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1704,10 +1704,12 @@ unsigned long deliverflags; /* special treatment for orcs and their kind */ if ((otmp->corpsenm & M2_ORC) != 0 && has_oname(otmp)) { if (!has_mname(mtmp)) { - if (at_crime_scene || (!at_crime_scene && !rn2(2))) + if (at_crime_scene || !rn2(2)) mtmp = christen_orc(mtmp, - at_crime_scene ? ONAME(otmp) : (char *) 0, - " the Fence"); /* bought the stolen goods */ + at_crime_scene ? ONAME(otmp) + : (char *) 0, + /* bought the stolen goods */ + " the Fence"); } free_oname(otmp); } diff --git a/src/mkmaze.c b/src/mkmaze.c index 1dd52cb98..863502baf 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1,4 +1,4 @@ -/* 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 $ */ +/* NetHack 3.6 mkmaze.c $NHDT-Date: 1543185071 2018/11/25 22:31:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.67 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -705,9 +705,10 @@ int otyp; const char *gang; { struct obj *otmp; + otmp = mksobj_migr_to_species(otyp, (unsigned long) M2_ORC, FALSE, FALSE); if (otmp && gang) { - new_oname(otmp, strlen(gang) + 1); /* removes old name if one is present */ + new_oname(otmp, strlen(gang) + 1); /* removes old name if present */ Strcpy(ONAME(otmp), gang); if (otyp >= TRIPE_RATION && otyp <= TIN) { if (otyp == SLIME_MOLD) diff --git a/src/pager.c b/src/pager.c index 894d3e7d5..27d274adc 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,4 +1,4 @@ -/* 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 $ */ +/* NetHack 3.6 pager.c $NHDT-Date: 1543185072 2018/11/25 22:31:12 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.139 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1397,7 +1397,7 @@ boolean without_asking; } if (yes_to_moreinfo) { int i, subs = 0; - char *gang = (char *) 0; + const char *gang = (char *) 0; if (bp) { textp = suptext1;