eal: declare trace buffer at top of own block
authorAndy Green <andy@warmcat.com>
Sat, 12 May 2018 01:59:32 +0000 (09:59 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 13 May 2018 20:45:16 +0000 (22:45 +0200)
rte_dev.h:54:2:
warning: ISO C90 forbids mixed declarations and
code [-Wdeclaration-after-statement]
  char buffer[vsnprintf(NULL, 0, fmt, ap) + 1];

Fixes: b974e4a40cb5 ("ethdev: make error checking macros public")
Cc: stable@dpdk.org
Signed-off-by: Andy Green <andy@warmcat.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
lib/librte_eal/common/include/rte_dev.h

index 0955e9a..3879ff3 100644 (file)
@@ -51,15 +51,18 @@ rte_pmd_debug_trace(const char *func_name, const char *fmt, ...)
 
        va_start(ap, fmt);
 
-       char buffer[vsnprintf(NULL, 0, fmt, ap) + 1];
+       {
+               char buffer[vsnprintf(NULL, 0, fmt, ap) + 1];
 
-       va_end(ap);
+               va_end(ap);
 
-       va_start(ap, fmt);
-       vsnprintf(buffer, sizeof(buffer), fmt, ap);
-       va_end(ap);
+               va_start(ap, fmt);
+               vsnprintf(buffer, sizeof(buffer), fmt, ap);
+               va_end(ap);
 
-       rte_log(RTE_LOG_ERR, RTE_LOGTYPE_PMD, "%s: %s", func_name, buffer);
+               rte_log(RTE_LOG_ERR, RTE_LOGTYPE_PMD, "%s: %s",
+                       func_name, buffer);
+       }
 }
 
 /*