Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/error Don't use non-literal format strings. Split it...



details:   https://anonhg.NetBSD.org/src/rev/6af9994ae282
branches:  trunk
changeset: 777683:6af9994ae282
user:      joerg <joerg%NetBSD.org@localhost>
date:      Wed Feb 29 23:37:07 2012 +0000

description:
Don't use non-literal format strings. Split it up depending on the
number of arguments used.

diffstat:

 usr.bin/error/error.h |   4 ++--
 usr.bin/error/touch.c |  15 +++++++++------
 2 files changed, 11 insertions(+), 8 deletions(-)

diffs (54 lines):

diff -r eb77a2f99cec -r 6af9994ae282 usr.bin/error/error.h
--- a/usr.bin/error/error.h     Wed Feb 29 23:35:49 2012 +0000
+++ b/usr.bin/error/error.h     Wed Feb 29 23:37:07 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: error.h,v 1.18 2011/08/17 13:11:22 christos Exp $      */
+/*     $NetBSD: error.h,v 1.19 2012/02/29 23:37:07 joerg Exp $ */
 
 /*
  * Copyright (c) 1980, 1993
@@ -114,7 +114,7 @@
 
 extern boolean query;
 extern boolean terse;
-int inquire(const char *, ...);        /* inquire for yes/no */
+int inquire(const char *, ...) __printflike(1, 2);     /* inquire for yes/no */
 
 /*
  * codes for inquire() to return
diff -r eb77a2f99cec -r 6af9994ae282 usr.bin/error/touch.c
--- a/usr.bin/error/touch.c     Wed Feb 29 23:35:49 2012 +0000
+++ b/usr.bin/error/touch.c     Wed Feb 29 23:37:07 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: touch.c,v 1.26 2011/05/24 12:24:22 joerg Exp $ */
+/*     $NetBSD: touch.c,v 1.27 2012/02/29 23:37:07 joerg Exp $ */
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)touch.c    8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.26 2011/05/24 12:24:22 joerg Exp $");
+__RCSID("$NetBSD: touch.c,v 1.27 2012/02/29 23:37:07 joerg Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -388,10 +388,13 @@
        int dest = TOSTDOUT;
 
        if (query) {
-               switch (inquire(terse
-                       ? "Touch? "
-                       : "Do you want to touch file \"%s\"? ",
-                       name)) {
+               int reply;
+               if (terse)
+                       reply = inquire("Touch? ");
+               else
+                       reply = inquire("Do you want to touch file \"%s\"? ",
+                           name);
+               switch (reply) {
                case Q_NO:
                case Q_no:
                case Q_error:



Home | Main Index | Thread Index | Old Index