[PATCH 2/2] Function attributes: use shorter versions of the format macros
Sergio Durigan Junior
sergiodj@redhat.com
Mon Dec 1 20:39:00 GMT 2014
On Monday, December 01 2014, Cleber Rosa wrote:
> For consistency sake, use the shorter versions of the function attribute
> format macros.
Thanks for the patch. It still looks good to me; let's wait for a
maintainer to reply :-).
Just a few comments about the ChangeLog entry.
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
> gdb/ChangeLog | 20 ++++++++++++++++++++
> 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/ChangeLog | 5 +++++
> 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 ++++++++++----------
> 21 files changed, 61 insertions(+), 36 deletions(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 13346fa..5aebcb0 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,23 @@
> +2014-12-01 Cleber Rosa <cleber@redhat.com>
> +
> + * ada-lang.c: use shorter versions of function attributes macros.
Capital "U" in the beginning of the sentence. You should also specify
which functions/prototypes were modified. Therefore, in this case, you
could write:
* ada-lang.c (lim_warning): Use a shorter version of the
ATTRIBUTE_PRINTF macro.
> + * cli-out.c: Likewise.
And here:
* cli-out.c (out_field_fmt): Likewise.
And so on...
Yeah, it can be a bit annoying, sorry about that :-/.
Other than that, your patch looks fine (and obvious) to me.
> + * common/agent.c: Likewise.
> + * common/buffer.h: Likewise.
> + * common/common-debug.h: Likewise.
> + * common/common-exceptions.h: Likewise.
> + * common/common-utils.h: Likewise.
> + * common/errors.h: Likewise.
> + * complaints.h: Likewise.
> + * disasm.c: Likewise.
> + * exceptions.h: Likewise.
> + * language.h: Likewise.
> + * monitor.c: Likewise.
> + * parser-defs.h: Likewise.
> + * serial.h: Likewise.
> + * ui-out.h: Likewise.
> + * utils.h: Likewise.
> +
> 2014-12-01 Simon Marchi <simon.marchi@ericsson.com>
>
> * objfiles.c (allocate_objfile): Remove duplicate comment.
> 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/ChangeLog b/gdb/gdbserver/ChangeLog
> index 0e110e7..113a1ea 100644
> --- a/gdb/gdbserver/ChangeLog
> +++ b/gdb/gdbserver/ChangeLog
> @@ -1,5 +1,10 @@
> 2014-12-01 Cleber Rosa <cleber@redhat.com>
>
> + * ax.c: use shorter versions of function attributes macros.
> + * tracepoint.c: Likewise.
> +
> +2014-12-01 Cleber Rosa <cleber@redhat.com>
> +
> * remote-utils.c: Remove unused variable.
>
> 2014-11-28 Yao Qi <yao@codesourcery.com>
> 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 1568011..175a15e 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
Thanks,
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
More information about the Gdb-patches
mailing list