[libvirt] [PATCH 0/2] tests: fix memleak in qemumonitorjsontest

the free callback should be qemuMonitorChardevInfoFree rather than just 'free' when virHashCreate'ing the chardevInfo hash. Zhang Bo (2): qemu: make qemuMonitorChardevInfoFree non-static tests: free ChardevInfo correctly in qemumonitorjsontest src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor.h | 1 + tests/qemumonitorjsontest.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) -- 1.7.12.4

It would be used in qemumonitorjsontest, thus we make it non-static. Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com> Signed-off-by: Zhou Yimin <zhouyimin@huawei.com> --- src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 1e7d2ef..c2a9028 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2812,7 +2812,7 @@ qemuMonitorQueryRxFilter(qemuMonitorPtr mon, const char *alias, } -static void +void qemuMonitorChardevInfoFree(void *data, const void *name ATTRIBUTE_UNUSED) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index cd4cc66..ba6e4e5 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -649,6 +649,7 @@ struct _qemuMonitorChardevInfo { char *ptyPath; virDomainChrDeviceState state; }; +void qemuMonitorChardevInfoFree(void *data, const void *name); int qemuMonitorGetChardevInfo(qemuMonitorPtr mon, virHashTablePtr *retinfo); -- 1.7.12.4

the free callback should be qemuMonitorChardevInfoFree rather than just 'free' when virHashCreate'ing the chardevInfo hash. Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com> Signed-off-by: Zhou Yimin <zhouyimin@huawei.com> --- tests/qemumonitorjsontest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index f729c7c..9296668 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -28,7 +28,7 @@ #include "virerror.h" #include "virstring.h" #include "cpu/cpu.h" - +#include "qemu/qemu_monitor.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -1782,7 +1782,7 @@ testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(const void *data) if (!test) return -1; - if (!(info = virHashCreate(32, (virHashDataFree) free)) || + if (!(info = virHashCreate(32, qemuMonitorChardevInfoFree)) || !(expectedInfo = virHashCreate(32, NULL))) goto cleanup; -- 1.7.12.4

On 28.04.2015 03:16, Zhang Bo wrote:
the free callback should be qemuMonitorChardevInfoFree rather than just 'free' when virHashCreate'ing the chardevInfo hash.
Zhang Bo (2): qemu: make qemuMonitorChardevInfoFree non-static tests: free ChardevInfo correctly in qemumonitorjsontest
src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor.h | 1 + tests/qemumonitorjsontest.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-)
ACKed and pushed. Michal
participants (2)
-
Michal Privoznik
-
Zhang Bo