report utmp file name if can't open; bug report 4.2BSD/bin/176
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 21 Apr 1988 01:49:47 +0000 (17:49 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 21 Apr 1988 01:49:47 +0000 (17:49 -0800)
SCCS-vsn: usr.bin/who/who.c 5.4

usr/src/usr.bin/who/who.c

index 4266170..bfc5d2b 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)who.c      5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)who.c      5.4 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -48,13 +48,13 @@ main(argc, argv)
                if (tp)
                        tp = rindex(tp, '/') + 1;
                else {  /* no tty - use best guess from passwd file */
                if (tp)
                        tp = rindex(tp, '/') + 1;
                else {  /* no tty - use best guess from passwd file */
-                       strcpy(utmp.ut_line, "tty??");
+                       (void)strcpy(utmp.ut_line, "tty??");
                        guess();
                        exit(0);
                }
        }
                        guess();
                        exit(0);
                }
        }
-       if ((fi = fopen(s, "r")) == NULL) {
-               puts("who: cannot open utmp");
+       if (!(fi = fopen(s, "r"))) {
+               fprintf(stderr, "who: cannot read %s.\n", s);
                exit(1);
        }
        while (fread((char *)&utmp, sizeof(utmp), 1, fi) == 1) {
                exit(1);
        }
        while (fread((char *)&utmp, sizeof(utmp), 1, fi) == 1) {