|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 3/3] tools/libxenstat: fix output initialisation in parseNetDevLine()
parseNetDevLine() zeroes all the outputs it is passed before parsing the
line, but *rxPackets is zeroed twice while *rxMcast isn't zeroed at all,
so it would be left untouched for a line that doesn't parse.
Also, iface is cleared with memset(iface, 0, sizeof(*iface)), which only
covers the first byte. The function isn't told the buffer size, and an
empty string is all that's needed, so write the terminator directly.
No functional change intended: the only caller passes NULL for rxMcast.
Assisted-by: Claude-Code:claude-opus-5-5
Signed-off-by: Olivier Lambert <olivier.lambert@xxxxxxxxxx>
---
tools/libs/stat/xenstat_linux.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/libs/stat/xenstat_linux.c b/tools/libs/stat/xenstat_linux.c
index 97f7fa9f87..aebd848722 100644
--- a/tools/libs/stat/xenstat_linux.c
+++ b/tools/libs/stat/xenstat_linux.c
@@ -123,7 +123,7 @@ static int parseNetDevLine(char *line, char *iface,
unsigned long long *rxBytes,
/* Initialize all variables called has passed as non-NULL to zeros */
if (iface != NULL)
- memset(iface, 0, sizeof(*iface));
+ iface[0] = '\0';
if (rxBytes != NULL)
*rxBytes = 0;
if (rxPackets != NULL)
@@ -136,10 +136,10 @@ static int parseNetDevLine(char *line, char *iface,
unsigned long long *rxBytes,
*rxFifo = 0;
if (rxFrames != NULL)
*rxFrames = 0;
- if (rxPackets != NULL)
- *rxPackets = 0;
if (rxComp != NULL)
*rxComp = 0;
+ if (rxMcast != NULL)
+ *rxMcast = 0;
if (txBytes != NULL)
*txBytes = 0;
if (txPackets != NULL)
--
2.53.0
--
Olivier Lambert | Vates CEO
XCP-ng & Xen Orchestra - Vates solutions
Book a meeting with me: https://calrs.vates.tech/u/olivier-lambert
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |