NetBSD-Bugs archive

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

bin/38755: /bin posix programs missing setprogname and/or setlocal



>Number:         38755
>Category:       bin
>Synopsis:       /bin posix programs missing setprogname and/or setlocal
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon May 26 08:30:00 +0000 2008
>Originator:     murray armfield
>Release:        NetBSD-current
>Organization:
N/A
>Environment:
NetBSD zeus.river-styx.org 4.99.63 NetBSD 4.99.63 (ZEUS) #1: Sun May 25 
11:08:57 EST 2008  
admin%zeus.river-styx.org@localhost:/vol01/build/obj/sys/arch/amd64/compile/ZEUS
 amd64
>Description:
There are several posix programs in the /bin directory that are missing calls 
to setprogname and/or setlocale at the start of their main() function.

Also, /bin/rmdir/rmdir.c includes <errno.h> unnecessarily.
>How-To-Repeat:
Inspection
>Fix:
Index: cp/cp.c
===================================================================
RCS file: /cvsroot/src/bin/cp/cp.c,v
retrieving revision 1.48
diff -u -u -p -r1.48 cp.c
--- cp/cp.c     26 Dec 2006 00:13:24 -0000      1.48
+++ cp/cp.c     26 May 2008 08:22:00 -0000
@@ -103,6 +103,7 @@ main(int argc, char *argv[])
        char *target, **src;

        (void)setlocale(LC_ALL, "");
+       setprogname(argv[0]);

        Hflag = Lflag = Pflag = Rflag = 0;
        while ((ch = getopt(argc, argv, "HLNPRfiprv")) != -1)
Index: dd/dd.c
===================================================================
RCS file: /cvsroot/src/bin/dd/dd.c,v
retrieving revision 1.40
diff -u -u -p -r1.40 dd.c
--- dd/dd.c     29 Apr 2007 20:23:34 -0000      1.40
+++ dd/dd.c     26 May 2008 08:22:00 -0000
@@ -57,6 +57,7 @@ __RCSID("$NetBSD: dd.c,v 1.40 2007/04/29
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <locale.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -91,6 +92,9 @@ main(int argc, char *argv[])
 {
        int ch;

+       setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");
+
        while ((ch = getopt(argc, argv, "")) != -1) {
                switch (ch) {
                default:
Index: df/df.c
===================================================================
RCS file: /cvsroot/src/bin/df/df.c,v
retrieving revision 1.81
diff -u -u -p -r1.81 df.c
--- df/df.c     4 Mar 2008 18:55:57 -0000       1.81
+++ df/df.c     26 May 2008 08:22:00 -0000
@@ -57,6 +57,7 @@ __RCSID("$NetBSD: df.c,v 1.81 2008/03/04
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <locale.h>
 #include <util.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -91,6 +92,9 @@ main(int argc, char *argv[])
        int ch, i, maxwidth, width;
        char *mntpt;

+       setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");
+
        while ((ch = getopt(argc, argv, "aGghiklmnPt:")) != -1)
                switch (ch) {
                case 'a':
Index: echo/echo.c
===================================================================
RCS file: /cvsroot/src/bin/echo/echo.c,v
retrieving revision 1.15
diff -u -u -p -r1.15 echo.c
--- echo/echo.c 25 Nov 2003 03:40:18 -0000      1.15
+++ echo/echo.c 26 May 2008 08:22:00 -0000
@@ -44,6 +44,7 @@ __RCSID("$NetBSD: echo.c,v 1.15 2003/11/
 #endif
 #endif /* not lint */

+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -56,6 +57,9 @@ main(int argc, char *argv[])
 {
        int nflag;

+       setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");
+
        /* This utility may NOT do getopt(3) option parsing. */
        if (*++argv && !strcmp(*argv, "-n")) {
                ++argv;
Index: ln/ln.c
===================================================================
RCS file: /cvsroot/src/bin/ln/ln.c,v
retrieving revision 1.32
diff -u -u -p -r1.32 ln.c
--- ln/ln.c     13 Oct 2006 20:37:10 -0000      1.32
+++ ln/ln.c     26 May 2008 08:22:01 -0000
@@ -48,6 +48,7 @@ __RCSID("$NetBSD: ln.c,v 1.32 2006/10/13

 #include <err.h>
 #include <errno.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -75,6 +76,8 @@ main(int argc, char *argv[])
        char *sourcedir;

        setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");
+
        while ((ch = getopt(argc, argv, "fhinsv")) != -1)
                switch (ch) {
                case 'f':
Index: ps/ps.c
===================================================================
RCS file: /cvsroot/src/bin/ps/ps.c,v
retrieving revision 1.67
diff -u -u -p -r1.67 ps.c
--- ps/ps.c     28 Apr 2008 20:22:51 -0000      1.67
+++ ps/ps.c     26 May 2008 08:22:01 -0000
@@ -89,6 +89,7 @@ __RCSID("$NetBSD: ps.c,v 1.67 2008/04/28
 #include <fcntl.h>
 #include <kvm.h>
 #include <limits.h>
+#include <locale.h>
 #include <nlist.h>
 #include <paths.h>
 #include <pwd.h>
@@ -156,6 +157,9 @@ main(int argc, char *argv[])
        char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX];
        char *ttname;

+       setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");
+
        if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
             ioctl(STDERR_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
             ioctl(STDIN_FILENO,  TIOCGWINSZ, (char *)&ws) == -1) ||
Index: pwd/pwd.c
===================================================================
RCS file: /cvsroot/src/bin/pwd/pwd.c,v
retrieving revision 1.19
diff -u -u -p -r1.19 pwd.c
--- pwd/pwd.c   30 Oct 2003 13:52:23 -0000      1.19
+++ pwd/pwd.c   26 May 2008 08:22:01 -0000
@@ -49,6 +49,7 @@ __RCSID("$NetBSD: pwd.c,v 1.19 2003/10/3

 #include <err.h>
 #include <errno.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -72,6 +73,8 @@ main(int argc, char *argv[])
        const char *p;

        setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");
+
        lFlag = 0;
        while ((ch = getopt(argc, argv, "LP")) != -1) {
                switch (ch) {
Index: rcp/rcp.c
===================================================================
RCS file: /cvsroot/src/bin/rcp/rcp.c,v
retrieving revision 1.45
diff -u -u -p -r1.45 rcp.c
--- rcp/rcp.c   24 Feb 2008 05:16:46 -0000      1.45
+++ rcp/rcp.c   26 May 2008 08:22:01 -0000
@@ -56,6 +56,7 @@ __RCSID("$NetBSD: rcp.c,v 1.45 2008/02/2
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <locale.h>
 #include <netdb.h>
 #include <pwd.h>
 #include <signal.h>
@@ -97,6 +98,9 @@ main(int argc, char *argv[])
        char *targ;
        const char *shell;

+       setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");
+
        fflag = tflag = 0;
        while ((ch = getopt(argc, argv, OPTIONS)) != -1)
                switch(ch) {                    /* User-visible flags. */
Index: rmdir/rmdir.c
===================================================================
RCS file: /cvsroot/src/bin/rmdir/rmdir.c,v
retrieving revision 1.23
diff -u -u -p -r1.23 rmdir.c
--- rmdir/rmdir.c       29 Sep 2003 21:11:15 -0000      1.23
+++ rmdir/rmdir.c       26 May 2008 08:22:01 -0000
@@ -46,7 +46,6 @@ __RCSID("$NetBSD: rmdir.c,v 1.23 2003/09
 #include <sys/param.h>

 #include <err.h>
-#include <errno.h>
 #include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
Index: stty/stty.c
===================================================================
RCS file: /cvsroot/src/bin/stty/stty.c,v
retrieving revision 1.19
diff -u -u -p -r1.19 stty.c
--- stty/stty.c 7 Aug 2003 09:05:42 -0000       1.19
+++ stty/stty.c 26 May 2008 08:22:01 -0000
@@ -49,6 +49,7 @@ __RCSID("$NetBSD: stty.c,v 1.19 2003/08/
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -67,6 +68,7 @@ main(int argc, char *argv[])
        int ch;

        setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");

        fmt = STTY_NOTSET;
        i.fd = STDIN_FILENO;
Index: test/test.c
===================================================================
RCS file: /cvsroot/src/bin/test/test.c,v
retrieving revision 1.34
diff -u -u -p -r1.34 test.c
--- test/test.c 15 Dec 2007 19:44:38 -0000      1.34
+++ test/test.c 26 May 2008 08:22:01 -0000
@@ -22,6 +22,7 @@ __RCSID("$NetBSD: test.c,v 1.34 2007/12/
 #include <err.h>
 #include <errno.h>
 #include <limits.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -218,6 +219,7 @@ main(int argc, char *argv[])
        argv0 = argv[0];
 #else
        setprogname(argv[0]);
+       (void)setlocale(LC_ALL, "");
        argv0 = getprogname();
 #endif
        if (strcmp(argv0, "[") == 0) {



Home | Main Index | Thread Index | Old Index