]> granicus.if.org Git - nethack/commitdiff
warning bit
authorPatR <rankin@nethack.org>
Fri, 18 Dec 2015 15:18:58 +0000 (07:18 -0800)
committerPatR <rankin@nethack.org>
Fri, 18 Dec 2015 15:18:58 +0000 (07:18 -0800)
Suppress a couple of 'dead increment' diagnostics from the clang static
analyzer.  The assignments are dead, but keeping the variable up to date
is more valuable (in case someone someday changes the code to use the
affected variable somewhere farther along in that function) than changing
the code to avoid the assignments in order to prevent the diagnostic.

This will only work to suppress the analyzer's diagnostic messages if
either FORCE_ARG_USAGE or GCC_WARN is defined when compiling makemon.c.

src/makemon.c

index 102379e4aa08a5e2a101f40ee9b8feeaf6132f6b..55cf66fabbc4fda92f2953a1a1802f494c70a34d 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 makemon.c       $NHDT-Date: 1449269917 2015/12/04 22:58:37 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.105 $ */
+/* NetHack 3.6 makemon.c       $NHDT-Date: 1450451931 2015/12/18 15:18:51 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.106 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -599,6 +599,8 @@ register struct monst *mtmp;
             else if (mac < 10 && rn2(2))
                 mac += 1 + mongets(mtmp, LEATHER_CLOAK);
 
+            nhUse(mac); /* suppress 'dead increment' from static analyzer */
+
             if (ptr != &mons[PM_GUARD] && ptr != &mons[PM_WATCHMAN]
                 && ptr != &mons[PM_WATCH_CAPTAIN]) {
                 if (!rn2(3))