Patchwork [5/5] Add ATTRIBUTE_PRINTF to trace_start_error

login
register
mail settings
Submitter Simon Marchi
Date June 10, 2017, 7:58 p.m.
Message ID <1497124689-11842-6-git-send-email-simon.marchi@ericsson.com>
Download mbox | patch
Permalink /patch/20909/
State New
Headers show

Comments

Simon Marchi - June 10, 2017, 7:58 p.m.
clang complains that the fmt passed to vwarning in trace_start_error is
not a literal.  This looks like a fair warning, which can be removed by
adding ATTRIBUTE_PRINTF to the declaration of trace_start_error.

gdb/ChangeLog:

	* nat/fork-inferior.h (trace_start_error): Add ATTRIBUTE_PRINTF.
---
 gdb/nat/fork-inferior.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Sergio Durigan Junior - June 14, 2017, 7:49 p.m.
On Saturday, June 10 2017, Simon Marchi wrote:

> clang complains that the fmt passed to vwarning in trace_start_error is
> not a literal.  This looks like a fair warning, which can be removed by
> adding ATTRIBUTE_PRINTF to the declaration of trace_start_error.
>
> gdb/ChangeLog:
>
> 	* nat/fork-inferior.h (trace_start_error): Add ATTRIBUTE_PRINTF.
> ---
>  gdb/nat/fork-inferior.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h
> index 10e3832..d369cff 100644
> --- a/gdb/nat/fork-inferior.h
> +++ b/gdb/nat/fork-inferior.h
> @@ -95,7 +95,7 @@ extern void gdb_flush_out_err ();
>     (i.e., when the "traceme_fun" callback is called on fork_inferior)
>     and bail out.  This function does not return.  */
>  extern void trace_start_error (const char *fmt, ...)
> -  ATTRIBUTE_NORETURN;
> +  ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
>  
>  /* Like "trace_start_error", but the error message is constructed by
>     combining STRING with the system error message for errno.  This
> -- 
> 2.7.4

Thanks, this looks good to me.

Patch

diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h
index 10e3832..d369cff 100644
--- a/gdb/nat/fork-inferior.h
+++ b/gdb/nat/fork-inferior.h
@@ -95,7 +95,7 @@  extern void gdb_flush_out_err ();
    (i.e., when the "traceme_fun" callback is called on fork_inferior)
    and bail out.  This function does not return.  */
 extern void trace_start_error (const char *fmt, ...)
-  ATTRIBUTE_NORETURN;
+  ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
 
 /* Like "trace_start_error", but the error message is constructed by
    combining STRING with the system error message for errno.  This