[dpdk-dev,v3,10/24] rte_dev.h: stack declaration at top of own basic block

Message ID 152609037252.121661.1483829650676418151.stgit@localhost.localdomain (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andy Green May 12, 2018, 1:59 a.m. UTC
  /projects/lagopus/src/dpdk/build/include/rte_dev.h:54:2:
warning: ISO C90 forbids mixed declarations and
code [-Wdeclaration-after-statement]
  char buffer[vsnprintf(NULL, 0, fmt, ap) + 1];

Signed-off-by: Andy Green <andy@warmcat.com>
---
 lib/librte_eal/common/include/rte_dev.h |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
  

Comments

Thomas Monjalon May 13, 2018, 8:41 p.m. UTC | #1
12/05/2018 03:59, Andy Green:
> /projects/lagopus/src/dpdk/build/include/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>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 0955e9adb..3879ff3ca 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -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);
+	}
 }
 
 /*