mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
sockettest: testMaskNetwork: use g_auto
This has the added benefit of 'gotnet' only being freed after
it was possibly used in the output string.
../src/internal.h:519:27: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
519 | # define fprintf(fh, ...) g_fprintf(fh, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
../tests/sockettest.c:194:9: note: in expansion of macro ‘fprintf’
194 | fprintf(stderr, "Expected %s, got %s\n", networkstr, gotnet);
| ^~~~~~~
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Jaroslav Suchanek <jsuchane@redhat.com>
Fixes: ba08c5932e
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
8ce8d591b0
commit
2bc827a949
@ -175,7 +175,7 @@ static int testMaskNetwork(const char *addrstr,
|
|||||||
{
|
{
|
||||||
virSocketAddr addr;
|
virSocketAddr addr;
|
||||||
virSocketAddr network;
|
virSocketAddr network;
|
||||||
char *gotnet = NULL;
|
g_autofree char *gotnet = NULL;
|
||||||
|
|
||||||
/* Intentionally fill with garbage */
|
/* Intentionally fill with garbage */
|
||||||
memset(&network, 1, sizeof(network));
|
memset(&network, 1, sizeof(network));
|
||||||
@ -190,11 +190,9 @@ static int testMaskNetwork(const char *addrstr,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (STRNEQ(networkstr, gotnet)) {
|
if (STRNEQ(networkstr, gotnet)) {
|
||||||
VIR_FREE(gotnet);
|
|
||||||
fprintf(stderr, "Expected %s, got %s\n", networkstr, gotnet);
|
fprintf(stderr, "Expected %s, got %s\n", networkstr, gotnet);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_FREE(gotnet);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user