summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-10-20 23:57:13 +0000
committernicm <nicm@openbsd.org>2014-10-20 23:57:13 +0000
commit74d4b937f51b5db0e6007b319cad3987fa67a2fb (patch)
treed8b7a1894fc57f2c4f1372b8f5748b2914a0ab68
parentMove template defines back into .c files. (diff)
downloadwireguard-openbsd-74d4b937f51b5db0e6007b319cad3987fa67a2fb.tar.xz
wireguard-openbsd-74d4b937f51b5db0e6007b319cad3987fa67a2fb.zip
Better format for printf format attributes.
-rw-r--r--usr.bin/tmux/cmd-queue.c6
-rw-r--r--usr.bin/tmux/control.c4
-rw-r--r--usr.bin/tmux/log.c8
-rw-r--r--usr.bin/tmux/options.c4
-rw-r--r--usr.bin/tmux/screen-write.c28
-rw-r--r--usr.bin/tmux/status.c4
-rw-r--r--usr.bin/tmux/tmux.h48
-rw-r--r--usr.bin/tmux/xmalloc.c6
8 files changed, 52 insertions, 56 deletions
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c
index 5313cb09451..9200f208cc3 100644
--- a/usr.bin/tmux/cmd-queue.c
+++ b/usr.bin/tmux/cmd-queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-queue.c,v 1.17 2014/09/01 21:50:18 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.18 2014/10/20 23:57:13 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -57,7 +57,7 @@ cmdq_free(struct cmd_q *cmdq)
}
/* Show message from command. */
-void printflike2
+void
cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
{
struct client *c = cmdq->client;
@@ -87,7 +87,7 @@ cmdq_print(struct cmd_q *cmdq, const char *fmt, ...)
}
/* Show error from command. */
-void printflike2
+void
cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
{
struct client *c = cmdq->client;
diff --git a/usr.bin/tmux/control.c b/usr.bin/tmux/control.c
index f157368b747..d439a5666ad 100644
--- a/usr.bin/tmux/control.c
+++ b/usr.bin/tmux/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.12 2013/10/10 11:45:29 nicm Exp $ */
+/* $OpenBSD: control.c,v 1.13 2014/10/20 23:57:13 nicm Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -27,7 +27,7 @@
#include "tmux.h"
/* Write a line. */
-void printflike2
+void
control_write(struct client *c, const char *fmt, ...)
{
va_list ap;
diff --git a/usr.bin/tmux/log.c b/usr.bin/tmux/log.c
index 83779151e7c..0680ac4e120 100644
--- a/usr.bin/tmux/log.c
+++ b/usr.bin/tmux/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.10 2014/03/31 21:42:45 nicm Exp $ */
+/* $OpenBSD: log.c,v 1.11 2014/10/20 23:57:13 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -80,7 +80,7 @@ log_vwrite(const char *msg, va_list ap)
}
/* Log a debug message. */
-void printflike1
+void
log_debug(const char *msg, ...)
{
va_list ap;
@@ -91,7 +91,7 @@ log_debug(const char *msg, ...)
}
/* Log a critical error with error string and die. */
-__dead void printflike1
+__dead void
log_fatal(const char *msg, ...)
{
char *fmt;
@@ -105,7 +105,7 @@ log_fatal(const char *msg, ...)
}
/* Log a critical error and die. */
-__dead void printflike1
+__dead void
log_fatalx(const char *msg, ...)
{
char *fmt;
diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c
index b67d94ad703..5562002d490 100644
--- a/usr.bin/tmux/options.c
+++ b/usr.bin/tmux/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.10 2014/01/28 23:07:09 nicm Exp $ */
+/* $OpenBSD: options.c,v 1.11 2014/10/20 23:57:14 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -99,7 +99,7 @@ options_remove(struct options *oo, const char *name)
free(o);
}
-struct options_entry *printflike3
+struct options_entry *
options_set_string(struct options *oo, const char *name, const char *fmt, ...)
{
struct options_entry *o;
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index e9d52c3f88b..b103508a4d8 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.70 2014/10/02 08:36:26 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.71 2014/10/20 23:57:14 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -25,13 +25,13 @@
void screen_write_initctx(struct screen_write_ctx *, struct tty_ctx *, int);
void screen_write_overwrite(struct screen_write_ctx *, u_int);
-int screen_write_combine(
- struct screen_write_ctx *, const struct utf8_data *);
+int screen_write_combine(struct screen_write_ctx *,
+ const struct utf8_data *);
/* Initialise writing with a window. */
void
-screen_write_start(
- struct screen_write_ctx *ctx, struct window_pane *wp, struct screen *s)
+screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp,
+ struct screen *s)
{
ctx->wp = wp;
if (wp != NULL && s == NULL)
@@ -73,7 +73,7 @@ screen_write_putc(struct screen_write_ctx *ctx, struct grid_cell *gc,
}
/* Calculate string length, with embedded formatting. */
-size_t printflike2
+size_t
screen_write_cstrlen(int utf8flag, const char *fmt, ...)
{
va_list ap;
@@ -108,7 +108,7 @@ screen_write_cstrlen(int utf8flag, const char *fmt, ...)
}
/* Calculate string length. */
-size_t printflike2
+size_t
screen_write_strlen(int utf8flag, const char *fmt, ...)
{
va_list ap;
@@ -145,9 +145,9 @@ screen_write_strlen(int utf8flag, const char *fmt, ...)
}
/* Write simple string (no UTF-8 or maximum length). */
-void printflike3
-screen_write_puts(
- struct screen_write_ctx *ctx, struct grid_cell *gc, const char *fmt, ...)
+void
+screen_write_puts(struct screen_write_ctx *ctx, struct grid_cell *gc,
+ const char *fmt, ...)
{
va_list ap;
@@ -157,9 +157,9 @@ screen_write_puts(
}
/* Write string with length limit (-1 for unlimited). */
-void printflike5
-screen_write_nputs(struct screen_write_ctx *ctx,
- ssize_t maxlen, struct grid_cell *gc, int utf8flag, const char *fmt, ...)
+void
+screen_write_nputs(struct screen_write_ctx *ctx, ssize_t maxlen,
+ struct grid_cell *gc, int utf8flag, const char *fmt, ...)
{
va_list ap;
@@ -221,7 +221,7 @@ screen_write_vnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
}
/* Write string, similar to nputs, but with embedded formatting (#[]). */
-void printflike5
+void
screen_write_cnputs(struct screen_write_ctx *ctx,
ssize_t maxlen, struct grid_cell *gc, int utf8flag, const char *fmt, ...)
{
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index ab3f07657b8..08a4739f391 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.116 2014/10/08 17:35:58 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.117 2014/10/20 23:57:14 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -651,7 +651,7 @@ status_print(
}
/* Set a status line message. */
-void printflike2
+void
status_message_set(struct client *c, const char *fmt, ...)
{
struct timeval tv;
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 959fa9fd279..26902a85610 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.475 2014/10/20 23:35:28 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.476 2014/10/20 23:57:14 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -69,11 +69,7 @@ extern char **environ;
#define unused __attribute__ ((unused))
/* Attribute to make gcc check printf-like arguments. */
-#define printflike1 __attribute__ ((format (printf, 1, 2)))
-#define printflike2 __attribute__ ((format (printf, 2, 3)))
-#define printflike3 __attribute__ ((format (printf, 3, 4)))
-#define printflike4 __attribute__ ((format (printf, 4, 5)))
-#define printflike5 __attribute__ ((format (printf, 5, 6)))
+#define printflike(a, b) __attribute__ ((format (printf, a, b)))
/* Number of items in array. */
#ifndef nitems
@@ -1515,8 +1511,8 @@ int format_cmp(struct format_entry *, struct format_entry *);
RB_PROTOTYPE(format_tree, format_entry, entry, format_cmp);
struct format_tree *format_create(void);
void format_free(struct format_tree *);
-void printflike3 format_add(struct format_tree *, const char *, const char *,
- ...);
+void printflike(3, 4) format_add(struct format_tree *, const char *,
+ const char *, ...);
const char *format_find(struct format_tree *, const char *);
char *format_expand(struct format_tree *, const char *);
void format_session(struct format_tree *, struct session *);
@@ -1569,7 +1565,7 @@ void options_free(struct options *);
struct options_entry *options_find1(struct options *, const char *);
struct options_entry *options_find(struct options *, const char *);
void options_remove(struct options *, const char *);
-struct options_entry *printflike3 options_set_string(struct options *,
+struct options_entry *printflike(3, 4) options_set_string(struct options *,
const char *, const char *, ...);
char *options_get_string(struct options *, const char *);
struct options_entry *options_set_number(struct options *, const char *,
@@ -1836,8 +1832,8 @@ size_t cmd_list_print(struct cmd_list *, char *, size_t);
/* cmd-queue.c */
struct cmd_q *cmdq_new(struct client *);
int cmdq_free(struct cmd_q *);
-void printflike2 cmdq_print(struct cmd_q *, const char *, ...);
-void printflike2 cmdq_error(struct cmd_q *, const char *, ...);
+void printflike(2, 3) cmdq_print(struct cmd_q *, const char *, ...);
+void printflike(2, 3) cmdq_error(struct cmd_q *, const char *, ...);
int cmdq_guard(struct cmd_q *, const char *, int);
void cmdq_run(struct cmd_q *, struct cmd_list *);
void cmdq_append(struct cmd_q *, struct cmd_list *);
@@ -1932,9 +1928,9 @@ void status_free_jobs(struct status_out_tree *);
void status_update_jobs(struct client *);
void status_set_window_at(struct client *, u_int);
int status_redraw(struct client *);
-char *status_replace(struct client *, struct session *,
- struct winlink *, struct window_pane *, const char *, time_t, int);
-void printflike2 status_message_set(struct client *, const char *, ...);
+char *status_replace(struct client *, struct session *, struct winlink *,
+ struct window_pane *, const char *, time_t, int);
+void printflike(2, 3) status_message_set(struct client *, const char *, ...);
void status_message_clear(struct client *);
int status_message_redraw(struct client *);
void status_prompt_set(struct client *, const char *, const char *,
@@ -2024,13 +2020,13 @@ void screen_write_start(
struct screen_write_ctx *, struct window_pane *, struct screen *);
void screen_write_stop(struct screen_write_ctx *);
void screen_write_reset(struct screen_write_ctx *);
-size_t printflike2 screen_write_cstrlen(int, const char *, ...);
-void printflike5 screen_write_cnputs(struct screen_write_ctx *,
+size_t printflike(2, 3) screen_write_cstrlen(int, const char *, ...);
+void printflike(5, 6) screen_write_cnputs(struct screen_write_ctx *,
ssize_t, struct grid_cell *, int, const char *, ...);
-size_t printflike2 screen_write_strlen(int, const char *, ...);
-void printflike3 screen_write_puts(struct screen_write_ctx *,
+size_t printflike(2, 3) screen_write_strlen(int, const char *, ...);
+void printflike(3, 4) screen_write_puts(struct screen_write_ctx *,
struct grid_cell *, const char *, ...);
-void printflike5 screen_write_nputs(struct screen_write_ctx *,
+void printflike(5, 6) screen_write_nputs(struct screen_write_ctx *,
ssize_t, struct grid_cell *, int, const char *, ...);
void screen_write_vnputs(struct screen_write_ctx *,
ssize_t, struct grid_cell *, int, const char *, va_list);
@@ -2214,7 +2210,7 @@ extern const char window_clock_table[14][5][5];
extern const struct window_mode window_copy_mode;
void window_copy_init_from_pane(struct window_pane *);
void window_copy_init_for_output(struct window_pane *);
-void printflike2 window_copy_add(struct window_pane *, const char *, ...);
+void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...);
void window_copy_vadd(struct window_pane *, const char *, va_list);
void window_copy_pageup(struct window_pane *);
@@ -2253,7 +2249,7 @@ void clear_signals(int);
/* control.c */
void control_callback(struct client *, int, void *);
-void printflike2 control_write(struct client *, const char *, ...);
+void printflike(2, 3) control_write(struct client *, const char *, ...);
void control_write_buffer(struct client *, struct evbuffer *);
/* control-notify.c */
@@ -2324,9 +2320,9 @@ char *get_proc_name(int, char *);
/* log.c */
void log_open(const char *);
void log_close(void);
-void printflike1 log_debug(const char *, ...);
-__dead void printflike1 log_fatal(const char *, ...);
-__dead void printflike1 log_fatalx(const char *, ...);
+void printflike(1, 2) log_debug(const char *, ...);
+__dead void printflike(1, 2) log_fatal(const char *, ...);
+__dead void printflike(1, 2) log_fatalx(const char *, ...);
/* xmalloc.c */
char *xstrdup(const char *);
@@ -2334,9 +2330,9 @@ void *xcalloc(size_t, size_t);
void *xmalloc(size_t);
void *xrealloc(void *, size_t);
void *xreallocarray(void *, size_t, size_t);
-int printflike2 xasprintf(char **, const char *, ...);
+int printflike(2, 3) xasprintf(char **, const char *, ...);
int xvasprintf(char **, const char *, va_list);
-int printflike3 xsnprintf(char *, size_t, const char *, ...);
+int printflike(3, 4) xsnprintf(char *, size_t, const char *, ...);
int xvsnprintf(char *, size_t, const char *, va_list);
/* style.c */
diff --git a/usr.bin/tmux/xmalloc.c b/usr.bin/tmux/xmalloc.c
index d64263cce78..b9fe9c7caad 100644
--- a/usr.bin/tmux/xmalloc.c
+++ b/usr.bin/tmux/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.6 2014/10/20 23:27:14 nicm Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.7 2014/10/20 23:57:14 nicm Exp $ */
/*
* Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -94,7 +94,7 @@ xreallocarray(void *oldptr, size_t nmemb, size_t size)
return (newptr);
}
-int printflike2
+int
xasprintf(char **ret, const char *fmt, ...)
{
va_list ap;
@@ -119,7 +119,7 @@ xvasprintf(char **ret, const char *fmt, va_list ap)
return (i);
}
-int printflike3
+int
xsnprintf(char *buf, size_t len, const char *fmt, ...)
{
va_list ap;