Author: eadler
Date: Wed Apr 24 12:47:30 2013
New Revision: 249840
URL: http://svnweb.freebsd.org/changeset/base/249840

Log:
  MFC r227101:
        Add static keywords to variables and functions where possible in games/.
  
        This allows us to detect unused functions and variables and allows the
        compiler to do a better job at optimisation.

Modified:
  stable/9/games/bcd/bcd.c
  stable/9/games/grdc/grdc.c
  stable/9/games/morse/morse.c
  stable/9/games/number/number.c
Directory Properties:
  stable/9/games/bcd/   (props changed)
  stable/9/games/grdc/   (props changed)
  stable/9/games/morse/   (props changed)
  stable/9/games/number/   (props changed)

Modified: stable/9/games/bcd/bcd.c
==============================================================================
--- stable/9/games/bcd/bcd.c    Wed Apr 24 12:36:37 2013        (r249839)
+++ stable/9/games/bcd/bcd.c    Wed Apr 24 12:47:30 2013        (r249840)
@@ -82,7 +82,7 @@ static const char rcsid[] =
 #include <string.h>
 #include <unistd.h>
 
-u_short holes[256] = {
+static u_short holes[256] = {
     0x0,        0x0,     0x0,     0x0,     0x0,     0x0,     0x0,     0x0,
     0x0,        0x0,     0x0,     0x0,     0x0,     0x0,     0x0,     0x0,
     0x0,        0x0,     0x0,     0x0,     0x0,     0x0,     0x0,     0x0,
@@ -117,7 +117,7 @@ u_short holes[256] = {
     0x202,      0x201,   0x082,   0x806,   0x822,   0x600,   0x282,   0x0
 };
 
-void printcard(char *);
+static void printcard(char *);
 
 /*
  * i'th bit of w.
@@ -145,7 +145,7 @@ main(int argc, char **argv)
 
 #define        COLUMNS 48
 
-void
+static void
 printcard(char *str)
 {
        static char rowchars[] = "   123456789";

Modified: stable/9/games/grdc/grdc.c
==============================================================================
--- stable/9/games/grdc/grdc.c  Wed Apr 24 12:36:37 2013        (r249839)
+++ stable/9/games/grdc/grdc.c  Wed Apr 24 12:47:30 2013        (r249840)
@@ -26,29 +26,30 @@
 #define XLENGTH 58
 #define YDEPTH  7
 
-struct timespec now;
-struct tm *tm;
+static struct timespec now;
+static struct tm *tm;
 
-short disp[11] = {
+static short disp[11] = {
        075557, 011111, 071747, 071717, 055711,
        074717, 074757, 071111, 075757, 075717, 002020
 };
-long old[6], next[6], new[6], mask;
+static long old[6], next[6], new[6], mask;
 
-volatile sig_atomic_t sigtermed;
+static volatile sig_atomic_t sigtermed;
 
-int hascolor = 0;
+static int hascolor = 0;
 
-void set(int, int);
-void standt(int);
-void movto(int, int);
-void sighndl(int);
-void usage(void);
+static void set(int, int);
+static void standt(int);
+static void movto(int, int);
+static void sighndl(int);
+static void usage(void);
 
-void
+static void
 sighndl(int signo)
 {
-       sigtermed=signo;
+
+       sigtermed = signo;
 }
 
 int
@@ -225,7 +226,7 @@ main(int argc, char *argv[])
        return(0);
 }
 
-void
+static void
 set(int t, int n)
 {
        int i, m;
@@ -239,7 +240,7 @@ set(int t, int n)
                mask |= m;
 }
 
-void
+static void
 standt(int on)
 {
        if (on) {
@@ -257,13 +258,13 @@ standt(int on)
        }
 }
 
-void
+static void
 movto(int line, int col)
 {
        move(line, col);
 }
 
-void
+static void
 usage(void)
 {
 

Modified: stable/9/games/morse/morse.c
==============================================================================
--- stable/9/games/morse/morse.c        Wed Apr 24 12:36:37 2013        
(r249839)
+++ stable/9/games/morse/morse.c        Wed Apr 24 12:47:30 2013        
(r249840)
@@ -266,33 +266,33 @@ static const struct morsetab koi8rtab[] 
        {'\0', ""}
 };
 
-void            show(const char *), play(const char *), morse(char);
-void           ttyout(const char *);
-void           sighandler(int);
+static void    show(const char *), play(const char *), morse(char);
+static void    ttyout(const char *);
+static void    sighandler(int);
 
 #define GETOPTOPTS "c:d:ef:lsw:"
 #define USAGE \
 "usage: morse [-els] [-d device] [-w speed] [-c speed] [-f frequency] [string 
...]\n"
 
-static int      pflag, lflag, sflag, eflag;
-static int      wpm = 20;      /* effective words per minute */
-static int      cpm;           /* effective words per minute between
+static int     pflag, lflag, sflag, eflag;
+static int     wpm = 20;       /* effective words per minute */
+static int     cpm;            /* effective words per minute between
                                 * characters */
 #define FREQUENCY 600
-static int      freq = FREQUENCY;
+static int     freq = FREQUENCY;
 static char    *device;        /* for tty-controlled generator */
 
 #define DASH_LEN 3
 #define CHAR_SPACE 3
 #define WORD_SPACE (7 - CHAR_SPACE - 1)
-static float    dot_clock;
-static float    cdot_clock;
-int             spkr, line;
-struct termios otty, ntty;
-int            olflags;
+static float   dot_clock;
+static float   cdot_clock;
+static int     spkr, line;
+static struct termios otty, ntty;
+static int     olflags;
 
 #ifdef SPEAKER
-tone_t          sound;
+static tone_t  sound;
 #undef GETOPTOPTS
 #define GETOPTOPTS "c:d:ef:lpsw:"
 #undef USAGE
@@ -444,7 +444,7 @@ main(int argc, char **argv)
        exit(0);
 }
 
-void
+static void
 morse(char c)
 {
        const struct morsetab *m;
@@ -478,7 +478,7 @@ morse(char c)
        }
 }
 
-void
+static void
 show(const char *s)
 {
        if (lflag) {
@@ -493,7 +493,7 @@ show(const char *s)
        }
 }
 
-void
+static void
 play(const char *s)
 {
 #ifdef SPEAKER
@@ -535,7 +535,7 @@ play(const char *s)
 #endif
 }
 
-void
+static void
 ttyout(const char *s)
 {
        const char *c;
@@ -577,7 +577,7 @@ ttyout(const char *s)
        usleep(duration);
 }
 
-void
+static void
 sighandler(int signo)
 {
 

Modified: stable/9/games/number/number.c
==============================================================================
--- stable/9/games/number/number.c      Wed Apr 24 12:36:37 2013        
(r249839)
+++ stable/9/games/number/number.c      Wed Apr 24 12:47:30 2013        
(r249840)
@@ -74,14 +74,13 @@ static const char   *name1[] = {
        "novemdecillion",               "vigintillion",
 };
 
-void   convert(char *);
-int    number(char *, int);
-void   pfract(int);
-void   toobig(void);
-int    unit(int, char *);
-void   usage(void);
+static void    convert(char *);
+static int     number(char *, int);
+static void    pfract(int);
+static int     unit(int, char *);
+static void    usage(void);
 
-int lflag;
+static int lflag;
 
 int
 main(int argc, char *argv[])
@@ -120,7 +119,7 @@ main(int argc, char *argv[])
        exit(0);
 }
 
-void
+static void
 convert(char *line)
 {
        int flen, len, rval;
@@ -188,7 +187,7 @@ badnum:                     errx(1, "illegal number: %s", 
                (void)printf("\n");
 }
 
-int
+static int
 unit(int len, char *p)
 {
        int off, rval;
@@ -222,7 +221,7 @@ unit(int len, char *p)
        return (rval);
 }
 
-int
+static int
 number(char *p, int len)
 {
        int val, rval;
@@ -260,7 +259,7 @@ number(char *p, int len)
        return (rval);
 }
 
-void
+static void
 pfract(int len)
 {
        static char const * const pref[] = { "", "ten-", "hundred-" };
@@ -278,7 +277,7 @@ pfract(int len)
        }
 }
 
-void
+static void
 usage(void)
 {
        (void)fprintf(stderr, "usage: number [-l] [# ...]\n");
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to