Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/caesar caesar: WARNS=6, strict bool mode



details:   https://anonhg.NetBSD.org/src/rev/5b473cc48f0a
branches:  trunk
changeset: 983070:5b473cc48f0a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat May 01 20:21:25 2021 +0000

description:
caesar: WARNS=6, strict bool mode

The rotation is validated to be nonnegative, therefore use unsigned int
for it.

diffstat:

 games/caesar/Makefile |   5 ++++-
 games/caesar/caesar.c |  12 ++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diffs (71 lines):

diff -r 658942f53b66 -r 5b473cc48f0a games/caesar/Makefile
--- a/games/caesar/Makefile     Sat May 01 18:07:52 2021 +0000
+++ b/games/caesar/Makefile     Sat May 01 20:21:25 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.8 2008/01/28 07:03:59 dholland Exp $
+#      $NetBSD: Makefile,v 1.9 2021/05/01 20:21:25 rillig Exp $
 #      @(#)Makefile    8.1 (Berkeley) 5/31/93
 
 PROG=  caesar
@@ -8,4 +8,7 @@
 MLINKS=        caesar.6 rot13.6
 SCRIPTS=rot13.sh
 
+WARNS=         6
+LINTFLAGS+=    -T
+
 .include <bsd.prog.mk>
diff -r 658942f53b66 -r 5b473cc48f0a games/caesar/caesar.c
--- a/games/caesar/caesar.c     Sat May 01 18:07:52 2021 +0000
+++ b/games/caesar/caesar.c     Sat May 01 20:21:25 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: caesar.c,v 1.22 2008/07/20 01:03:21 lukem Exp $        */
+/*     $NetBSD: caesar.c,v 1.23 2021/05/01 20:21:25 rillig Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -48,7 +48,7 @@
 #if 0
 static char sccsid[] = "@(#)caesar.c   8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: caesar.c,v 1.22 2008/07/20 01:03:21 lukem Exp $");
+__RCSID("$NetBSD: caesar.c,v 1.23 2021/05/01 20:21:25 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -79,7 +79,7 @@
 
 
 static void
-init_rottbl(int rot)
+init_rottbl(unsigned int rot)
 {
        size_t i;
 
@@ -121,7 +121,7 @@
        }
 }
 
-static int
+static unsigned int
 get_rotation(const char *arg)
 {
        long rot;
@@ -135,7 +135,7 @@
                errno = ERANGE;
        if (errno)
                err(EXIT_FAILURE, "Bad rotation value `%s'", arg);
-       return (int)rot;
+       return (unsigned int)rot;
 }
 
 static void
@@ -145,7 +145,7 @@
        unsigned int obs[NCHARS];
        size_t i, nread;
        double dot, winnerdot;
-       int try, winner;
+       unsigned int try, winner;
        int ch;
 
        /* adjust frequency table to weight low probs REAL low */



Home | Main Index | Thread Index | Old Index