This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[v2,2/2] Function attributes: use shorter versions of the format macros
- From: Cleber Rosa <crosa at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: crosa at redhat dot com, sergiodj at redhat dot com, lmr at redhat dot com, brobecker at adacore dot com
- Date: Thu, 11 Dec 2014 15:50:40 -0300
- Subject: [v2,2/2] Function attributes: use shorter versions of the format macros
- Authentication-results: sourceware.org; auth=none
- References: <20141203103111 dot GB7899 at adacore dot com> <1418323840-2496-1-git-send-email-crosa at redhat dot com>
glibc provides a wide range of function attributes that can help GCC during
code compilation.
One step further, glibc also provides in /usr/include/ansidecl.h a generic
version of a macro called ATTRIBUTE_PRINTF, based on the format function
attribute, and others that are more specific and shorter to write, read and
grasp.
For consistency sake, let's use these shorter versions of those macros.
For more information:
* /usr/include/ansidecl.h
* https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-Wformat-2963
gdb/ChangeLog:
* ada-lang.c (lim_warning): use shorter versions of function attributes
macros.
* cli-out.c (out_field_fmt): Likewise.
* common/agent.c (debug_agent_printf): Likewise.
* common/buffer.h (buffer_xml_printf): Likewise.
* common/common-debug.h (debug_printf): Likewise.
* common/common-exceptions.h (throw_error): Likewise.
(throw_quit): Likewise.
* common/common-utils.h (xstrprintf): Likewise.
(xsnprintf): Likewise.
* common/errors.h (warning): Likewise.
(error): Likewise.
(internal_error): Likewise.
(internal_verror): Likewise.
(internal_warning): Likewise.
* complaints.h (complaint): Likewise.
(internal_complaint): Likewise.
* disasm.c (fprintf_disasm): Likewise.
(gdb_buffered_insn_length_fprintf): Likewise.
* exceptions.h (exception_fprintf): Likewise.
* language.h (range_error): Likewise.
* monitor.c (monitor_debug): Likewise.
* parser-defs.h (parser_fprintf): Likewise.
* serial.h (serial_printf): Likewise.
* ui-out.h (ui_out_field_fmt): Likewise.
(ui_out_message): Likewise.
* utils.h (query): Likewise.
(nquery): Likewise.
(yquery): Likewise.
(fprintf_filtered): Likewise.
(fprintfi_filtered): Likewise.
(printf_filtered): Likewise.
(printfi_filtered): Likewise.
(fprintf_unfiltered): Likewise.
(printf_unfiltered): Likewise.
(demangler_warning): Likewise.
gdb/gdbserver/ChangeLog:
* ax.c (ax_vdebug): use shorter versions of function attributes
macros.
* tracepoint.c (trace_vdebug): Likewise.
---
gdb/ada-lang.c | 2 +-
gdb/cli-out.c | 2 +-
gdb/common/agent.c | 2 +-
gdb/common/buffer.h | 2 +-
gdb/common/common-debug.h | 2 +-
gdb/common/common-exceptions.h | 4 ++--
gdb/common/common-utils.h | 4 ++--
gdb/common/errors.h | 8 ++++----
gdb/complaints.h | 4 ++--
gdb/disasm.c | 4 ++--
gdb/exceptions.h | 2 +-
gdb/gdbserver/ax.c | 2 +-
gdb/gdbserver/tracepoint.c | 2 +-
gdb/language.h | 2 +-
gdb/monitor.c | 2 +-
gdb/parser-defs.h | 2 +-
gdb/serial.h | 2 +-
gdb/ui-out.h | 4 ++--
gdb/utils.h | 20 ++++++++++----------
19 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3a024d9..584f1a4 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -721,7 +721,7 @@ cond_offset_target (CORE_ADDR address, long offset)
/* FIXME: cagney/2004-10-10: This function is mimicking the behavior
provided by "complaint". */
-static void lim_warning (const char *format, ...) ATTRIBUTE_PRINTF (1, 2);
+static void lim_warning (const char *format, ...) ATTRIBUTE_PRINTF_1;
static void
lim_warning (const char *format, ...)
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 4961d8a..9314cad 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -36,7 +36,7 @@ static void field_separator (void);
static void out_field_fmt (struct ui_out *uiout, int fldno,
const char *fldname,
- const char *format,...) ATTRIBUTE_PRINTF (4, 5);
+ const char *format,...) ATTRIBUTE_PRINTF_4;
/* The destructor. */
diff --git a/gdb/common/agent.c b/gdb/common/agent.c
index 0c3d7a3..2d9ad91 100644
--- a/gdb/common/agent.c
+++ b/gdb/common/agent.c
@@ -28,7 +28,7 @@ int debug_agent = 0;
/* A stdarg wrapper for debug_vprintf. */
-static void ATTRIBUTE_PRINTF (1, 2)
+static void ATTRIBUTE_PRINTF_1
debug_agent_printf (const char *fmt, ...)
{
va_list ap;
diff --git a/gdb/common/buffer.h b/gdb/common/buffer.h
index 1c748dd..65079e2 100644
--- a/gdb/common/buffer.h
+++ b/gdb/common/buffer.h
@@ -49,7 +49,7 @@ char* buffer_finish (struct buffer *buffer);
%x - grow an unsigned integer formatted in hexadecimal in BUFFER.
%o - grow an unsigned integer formatted in octal in BUFFER. */
void buffer_xml_printf (struct buffer *buffer, const char *format, ...)
- ATTRIBUTE_PRINTF (2, 3);
+ ATTRIBUTE_PRINTF_2;
#define buffer_grow_str(BUFFER,STRING) \
buffer_grow (BUFFER, STRING, strlen (STRING))
diff --git a/gdb/common/common-debug.h b/gdb/common/common-debug.h
index 348b0e3..99eb9ee 100644
--- a/gdb/common/common-debug.h
+++ b/gdb/common/common-debug.h
@@ -29,7 +29,7 @@ extern int show_debug_regs;
debugging output for the client. */
extern void debug_printf (const char *format, ...)
- ATTRIBUTE_PRINTF (1, 2);
+ ATTRIBUTE_PRINTF_1;
/* Print a formatted message to the appropriate channel for
debugging output for the client. This function must be
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
index 5f750c3..34396e0 100644
--- a/gdb/common/common-exceptions.h
+++ b/gdb/common/common-exceptions.h
@@ -178,8 +178,8 @@ extern void throw_verror (enum errors, const char *fmt, va_list ap)
extern void throw_vquit (const char *fmt, va_list ap)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
extern void throw_error (enum errors error, const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_2;
extern void throw_quit (const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
#endif /* COMMON_EXCEPTIONS_H */
diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h
index 67615ba..9df5d38 100644
--- a/gdb/common/common-utils.h
+++ b/gdb/common/common-utils.h
@@ -48,13 +48,13 @@ void xfree (void *);
/* Like asprintf and vasprintf, but return the string, throw an error
if no memory. */
-char *xstrprintf (const char *format, ...) ATTRIBUTE_PRINTF (1, 2);
+char *xstrprintf (const char *format, ...) ATTRIBUTE_PRINTF_1;
char *xstrvprintf (const char *format, va_list ap)
ATTRIBUTE_PRINTF (1, 0);
/* Like snprintf, but throw an error if the output buffer is too small. */
int xsnprintf (char *str, size_t size, const char *format, ...)
- ATTRIBUTE_PRINTF (3, 4);
+ ATTRIBUTE_PRINTF_3;
/* Make a copy of the string at PTR with LEN characters
(and add a null character at the end in the copy).
diff --git a/gdb/common/errors.h b/gdb/common/errors.h
index 88d77e5..fb3df0b 100644
--- a/gdb/common/errors.h
+++ b/gdb/common/errors.h
@@ -26,7 +26,7 @@
provided by the client. */
extern void warning (const char *fmt, ...)
- ATTRIBUTE_PRINTF (1, 2);
+ ATTRIBUTE_PRINTF_1;
extern void vwarning (const char *fmt, va_list args)
ATTRIBUTE_PRINTF (1, 0);
@@ -37,7 +37,7 @@ extern void vwarning (const char *fmt, va_list args)
return. The function "verror" must be provided by the client. */
extern void error (const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
extern void verror (const char *fmt, va_list args)
ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 0);
@@ -53,7 +53,7 @@ extern void verror (const char *fmt, va_list args)
extern void internal_error (const char *file, int line,
const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 4);
+ ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_3;
extern void internal_verror (const char *file, int line,
const char *fmt, va_list args)
@@ -68,7 +68,7 @@ extern void internal_verror (const char *file, int line,
extern void internal_warning (const char *file, int line,
const char *fmt, ...)
- ATTRIBUTE_PRINTF (3, 4);
+ ATTRIBUTE_PRINTF_3;
extern void internal_vwarning (const char *file, int line,
const char *fmt, va_list args)
diff --git a/gdb/complaints.h b/gdb/complaints.h
index a848144..7fc8063 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -31,11 +31,11 @@ extern struct complaints *symfile_complaints;
/* Register a complaint. */
extern void complaint (struct complaints **complaints,
const char *fmt,
- ...) ATTRIBUTE_PRINTF (2, 3);
+ ...) ATTRIBUTE_PRINTF_2;
extern void internal_complaint (struct complaints **complaints,
const char *file, int line,
const char *fmt,
- ...) ATTRIBUTE_PRINTF (4, 5);
+ ...) ATTRIBUTE_PRINTF_4;
/* Clear out / initialize all complaint counters that have ever been
incremented. If LESS_VERBOSE is 1, be less verbose about
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 52d6a0f..33c6778 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -363,7 +363,7 @@ do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout,
/* Initialize the disassemble info struct ready for the specified
stream. */
-static int ATTRIBUTE_PRINTF (2, 3)
+static int ATTRIBUTE_PRINTF_2
fprintf_disasm (void *stream, const char *format, ...)
{
va_list args;
@@ -487,7 +487,7 @@ gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR addr)
nop, we don't want to print anything, we just want to compute the
length of the insn. */
-static int ATTRIBUTE_PRINTF (2, 3)
+static int ATTRIBUTE_PRINTF_2
gdb_buffered_insn_length_fprintf (void *stream, const char *format, ...)
{
return 0;
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index f4d62a6..2465771 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -30,7 +30,7 @@ extern const struct gdb_exception exception_none;
extern void exception_print (struct ui_file *file, struct gdb_exception e);
extern void exception_fprintf (struct ui_file *file, struct gdb_exception e,
const char *prefix,
- ...) ATTRIBUTE_PRINTF (3, 4);
+ ...) ATTRIBUTE_PRINTF_3;
/* Call FUNC(UIOUT, FUNC_ARGS) but wrapped within an exception
handler. If an exception (enum return_reason) is thrown using
diff --git a/gdb/gdbserver/ax.c b/gdb/gdbserver/ax.c
index 8b28c72..f5c6179 100644
--- a/gdb/gdbserver/ax.c
+++ b/gdb/gdbserver/ax.c
@@ -22,7 +22,7 @@
#include "tracepoint.h"
#include "rsp-low.h"
-static void ax_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
+static void ax_vdebug (const char *, ...) ATTRIBUTE_PRINTF_1;
#ifdef IN_PROCESS_AGENT
int debug_agent = 0;
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index b6ab53f..278fad9 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -63,7 +63,7 @@
#ifdef IN_PROCESS_AGENT
-static void trace_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
+static void trace_vdebug (const char *, ...) ATTRIBUTE_PRINTF_1;
static void
trace_vdebug (const char *fmt, ...)
diff --git a/gdb/language.h b/gdb/language.h
index 73619ca..a4bd02f 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -477,7 +477,7 @@ extern int pointer_type (struct type *);
/* Error messages */
-extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
+extern void range_error (const char *, ...) ATTRIBUTE_PRINTF_1;
/* Data: Does this value represent "truth" to the current language? */
diff --git a/gdb/monitor.c b/gdb/monitor.c
index d9e7b0a..66e2624 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -118,7 +118,7 @@ static ptid_t monitor_ptid;
/* Monitor specific debugging information. Typically only useful to
the developer of a new monitor interface. */
-static void monitor_debug (const char *fmt, ...) ATTRIBUTE_PRINTF (1, 2);
+static void monitor_debug (const char *fmt, ...) ATTRIBUTE_PRINTF_1;
static unsigned int monitor_debug_p = 0;
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 2ba6e05..044e534 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -382,7 +382,7 @@ extern void print_subexp_standard (struct expression *, int *,
/* Function used to avoid direct calls to fprintf
in the code generated by the bison parser. */
-extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
+extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF_2;
extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
diff --git a/gdb/serial.h b/gdb/serial.h
index f4ab31e..7b01e96 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -112,7 +112,7 @@ extern int serial_write (struct serial *scb, const void *buf, size_t count);
/* Write a printf style string onto the serial port. */
extern void serial_printf (struct serial *desc,
- const char *,...) ATTRIBUTE_PRINTF (2, 3);
+ const char *,...) ATTRIBUTE_PRINTF_2;
/* Allow pending output to drain. */
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index cbd0b9b..f566dda 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -114,7 +114,7 @@ extern void ui_out_field_stream (struct ui_out *uiout, const char *fldname,
extern void ui_out_field_fmt (struct ui_out *uiout, const char *fldname,
const char *format, ...)
- ATTRIBUTE_PRINTF (3, 4);
+ ATTRIBUTE_PRINTF_3;
extern void ui_out_field_skip (struct ui_out *uiout, const char *fldname);
@@ -124,7 +124,7 @@ extern void ui_out_text (struct ui_out *uiout, const char *string);
extern void ui_out_message (struct ui_out *uiout, int verbosity,
const char *format, ...)
- ATTRIBUTE_PRINTF (3, 4);
+ ATTRIBUTE_PRINTF_3;
extern void ui_out_wrap_hint (struct ui_out *uiout, char *identstring);
diff --git a/gdb/utils.h b/gdb/utils.h
index 660b548..7293c47 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -145,9 +145,9 @@ char *ldirname (const char *filename);
struct ui_file;
-extern int query (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
-extern int nquery (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
-extern int yquery (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
+extern int query (const char *, ...) ATTRIBUTE_PRINTF_1;
+extern int nquery (const char *, ...) ATTRIBUTE_PRINTF_1;
+extern int yquery (const char *, ...) ATTRIBUTE_PRINTF_1;
extern void begin_line (void);
@@ -206,14 +206,14 @@ extern void vfprintf_filtered (struct ui_file *, const char *, va_list)
ATTRIBUTE_PRINTF (2, 0);
extern void fprintf_filtered (struct ui_file *, const char *, ...)
- ATTRIBUTE_PRINTF (2, 3);
+ ATTRIBUTE_PRINTF_2;
extern void fprintfi_filtered (int, struct ui_file *, const char *, ...)
- ATTRIBUTE_PRINTF (3, 4);
+ ATTRIBUTE_PRINTF_3;
-extern void printf_filtered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
+extern void printf_filtered (const char *, ...) ATTRIBUTE_PRINTF_1;
-extern void printfi_filtered (int, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
+extern void printfi_filtered (int, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void vprintf_unfiltered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
@@ -221,9 +221,9 @@ extern void vfprintf_unfiltered (struct ui_file *, const char *, va_list)
ATTRIBUTE_PRINTF (2, 0);
extern void fprintf_unfiltered (struct ui_file *, const char *, ...)
- ATTRIBUTE_PRINTF (2, 3);
+ ATTRIBUTE_PRINTF_2;
-extern void printf_unfiltered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
+extern void printf_unfiltered (const char *, ...) ATTRIBUTE_PRINTF_1;
extern void print_spaces (int, struct ui_file *);
@@ -290,7 +290,7 @@ extern void demangler_vwarning (const char *file, int line,
ATTRIBUTE_PRINTF (3, 0);
extern void demangler_warning (const char *file, int line,
- const char *, ...) ATTRIBUTE_PRINTF (3, 4);
+ const char *, ...) ATTRIBUTE_PRINTF_3;
/* Misc. utilities. */
--
1.9.3