[PATCH v2 8/9] telemetry: disable json print formatting with msvc

Tyler Retzlaff roretzla at linux.microsoft.com
Tue Apr 4 22:07:26 CEST 2023


VLAs are unsafe and will never be implemented in MSVC. When compiling
with MSVC just return immediately indicating 0 output characters
formatted.

For now telemetry doesn't work on Windows, we will revisit support for
the telemetry library sometime after we establish the DPDK unit tests.

Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
---
 lib/telemetry/telemetry_json.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h
index 744bbfe..d847003 100644
--- a/lib/telemetry/telemetry_json.h
+++ b/lib/telemetry/telemetry_json.h
@@ -30,6 +30,7 @@
 static inline int
 __json_snprintf(char *buf, const int len, const char *format, ...)
 {
+#ifndef RTE_TOOLCHAIN_MSVC
 	char tmp[len];
 	va_list ap;
 	int ret;
@@ -41,6 +42,7 @@
 		strcpy(buf, tmp);
 		return ret;
 	}
+#endif
 	return 0; /* nothing written or modified */
 }
 
@@ -60,6 +62,7 @@
 static inline int
 __json_format_str(char *buf, const int len, const char *prefix, const char *str, const char *suffix)
 {
+#ifndef RTE_TOOLCHAIN_MSVC
 	char tmp[len];
 	int tmpidx = 0;
 
@@ -98,6 +101,9 @@
 
 	strcpy(buf, tmp);
 	return tmpidx;
+#else
+	return 0;
+#endif
 }
 
 /* Copies an empty array into the provided buffer. */
-- 
1.8.3.1



More information about the dev mailing list