Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/mktemp warns=3, delint.



details:   https://anonhg.NetBSD.org/src/rev/179a0c38cd5a
branches:  trunk
changeset: 583328:179a0c38cd5a
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jul 30 16:19:09 2005 +0000

description:
warns=3, delint.

diffstat:

 usr.bin/mktemp/Makefile |   3 ++-
 usr.bin/mktemp/mktemp.c |  38 +++++++++++++++++++++-----------------
 2 files changed, 23 insertions(+), 18 deletions(-)

diffs (110 lines):

diff -r 5ce4a52029fa -r 179a0c38cd5a usr.bin/mktemp/Makefile
--- a/usr.bin/mktemp/Makefile   Sat Jul 30 16:14:39 2005 +0000
+++ b/usr.bin/mktemp/Makefile   Sat Jul 30 16:19:09 2005 +0000
@@ -1,5 +1,6 @@
-# $NetBSD: Makefile,v 1.6 2003/05/18 07:57:36 lukem Exp $
+# $NetBSD: Makefile,v 1.7 2005/07/30 16:19:09 christos Exp $
 
+WARNS=3
 PROG=  mktemp
 
 .include <bsd.prog.mk>
diff -r 5ce4a52029fa -r 179a0c38cd5a usr.bin/mktemp/mktemp.c
--- a/usr.bin/mktemp/mktemp.c   Sat Jul 30 16:14:39 2005 +0000
+++ b/usr.bin/mktemp/mktemp.c   Sat Jul 30 16:19:09 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mktemp.c,v 1.6 2003/10/27 00:12:43 lukem Exp $ */
+/* $NetBSD: mktemp.c,v 1.7 2005/07/30 16:19:09 christos Exp $ */
 
 /*-
  * Copyright (c) 1994, 1995, 1996, 1998 Peter Wemm <peter%netplex.com.au@localhost>
@@ -49,19 +49,21 @@
 #include <unistd.h>
 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: mktemp.c,v 1.6 2003/10/27 00:12:43 lukem Exp $");
+__RCSID("$NetBSD: mktemp.c,v 1.7 2005/07/30 16:19:09 christos Exp $");
 #endif /* !__lint */
 
-static void usage __P((void));
+static void usage(void) __attribute__((__noreturn__));
 
 int
 main(int argc, char **argv)
 {
        int c, fd, ret;
-       char *tmpdir, *prefix;
+       char *tmpdir;
+       const char *prefix;
        char *name;
        int dflag, qflag, tflag, uflag;
 
+       setprogname(*argv);
        ret = dflag = qflag = tflag = uflag = 0;
        prefix = "mktemp";
        name = NULL;
@@ -95,15 +97,16 @@
        if (tflag) {
                tmpdir = getenv("TMPDIR");
                if (tmpdir == NULL)
-                       asprintf(&name, "%s%s.XXXXXXXX", _PATH_TMP, prefix);
+                       (void)asprintf(&name, "%s%s.XXXXXXXX", _PATH_TMP,
+                           prefix);
                else
-                       asprintf(&name, "%s/%s.XXXXXXXX", tmpdir, prefix);
+                       (void)asprintf(&name, "%s/%s.XXXXXXXX", tmpdir, prefix);
                /* if this fails, the program is in big trouble already */
                if (name == NULL) {
                        if (qflag)
-                               return (1);
+                               return 1;
                        else
-                               errx(1, "cannot generate template");
+                               errx(1, "Cannot generate template");
                }
        } else if (argc < 1) {
                usage();
@@ -123,9 +126,9 @@
                                if (!qflag)
                                        warn("mkdtemp failed on %s", name);
                        } else {
-                               printf("%s\n", name);
+                               (void)printf("%s\n", name);
                                if (uflag)
-                                       rmdir(name);
+                                       (void)rmdir(name);
                        }
                } else {
                        fd = mkstemp(name);
@@ -134,23 +137,24 @@
                                if (!qflag)
                                        warn("mkstemp failed on %s", name);
                        } else {
-                               close(fd);
+                               (void)close(fd);
                                if (uflag)
-                                       unlink(name);
-                               printf("%s\n", name);
+                                       (void)unlink(name);
+                               (void)printf("%s\n", name);
                        }
                }
                if (name)
                        free(name);
                name = NULL;
        }
-       return (ret);
+       return ret;
 }
 
 static void
-usage()
+usage(void)
 {
-       fprintf(stderr,
-               "usage: mktemp [-d] [-q] [-t prefix] [-u] [template ...]\n");
+       (void)fprintf(stderr,
+               "Usage: %s [-d] [-q] [-t prefix] [-u] [template ...]\n",
+               getprogname());
        exit (1);
 }



Home | Main Index | Thread Index | Old Index