Source-Changes-HG archive

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

[src/trunk]: src Add __printflike attribution to use vprintf and friends with...



details:   https://anonhg.NetBSD.org/src/rev/9613e0358352
branches:  trunk
changeset: 778066:9613e0358352
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Mar 15 02:02:20 2012 +0000

description:
Add __printflike attribution to use vprintf and friends with an argument
as format string.

diffstat:

 bin/expr/expr.y                         |   6 ++--
 bin/sh/error.c                          |   8 +++---
 bin/sh/error.h                          |  36 +++++++++++---------------------
 bin/sh/exec.h                           |   5 +--
 bin/sh/output.h                         |  17 +++++----------
 bin/sh/trap.h                           |   4 +-
 bin/test/test.c                         |   8 +++---
 lib/libpuffs/opdump.c                   |   6 ++--
 lib/lua/gpio/gpio.c                     |   4 +-
 lib/lua/sqlite/sqlite.c                 |   4 +-
 libexec/fingerd/fingerd.c               |   6 ++--
 libexec/identd/identd.c                 |   6 ++--
 libexec/identd/identd.h                 |   4 +-
 sbin/dkscan_bsdlabel/dkscan_util.h      |   6 ++--
 sbin/fdisk/fdisk.c                      |   6 ++--
 sbin/sysctl/sysctl.c                    |   6 ++--
 sys/ddb/db_output.h                     |   4 +-
 sys/rump/include/rump/rumpuser.h        |   4 +-
 tests/fs/ffs/t_quota2_1.c               |   9 +++----
 tests/fs/ffs/t_quota2_remount.c         |   8 ++----
 tests/h_macros.h                        |   4 +-
 tests/kernel/gen_t_subr_prf             |   4 +-
 tests/lib/libc/ssp/h_vsnprintf.c        |   6 ++--
 tests/lib/libc/ssp/h_vsprintf.c         |   6 ++--
 tests/lib/libc/stdlib/t_getenv_thread.c |  31 +++++----------------------
 tests/modules/t_modctl.c                |   8 +++---
 usr.bin/bthset/bthset.c                 |   6 ++--
 usr.bin/getent/getent.c                 |   6 ++--
 usr.bin/m4/extern.h                     |   9 ++++---
 usr.bin/su/su_pam.c                     |   6 ++--
 usr.sbin/cpuctl/cpuctl.h                |  14 ++++++------
 usr.sbin/envstat/config_lex.l           |   6 ++--
 usr.sbin/envstat/config_yacc.y          |   6 ++--
 usr.sbin/ldpd/ldp_errors.c              |   4 +-
 usr.sbin/ldpd/ldp_errors.h              |   8 +++---
 usr.sbin/ldpd/mpls_routes.c             |   4 +-
 usr.sbin/mtree/spec.c                   |   6 ++--
 usr.sbin/powerd/powerd.c                |   4 +-
 usr.sbin/ypserv/ypserv/ypserv.c         |   6 ++--
 39 files changed, 132 insertions(+), 169 deletions(-)

diffs (truncated from 1020 to 300 lines):

diff -r 383467c86944 -r 9613e0358352 bin/expr/expr.y
--- a/bin/expr/expr.y   Thu Mar 15 02:00:52 2012 +0000
+++ b/bin/expr/expr.y   Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: expr.y,v 1.37 2011/08/25 01:11:47 joerg Exp $ */
+/* $NetBSD: expr.y,v 1.38 2012/03/15 02:02:20 joerg Exp $ */
 
 /*_
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 %{
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: expr.y,v 1.37 2011/08/25 01:11:47 joerg Exp $");
+__RCSID("$NetBSD: expr.y,v 1.38 2012/03/15 02:02:20 joerg Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -430,7 +430,7 @@
 /*
  * Print error message and exit with error 2 (syntax error).
  */
-static void
+static __printflike(1, 2) void
 yyerror(const char *fmt, ...)
 {
        va_list arg;
diff -r 383467c86944 -r 9613e0358352 bin/sh/error.c
--- a/bin/sh/error.c    Thu Mar 15 02:00:52 2012 +0000
+++ b/bin/sh/error.c    Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: error.c,v 1.37 2008/10/16 14:36:40 dholland Exp $      */
+/*     $NetBSD: error.c,v 1.38 2012/03/15 02:02:20 joerg Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)error.c    8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: error.c,v 1.37 2008/10/16 14:36:40 dholland Exp $");
+__RCSID("$NetBSD: error.c,v 1.38 2012/03/15 02:02:20 joerg Exp $");
 #endif
 #endif /* not lint */
 
@@ -120,7 +120,7 @@
        /* NOTREACHED */
 }
 
-static void
+static __printflike(2, 0) void
 exvwarning(int sv_errno, const char *msg, va_list ap)
 {
        /* Partially emulate line buffered output so that:
@@ -151,7 +151,7 @@
  * is not NULL then error prints an error message using printf style
  * formatting.  It then raises the error exception.
  */
-static void
+static __printflike(2, 0) void
 exverror(int cond, const char *msg, va_list ap)
 {
        CLEAR_PENDING_INT;
diff -r 383467c86944 -r 9613e0358352 bin/sh/error.h
--- a/bin/sh/error.h    Thu Mar 15 02:00:52 2012 +0000
+++ b/bin/sh/error.h    Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: error.h,v 1.18 2011/08/23 09:59:20 christos Exp $      */
+/*     $NetBSD: error.h,v 1.19 2012/03/15 02:02:20 joerg Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -89,33 +89,23 @@
 #define int_pending() intpending
 
 #if ! defined(SHELL_BUILTIN)
-void exraise(int) __attribute__((__noreturn__));
+void exraise(int) __dead;
 void onint(void);
-void error(const char *, ...) __attribute__((__noreturn__))
-    __attribute__((__format__(__printf__, 1, 2)));
-void exerror(int, const char *, ...) __attribute__((__noreturn__))
-    __attribute__((__format__(__printf__, 2, 3)));
+void error(const char *, ...) __dead __printflike(1, 2);
+void exerror(int, const char *, ...) __dead __printflike(2, 3);
 const char *errmsg(int, int);
 #endif /* ! SHELL_BUILTIN */
 
-void sh_err(int, const char *, ...) __attribute__((__noreturn__))
-    __attribute__((__format__(__printf__, 2, 3)));
-void sh_verr(int, const char *, va_list) __attribute__((__noreturn__))
-    __attribute__((__format__(__printf__, 2, 0)));
-void sh_errx(int, const char *, ...) __attribute__((__noreturn__))
-    __attribute__((__format__(__printf__, 2, 3)));
-void sh_verrx(int, const char *, va_list) __attribute__((__noreturn__))
-    __attribute__((__format__(__printf__, 2, 0)));
-void sh_warn(const char *, ...)
-    __attribute__((__format__(__printf__, 1, 2)));
-void sh_vwarn(const char *, va_list)
-    __attribute__((__format__(__printf__, 1, 0)));
-void sh_warnx(const char *, ...)
-    __attribute__((__format__(__printf__, 1, 2)));
-void sh_vwarnx(const char *, va_list)
-    __attribute__((__format__(__printf__, 1, 0)));
+void sh_err(int, const char *, ...) __dead __printflike(2, 3);
+void sh_verr(int, const char *, va_list) __dead __printflike(2, 0);
+void sh_errx(int, const char *, ...) __dead __printflike(2, 3);
+void sh_verrx(int, const char *, va_list) __dead __printflike(2, 0);
+void sh_warn(const char *, ...) __printflike(1, 2);
+void sh_vwarn(const char *, va_list) __printflike(1, 0);
+void sh_warnx(const char *, ...) __printflike(1, 2);
+void sh_vwarnx(const char *, va_list) __printflike(1, 0);
 
-void sh_exit(int) __attribute__((__noreturn__));
+void sh_exit(int) __dead;
 
 
 /*
diff -r 383467c86944 -r 9613e0358352 bin/sh/exec.h
--- a/bin/sh/exec.h     Thu Mar 15 02:00:52 2012 +0000
+++ b/bin/sh/exec.h     Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec.h,v 1.22 2011/06/18 21:18:46 christos Exp $       */
+/*     $NetBSD: exec.h,v 1.23 2012/03/15 02:02:20 joerg Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -61,8 +61,7 @@
 
 extern const char *pathopt;    /* set by padvance */
 
-void shellexec(char **, char **, const char *, int, int)
-    __attribute__((__noreturn__));
+void shellexec(char **, char **, const char *, int, int) __dead;
 char *padvance(const char **, const char *);
 void find_command(char *, struct cmdentry *, int, const char *);
 int (*find_builtin(char *))(int, char **);
diff -r 383467c86944 -r 9613e0358352 bin/sh/output.h
--- a/bin/sh/output.h   Thu Mar 15 02:00:52 2012 +0000
+++ b/bin/sh/output.h   Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: output.h,v 1.23 2011/08/23 09:59:20 christos Exp $     */
+/*     $NetBSD: output.h,v 1.24 2012/03/15 02:02:20 joerg Exp $        */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -66,18 +66,13 @@
 void flushall(void);
 void flushout(struct output *);
 void freestdout(void);
-void outfmt(struct output *, const char *, ...)
-    __attribute__((__format__(__printf__, 2, 3)));
-void out1fmt(const char *, ...)
-    __attribute__((__format__(__printf__, 1, 2)));
+void outfmt(struct output *, const char *, ...) __printflike(2, 3);
+void out1fmt(const char *, ...) __printflike(1, 2);
 #ifdef DEBUG
-void debugprintf(const char *, ...)
-    __attribute__((__format__(__printf__, 1, 2)));
+void debugprintf(const char *, ...) __printflike(1, 2);
 #endif
-void fmtstr(char *, size_t, const char *, ...)
-    __attribute__((__format__(__printf__, 3, 4)));
-void doformat(struct output *, const char *, va_list)
-    __attribute__((__format__(__printf__, 2, 0)));
+void fmtstr(char *, size_t, const char *, ...) __printflike(3, 4);
+void doformat(struct output *, const char *, va_list) __printflike(2, 0);
 int xwrite(int, char *, int);
 int xioctl(int, unsigned long, char *);
 
diff -r 383467c86944 -r 9613e0358352 bin/sh/trap.h
--- a/bin/sh/trap.h     Thu Mar 15 02:00:52 2012 +0000
+++ b/bin/sh/trap.h     Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.h,v 1.19 2011/06/18 21:18:46 christos Exp $       */
+/*     $NetBSD: trap.h,v 1.20 2012/03/15 02:02:20 joerg Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,4 +42,4 @@
 void onsig(int);
 void dotrap(void);
 void setinteractive(int);
-void exitshell(int) __attribute__((__noreturn__));
+void exitshell(int) __dead;
diff -r 383467c86944 -r 9613e0358352 bin/test/test.c
--- a/bin/test/test.c   Thu Mar 15 02:00:52 2012 +0000
+++ b/bin/test/test.c   Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: test.c,v 1.38 2011/08/29 14:51:19 joerg Exp $ */
+/* $NetBSD: test.c,v 1.39 2012/03/15 02:02:21 joerg Exp $ */
 
 /*
  * test(1); version 7-like  --  author Erik Baalbergen
@@ -12,7 +12,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: test.c,v 1.38 2011/08/29 14:51:19 joerg Exp $");
+__RCSID("$NetBSD: test.c,v 1.39 2012/03/15 02:02:21 joerg Exp $");
 #endif
 
 #include <sys/stat.h>
@@ -172,10 +172,10 @@
 static int equalf(const char *, const char *);
 
 #if defined(SHELL)
-extern void error(const char *, ...) __dead;
+extern void error(const char *, ...) __dead __printflike(1, 2);
 extern void *ckmalloc(size_t);
 #else
-static void error(const char *, ...) __dead;
+static void error(const char *, ...) __dead __printflike(1, 2);
 
 static void
 error(const char *msg, ...)
diff -r 383467c86944 -r 9613e0358352 lib/libpuffs/opdump.c
--- a/lib/libpuffs/opdump.c     Thu Mar 15 02:00:52 2012 +0000
+++ b/lib/libpuffs/opdump.c     Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opdump.c,v 1.35 2010/08/20 16:35:05 pooka Exp $        */
+/*     $NetBSD: opdump.c,v 1.36 2012/03/15 02:02:21 joerg Exp $        */
 
 /*
  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: opdump.c,v 1.35 2010/08/20 16:35:05 pooka Exp $");
+__RCSID("$NetBSD: opdump.c,v 1.36 2012/03/15 02:02:21 joerg Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -148,7 +148,7 @@
 };
 size_t puffsdump_flush_count = __arraycount(puffsdump_flush_revmap);
 
-static void
+static __printflike(1, 2) void
 mydprintf(const char *fmt, ...)
 {
        va_list ap;
diff -r 383467c86944 -r 9613e0358352 lib/lua/gpio/gpio.c
--- a/lib/lua/gpio/gpio.c       Thu Mar 15 02:00:52 2012 +0000
+++ b/lib/lua/gpio/gpio.c       Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gpio.c,v 1.6 2011/11/13 16:56:15 mbalmer Exp $ */
+/*     $NetBSD: gpio.c,v 1.7 2012/03/15 02:02:21 joerg Exp $ */
 
 /*
  * Copyright (c) 2011 Marc Balmer <marc%msys.ch@localhost>
@@ -45,7 +45,7 @@
 
 #define GPIO_METATABLE "GPIO object methods"
 
-static void
+static __printflike(2, 3) void
 gpio_error(lua_State *L, const char *fmt, ...)
 {
        va_list ap;
diff -r 383467c86944 -r 9613e0358352 lib/lua/sqlite/sqlite.c
--- a/lib/lua/sqlite/sqlite.c   Thu Mar 15 02:00:52 2012 +0000
+++ b/lib/lua/sqlite/sqlite.c   Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sqlite.c,v 1.3 2011/10/15 12:58:20 mbalmer Exp $ */
+/*     $NetBSD: sqlite.c,v 1.4 2012/03/15 02:02:21 joerg Exp $ */
 
 /*
  * Copyright (c) 2011 Marc Balmer <marc%msys.ch@localhost>
@@ -42,7 +42,7 @@
 
 int luaopen_sqlite(lua_State*);
 
-static void
+static __printflike(2, 3) void
 sqlite_error(lua_State *L, const char *fmt, ...)
 {
        va_list ap;
diff -r 383467c86944 -r 9613e0358352 libexec/fingerd/fingerd.c
--- a/libexec/fingerd/fingerd.c Thu Mar 15 02:00:52 2012 +0000
+++ b/libexec/fingerd/fingerd.c Thu Mar 15 02:02:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fingerd.c,v 1.26 2011/08/27 15:08:58 joerg Exp $       */
+/*     $NetBSD: fingerd.c,v 1.27 2012/03/15 02:02:21 joerg Exp $       */
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "from: @(#)fingerd.c    8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fingerd.c,v 1.26 2011/08/27 15:08:58 joerg Exp $");
+__RCSID("$NetBSD: fingerd.c,v 1.27 2012/03/15 02:02:21 joerg Exp $");
 #endif
 #endif /* not lint */
 
@@ -58,7 +58,7 @@
 #include <string.h>
 #include "pathnames.h"



Home | Main Index | Thread Index | Old Index