Hi tech@

Few nitpicks on games:

Change home var to const char* both on canfield(6)/cfscores(6), and on the
latter also remove unused var name.

Additionaly on snake(6) one of the getenv("HOME") missed a safe checking for
NULL.

Index: games/canfield/canfield/canfield.c
===================================================================
RCS file: /cvs/src/games/canfield/canfield/canfield.c,v
retrieving revision 1.21
diff -u -p -u -r1.21 canfield.c
--- games/canfield/canfield/canfield.c  30 Nov 2015 08:38:13 -0000      1.21
+++ games/canfield/canfield/canfield.c  2 Dec 2015 12:59:05 -0000
@@ -1627,7 +1627,7 @@ initall(void)
 {
        int i, ret;
        char scorepath[PATH_MAX];
-       char *home;
+       const char *home;
 
        time(&acctstart);
        initdeck(deck);
Index: games/canfield/cfscores/cfscores.c
===================================================================
RCS file: /cvs/src/games/canfield/cfscores/cfscores.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 cfscores.c
--- games/canfield/cfscores/cfscores.c  30 Nov 2015 08:38:13 -0000      1.20
+++ games/canfield/cfscores/cfscores.c  2 Dec 2015 12:59:18 -0000
@@ -59,7 +59,7 @@ void  printuser(void);
 int
 main(int argc, char *argv[])
 {
-       char *home, *name;
+       const char *home;
        int ret;
 
        if (pledge("stdio rpath", NULL) == -1)
Index: games/snake/snake.c
===================================================================
RCS file: /cvs/src/games/snake/snake.c,v
retrieving revision 1.18
diff -u -p -u -r1.18 snake.c
--- games/snake/snake.c 29 Nov 2015 14:31:01 -0000      1.18
+++ games/snake/snake.c 2 Dec 2015 12:59:58 -0000
@@ -148,7 +148,13 @@ main(int argc, char *argv[])
                err(1, "pledge");
 
 #ifdef LOGGING
-       snprintf(logpath, sizeof(logpath), "%s/%s", getenv("HOME"),
+       const   char* home;
+
+       home = getenv("HOME");
+       if (home == NULL || *home == '\0')
+               err(1, "getenv");
+
+       snprintf(logpath, sizeof(logpath), "%s/%s", home,
            ".snake.log");
        logfile = fopen(logpath, "a");
 #endiF

Reply via email to