diff mbox

[v3,for-4.7,10/16] libxl: add the printf-like attributes to a couple of functions

Message ID 1461755514-23754-11-git-send-email-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roger Pau Monné April 27, 2016, 11:11 a.m. UTC
Or else clang complains with:

error: format string is not a string literal

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl_internal.h    | 4 ++--
 tools/libxl/libxl_save_helper.c | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Wei Liu April 27, 2016, 11:25 a.m. UTC | #1
On Wed, Apr 27, 2016 at 01:11:48PM +0200, Roger Pau Monne wrote:
> Or else clang complains with:
> 
> error: format string is not a string literal
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libxl/libxl_internal.h    | 4 ++--
>  tools/libxl/libxl_save_helper.c | 1 +
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 8e2cf3e..662d01a 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -636,7 +636,7 @@ _hidden void *libxl__realloc(libxl__gc *gc_opt, void *ptr, size_t new_size) NN1;
>  /* print @fmt into an allocated string large enoughto contain the result.
>   * (similar to gc'd asprintf(3)). */
>  _hidden char *libxl__sprintf(libxl__gc *gc_opt, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3) NN1;
> -_hidden char *libxl__vsprintf(libxl__gc *gc, const char *format, va_list ap);
> +_hidden char *libxl__vsprintf(libxl__gc *gc, const char *format, va_list ap) PRINTF_ATTRIBUTE(2, 0);
>  /* duplicate the string @c (similar to a gc'd strdup(3)). */
>  _hidden char *libxl__strdup(libxl__gc *gc_opt,
>                              const char *c /* may be NULL */) NN1;
> @@ -709,7 +709,7 @@ _hidden char *libxl__xs_libxl_path(libxl__gc *gc, uint32_t domid);
>   */
>  
>  int libxl__xs_vprintf(libxl__gc *gc, xs_transaction_t t,
> -                      const char *path, const char *fmt, va_list ap);
> +                      const char *path, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(4, 0);
>  int libxl__xs_printf(libxl__gc *gc, xs_transaction_t t,
>                       const char *path, const char *fmt, ...) PRINTF_ATTRIBUTE(4, 5);
>  
> diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c
> index 5fe642a..d3def6b 100644
> --- a/tools/libxl/libxl_save_helper.c
> +++ b/tools/libxl/libxl_save_helper.c
> @@ -52,6 +52,7 @@
>  
>  /*----- logger -----*/
>  
> +__attribute__((format(printf, 5, 0)))
>  static void tellparent_vmessage(xentoollog_logger *logger_in,
>                                  xentoollog_level level,
>                                  int errnoval,
> -- 
> 2.6.4 (Apple Git-63)
>
diff mbox

Patch

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 8e2cf3e..662d01a 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -636,7 +636,7 @@  _hidden void *libxl__realloc(libxl__gc *gc_opt, void *ptr, size_t new_size) NN1;
 /* print @fmt into an allocated string large enoughto contain the result.
  * (similar to gc'd asprintf(3)). */
 _hidden char *libxl__sprintf(libxl__gc *gc_opt, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3) NN1;
-_hidden char *libxl__vsprintf(libxl__gc *gc, const char *format, va_list ap);
+_hidden char *libxl__vsprintf(libxl__gc *gc, const char *format, va_list ap) PRINTF_ATTRIBUTE(2, 0);
 /* duplicate the string @c (similar to a gc'd strdup(3)). */
 _hidden char *libxl__strdup(libxl__gc *gc_opt,
                             const char *c /* may be NULL */) NN1;
@@ -709,7 +709,7 @@  _hidden char *libxl__xs_libxl_path(libxl__gc *gc, uint32_t domid);
  */
 
 int libxl__xs_vprintf(libxl__gc *gc, xs_transaction_t t,
-                      const char *path, const char *fmt, va_list ap);
+                      const char *path, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(4, 0);
 int libxl__xs_printf(libxl__gc *gc, xs_transaction_t t,
                      const char *path, const char *fmt, ...) PRINTF_ATTRIBUTE(4, 5);
 
diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c
index 5fe642a..d3def6b 100644
--- a/tools/libxl/libxl_save_helper.c
+++ b/tools/libxl/libxl_save_helper.c
@@ -52,6 +52,7 @@ 
 
 /*----- logger -----*/
 
+__attribute__((format(printf, 5, 0)))
 static void tellparent_vmessage(xentoollog_logger *logger_in,
                                 xentoollog_level level,
                                 int errnoval,