[libvirt] [PATCH v1 20/21] tests: remove unneeded cleanup labels
Ján Tomko
jtomko at redhat.com
Tue Nov 12 16:54:36 UTC 2019
On Mon, Oct 21, 2019 at 03:19:10PM -0300, Daniel Henrique Barboza wrote:
>Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
>---
> tests/commandtest.c | 17 ++++----
> tests/domainconftest.c | 5 +--
> tests/networkxml2firewalltest.c | 13 ++----
> tests/nsstest.c | 27 ++++++-------
> tests/nwfilterebiptablestest.c | 4 +-
> tests/nwfilterxml2firewalltest.c | 16 +++-----
> tests/qemuhotplugtest.c | 19 ++++-----
> tests/qemuxml2argvtest.c | 11 ++---
> tests/storagebackendsheepdogtest.c | 5 +--
> tests/virauthconfigtest.c | 11 ++---
> tests/vircgroupmock.c | 11 ++---
> tests/virendiantest.c | 58 ++++++++++++--------------
> tests/virkeycodetest.c | 14 ++-----
> tests/virmacmaptest.c | 5 +--
> tests/virnetdevtest.c | 11 ++---
> tests/virpcimock.c | 31 +++++---------
> tests/virpcitest.c | 3 +-
> tests/virpolkittest.c | 65 +++++++++---------------------
> tests/virstringtest.c | 18 +++------
> 19 files changed, 126 insertions(+), 218 deletions(-)
>
>diff --git a/tests/commandtest.c b/tests/commandtest.c
>index 6ff2039ab1..4fbbde9559 100644
>--- a/tests/commandtest.c
>+++ b/tests/commandtest.c
>@@ -949,12 +949,11 @@ test23(const void *unused G_GNUC_UNUSED)
> /* Not strictly a virCommand test, but this is the easiest place
> * to test this lower-level interface. It takes a double fork to
> * test virProcessExitWithStatus. */
>- int ret = -1;
> int status = -1;
> pid_t pid;
>
> if ((pid = virFork()) < 0)
>- goto cleanup;
>+ return -1;
> if (pid == 0) {
> if ((pid = virFork()) < 0)
> _exit(EXIT_FAILURE);
>@@ -967,14 +966,14 @@ test23(const void *unused G_GNUC_UNUSED)
> }
>
> if (virProcessWait(pid, &status, true) < 0)
>- goto cleanup;
>+ return -1;
> if (!WIFEXITED(status) || WEXITSTATUS(status) != 42) {
> printf("Unexpected status %d\n", status);
>- goto cleanup;
>+ return -1;
> }
>
> if ((pid = virFork()) < 0)
>- goto cleanup;
>+ return -1;
> if (pid == 0) {
> if ((pid = virFork()) < 0)
> _exit(EXIT_FAILURE);
>@@ -989,15 +988,13 @@ test23(const void *unused G_GNUC_UNUSED)
> }
>
> if (virProcessWait(pid, &status, true) < 0)
>- goto cleanup;
>+ return -1;
> if (!WIFSIGNALED(status) || WTERMSIG(status) != SIGKILL) {
> printf("Unexpected status %d\n", status);
>- goto cleanup;
>+ return -1;
> }
>
>- ret = 0;
>- cleanup:
>- return ret;
>+ return 0;
> }
>
> static int test25(const void *unused G_GNUC_UNUSED)
>diff --git a/tests/domainconftest.c b/tests/domainconftest.c
>index e7bdc99438..5b7bf4bbec 100644
>--- a/tests/domainconftest.c
>+++ b/tests/domainconftest.c
>@@ -83,10 +83,10 @@ mymain(void)
> int ret = 0;
>
> if ((caps = virTestGenericCapsInit()) == NULL)
>- goto cleanup;
>+ return EXIT_SUCCESS;
>
> if (!(xmlopt = virTestGenericDomainXMLConfInit()))
>- goto cleanup;
>+ return EXIT_SUCCESS;
Here I think sticking with goto and only translating 0/-1 to
EXIT_SUCCESS and EXIT_FAILURE once is more readable than copying it
everywhere.
Jano
>
> #define DO_TEST_GET_FS(fspath, expect) \
> do { \
>@@ -107,7 +107,6 @@ mymain(void)
> virObjectUnref(caps);
> virObjectUnref(xmlopt);
>
>- cleanup:
> return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
> }
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20191112/7c35d383/attachment-0001.sig>
More information about the libvir-list
mailing list