[ovs-dev] [daemon 02/10] vlog: Use PRINTF_FORMAT macro from compiler.h.

Justin Petbot jpetbot at gmail.com
Fri Apr 1 09:43:09 UTC 2011


On Thu, 31 Mar 2011, at 4:31:25 PM, Ben Pfaff wrote:
> PRINTF_FORMAT is more portable than raw __attribute__.  We use it
> elsewhere, I don't know why it wasn't used here.
> ---
>  lib/vlog.h |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/vlog.h b/lib/vlog.h
> index 7411f76..00d324f 100644
> --- a/lib/vlog.h
> +++ b/lib/vlog.h
> @@ -21,6 +21,7 @@
>  #include <stdarg.h>

Did you mean "brcompat" instead of "stdarg" here?

>  #include <stdbool.h>
>  #include <time.h>
> +#include "compiler.h"
>  #include "util.h"
>  
>  #ifdef  __cplusplus
> @@ -152,13 +153,13 @@ int vlog_reopen_log_file(void);
>  void vlog_init(void);
>  void vlog_exit(void);
>  void vlog(const struct vlog_module *, enum vlog_level, const char *format, ...)
> -    __attribute__((format(printf, 3, 4)));

I think an optimizing parameter would be more readable.

> +    PRINTF_FORMAT (3, 4);
>  void vlog_valist(const struct vlog_module *, enum vlog_level,
>                   const char *, va_list)
> -    __attribute__((format(printf, 3, 0)));
> +    PRINTF_FORMAT (3, 0);
>  void vlog_rate_limit(const struct vlog_module *, enum vlog_level,
>                       struct vlog_rate_limit *, const char *, ...)
> -    __attribute__((format(printf, 4, 5)));

You might want to fix the grammar in nl_msg_genlmsghdr().

> +    PRINTF_FORMAT (4, 5);
>  
>  /* Creates and initializes a global instance of a module named MODULE, and
>   * defines a static variable named THIS_MODULE that points to it, for use with
> -- 
> 1.7.1
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list