Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/printf WARNS=6



details:   https://anonhg.NetBSD.org/src/rev/890b69b3e64c
branches:  trunk
changeset: 787949:890b69b3e64c
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jul 16 17:48:22 2013 +0000

description:
WARNS=6

diffstat:

 usr.bin/printf/Makefile |   4 +-
 usr.bin/printf/printf.c |  56 ++++++++++++++++++++++++------------------------
 2 files changed, 30 insertions(+), 30 deletions(-)

diffs (205 lines):

diff -r e632fd4619de -r 890b69b3e64c usr.bin/printf/Makefile
--- a/usr.bin/printf/Makefile   Tue Jul 16 17:47:43 2013 +0000
+++ b/usr.bin/printf/Makefile   Tue Jul 16 17:48:22 2013 +0000
@@ -1,6 +1,6 @@
-#      $NetBSD: Makefile,v 1.11 2011/08/16 10:37:21 christos Exp $
+#      $NetBSD: Makefile,v 1.12 2013/07/16 17:48:22 christos Exp $
 #      from: @(#)Makefile      8.1 (Berkeley) 6/6/93
-
+WARNS=6
 PROG=  printf
 
 COPTS.printf.c = -Wno-format-nonliteral
diff -r e632fd4619de -r 890b69b3e64c usr.bin/printf/printf.c
--- a/usr.bin/printf/printf.c   Tue Jul 16 17:47:43 2013 +0000
+++ b/usr.bin/printf/printf.c   Tue Jul 16 17:48:22 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: printf.c,v 1.35 2011/03/15 23:11:49 christos Exp $     */
+/*     $NetBSD: printf.c,v 1.36 2013/07/16 17:48:22 christos Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)printf.c   8.2 (Berkeley) 3/22/95";
 #else
-__RCSID("$NetBSD: printf.c,v 1.35 2011/03/15 23:11:49 christos Exp $");
+__RCSID("$NetBSD: printf.c,v 1.36 2013/07/16 17:48:22 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -68,13 +68,13 @@
 static void     conv_escape_str(char *, void (*)(int));
 static char    *conv_escape(char *, char *);
 static char    *conv_expand(const char *);
-static int      getchr(void);
+static char     getchr(void);
 static double   getdouble(void);
 static int      getwidth(void);
 static intmax_t         getintmax(void);
 static uintmax_t getuintmax(void);
 static char    *getstr(void);
-static char    *mklong(const char *, int);
+static char    *mklong(const char *, char);
 static void      check_conversion(const char *, const char *);
 static void     usage(void); 
 
@@ -128,15 +128,15 @@
        int fieldwidth, precision;
        char nextch;
        char *format;
-       int ch;
-       int error;
+       char ch;
+       int error, o;
 
 #if !defined(SHELL) && !defined(BUILTIN)
        (void)setlocale (LC_ALL, "");
 #endif
 
-       while ((ch = getopt(argc, argv, "")) != -1) {
-               switch (ch) {
+       while ((o = getopt(argc, argv, "")) != -1) {
+               switch (o) {
                case '?':
                default:
                        usage();
@@ -426,8 +426,8 @@
 static char *
 conv_escape(char *str, char *conv_ch)
 {
-       int value;
-       int ch;
+       char value;
+       char ch;
        char num_buf[4], *num_end;
 
        ch = *str++;
@@ -438,9 +438,9 @@
                num_buf[0] = ch;
                ch = str[0];
                num_buf[1] = ch;
-               num_buf[2] = ch ? str[1] : 0;
-               num_buf[3] = 0;
-               value = strtoul(num_buf, &num_end, 8);
+               num_buf[2] = (char)(ch != '\0' ? str[1] : '\0');
+               num_buf[3] = '\0';
+               value = (char)strtoul(num_buf, &num_end, 8);
                str += num_end  - (num_buf + 1);
                break;
 
@@ -451,9 +451,9 @@
                   Supporting 2 byte constants is a compromise. */
                ch = str[0];
                num_buf[0] = ch;
-               num_buf[1] = ch ? str[1] : 0;
-               num_buf[2] = 0;
-               value = strtoul(num_buf, &num_end, 16);
+               num_buf[1] = (char)(ch != '\0' ? str[1] : '\0');
+               num_buf[2] = '\0';
+               value = (char)strtoul(num_buf, &num_end, 16);
                str += num_end - num_buf;
                break;
 
@@ -487,7 +487,7 @@
 {
        static char *conv_str;
        char *cp;
-       int ch;
+       char ch;
 
        if (conv_str)
                free(conv_str);
@@ -497,7 +497,7 @@
                return NULL;
        cp = conv_str;
 
-       while ((ch = *(const unsigned char *)str++) != '\0') {
+       while ((ch = *(const char *)str++) != '\0') {
                switch (ch) {
                /* Use C escapes for expected control characters */
                case '\\':      ch = '\\';      break;  /* backslash */
@@ -513,7 +513,7 @@
                case '\v':      ch = 'v';       break;  /* vertical-tab */
                default:
                        /* Copy anything printable */
-                       if (isprint(ch)) {
+                       if (isprint((unsigned char)ch)) {
                                *cp++ = ch;
                                continue;
                        }
@@ -521,7 +521,7 @@
                        *cp++ = '\\';
                        if (ch & 0200) {
                                *cp++ = 'M';
-                               ch &= ~0200;
+                               ch &= (char)~0200;
                        }
                        if (ch == 0177) {
                                *cp++ = '^';
@@ -546,7 +546,7 @@
 }
 
 static char *
-mklong(const char *str, int ch)
+mklong(const char *str, char ch)
 {
        static char copy[64];
        size_t len;     
@@ -563,12 +563,12 @@
        return copy;    
 }
 
-static int
+static char
 getchr(void)
 {
        if (!*gargv)
                return 0;
-       return (int)**gargv++;
+       return **gargv++;
 }
 
 static char *
@@ -583,7 +583,7 @@
 static int
 getwidth(void)
 {
-       long val;
+       unsigned long val;
        char *s, *ep;
 
        s = *gargv;
@@ -596,12 +596,12 @@
        check_conversion(s, ep);
 
        /* Arbitrarily 'restrict' field widths to 1Mbyte */
-       if (val < 0 || val > 1 << 20) {
+       if (val > 1 << 20) {
                warnx("%s: invalid field width", s);
                return 0;
        }
 
-       return val;
+       return (int)val;
 }
 
 static intmax_t
@@ -616,7 +616,7 @@
        gargv++;
 
        if (*cp == '\"' || *cp == '\'')
-               return *(cp+1);
+               return *(cp + 1);
 
        errno = 0;
        val = strtoimax(cp, &ep, 0);
@@ -636,7 +636,7 @@
        gargv++;
 
        if (*cp == '\"' || *cp == '\'')
-               return *(cp + 1);
+               return (uintmax_t)*(cp + 1);
 
        /* strtoumax won't error -ve values */
        while (isspace(*(unsigned char *)cp))



Home | Main Index | Thread Index | Old Index