* [PATCH for-8.1] tests/test-util-filemonitor: Avoid pointless allocations
@ 2023-07-19 15:01 Philippe Mathieu-Daudé
2023-07-19 15:39 ` Daniel P. Berrangé
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-07-19 15:01 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Thomas Huth, Philippe Mathieu-Daudé
Coverity reports few resource leaks. While they are
harmless, fix them to avoid them showing on the reports.
Reported-by: Coverity (CID 1432615: RESOURCE_LEAK)
Fixes: 4f370b1098 ("test-util-filemonitor: Skip test on non-x86 Travis containers")
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
tests/unit/test-util-filemonitor.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tests/unit/test-util-filemonitor.c b/tests/unit/test-util-filemonitor.c
index b629e10857..3ca687860d 100644
--- a/tests/unit/test-util-filemonitor.c
+++ b/tests/unit/test-util-filemonitor.c
@@ -398,7 +398,7 @@ test_file_monitor_events(void)
};
Error *local_err = NULL;
GError *gerr = NULL;
- QFileMonitor *mon = qemu_file_monitor_new(&local_err);
+ QFileMonitor *mon;
QemuThread th;
GTimer *timer;
gchar *dir = NULL;
@@ -407,12 +407,9 @@ test_file_monitor_events(void)
char *pathsrc = NULL;
char *pathdst = NULL;
QFileMonitorTestData data;
- GHashTable *ids = g_hash_table_new(g_int64_hash, g_int64_equal);
+ GHashTable *ids;
char *travis_arch;
- qemu_mutex_init(&data.lock);
- data.records = NULL;
-
/*
* This test does not work on Travis LXD containers since some
* syscalls are blocked in that environment.
@@ -423,6 +420,12 @@ test_file_monitor_events(void)
return;
}
+ mon = qemu_file_monitor_new(&local_err);
+ ids = g_hash_table_new(g_int64_hash, g_int64_equal);
+
+ qemu_mutex_init(&data.lock);
+ data.records = NULL;
+
/*
* The file monitor needs the main loop running in
* order to receive events from inotify. We must
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH for-8.1] tests/test-util-filemonitor: Avoid pointless allocations
2023-07-19 15:01 [PATCH for-8.1] tests/test-util-filemonitor: Avoid pointless allocations Philippe Mathieu-Daudé
@ 2023-07-19 15:39 ` Daniel P. Berrangé
2023-07-19 15:49 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Daniel P. Berrangé @ 2023-07-19 15:39 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, Thomas Huth
On Wed, Jul 19, 2023 at 05:01:03PM +0200, Philippe Mathieu-Daudé wrote:
> Coverity reports few resource leaks. While they are
> harmless, fix them to avoid them showing on the reports.
>
> Reported-by: Coverity (CID 1432615: RESOURCE_LEAK)
> Fixes: 4f370b1098 ("test-util-filemonitor: Skip test on non-x86 Travis containers")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> tests/unit/test-util-filemonitor.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/tests/unit/test-util-filemonitor.c b/tests/unit/test-util-filemonitor.c
> index b629e10857..3ca687860d 100644
> --- a/tests/unit/test-util-filemonitor.c
> +++ b/tests/unit/test-util-filemonitor.c
> @@ -398,7 +398,7 @@ test_file_monitor_events(void)
> };
> Error *local_err = NULL;
> GError *gerr = NULL;
> - QFileMonitor *mon = qemu_file_monitor_new(&local_err);
> + QFileMonitor *mon;
> QemuThread th;
> GTimer *timer;
> gchar *dir = NULL;
> @@ -407,12 +407,9 @@ test_file_monitor_events(void)
> char *pathsrc = NULL;
> char *pathdst = NULL;
> QFileMonitorTestData data;
> - GHashTable *ids = g_hash_table_new(g_int64_hash, g_int64_equal);
> + GHashTable *ids;
> char *travis_arch;
>
> - qemu_mutex_init(&data.lock);
> - data.records = NULL;
> -
> /*
> * This test does not work on Travis LXD containers since some
> * syscalls are blocked in that environment.
Right here is logic that checks the TRAVIS_ARCH env variable.
IMHO this should just be moved out into the main() method, so
we don't even start test when under Travis. Just make the whole
program exits with a skip status on travis.
> @@ -423,6 +420,12 @@ test_file_monitor_events(void)
> return;
> }
>
> + mon = qemu_file_monitor_new(&local_err);
> + ids = g_hash_table_new(g_int64_hash, g_int64_equal);
> +
> + qemu_mutex_init(&data.lock);
> + data.records = NULL;
> +
> /*
> * The file monitor needs the main loop running in
> * order to receive events from inotify. We must
> --
> 2.38.1
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH for-8.1] tests/test-util-filemonitor: Avoid pointless allocations
2023-07-19 15:39 ` Daniel P. Berrangé
@ 2023-07-19 15:49 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-07-19 15:49 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-devel, Thomas Huth
On 19/7/23 17:39, Daniel P. Berrangé wrote:
> On Wed, Jul 19, 2023 at 05:01:03PM +0200, Philippe Mathieu-Daudé wrote:
>> Coverity reports few resource leaks. While they are
>> harmless, fix them to avoid them showing on the reports.
>>
>> Reported-by: Coverity (CID 1432615: RESOURCE_LEAK)
>> Fixes: 4f370b1098 ("test-util-filemonitor: Skip test on non-x86 Travis containers")
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> tests/unit/test-util-filemonitor.c | 13 ++++++++-----
>> 1 file changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/tests/unit/test-util-filemonitor.c b/tests/unit/test-util-filemonitor.c
>> index b629e10857..3ca687860d 100644
>> --- a/tests/unit/test-util-filemonitor.c
>> +++ b/tests/unit/test-util-filemonitor.c
>> @@ -398,7 +398,7 @@ test_file_monitor_events(void)
>> /*
>> * This test does not work on Travis LXD containers since some
>> * syscalls are blocked in that environment.
>
> Right here is logic that checks the TRAVIS_ARCH env variable.
>
> IMHO this should just be moved out into the main() method, so
> we don't even start test when under Travis. Just make the whole
> program exits with a skip status on travis.
Clever eh :)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-19 15:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-19 15:01 [PATCH for-8.1] tests/test-util-filemonitor: Avoid pointless allocations Philippe Mathieu-Daudé
2023-07-19 15:39 ` Daniel P. Berrangé
2023-07-19 15:49 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).