From nobody Sat Feb 7 09:46:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630784319; cv=none; d=zohomail.com; s=zohoarc; b=Zl4YPpWO2gbEvkY0cZu5dle7KubkKo5tAkR9PjQQo6eH/jpoM/Q2s5Rsq3k96ZSz+l/kb11ugqnQPvFI+PMjQg6QvMPA2TvLBfVeH+U7KuqVeg7q2BBRLmVt2f2u3LSQnD+oJzaO/AIvUtywBFyD1ho+Hj6N0SDD2eee6S+JVOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630784319; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8lSpHXkvN6JDx99T9Tj9QVgKC+D1EnXHwoQuY8YUMEA=; b=NqZypbOlR7DfBt+mJm1K/RxkozrYn3GU4ZhY6HQ6ajB7h5t1z7FSKcPdrqVMlqIBrTtXVoBTZaoIY3xA56ifG1y3YkQSWUTNwJww9OqJApU6IjBczp+Z53QjM2lCbyF7Mt9tOdsnRj6UrKouDgFpffHTvoKVwgAFqXP7ldieoT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630784319667926.7104951298597; Sat, 4 Sep 2021 12:38:39 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-497-ykr8AH7zNWiaMRw3TU8r3A-1; Sat, 04 Sep 2021 15:38:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F2EBE107ACCD; Sat, 4 Sep 2021 19:38:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D739C1045D0E; Sat, 4 Sep 2021 19:38:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A0527180B44F; Sat, 4 Sep 2021 19:38:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 184JZ6tL002599 for ; Sat, 4 Sep 2021 15:35:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CAA9781ED; Sat, 4 Sep 2021 19:35:06 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C7BA77718 for ; Sat, 4 Sep 2021 19:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630784318; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8lSpHXkvN6JDx99T9Tj9QVgKC+D1EnXHwoQuY8YUMEA=; b=I4QQeC5jQyI9oHN9i64OZlpGofTsfE4owHnABwqh6z7w474bj5MWTrhA/5t5wNe3jkYM2X grusFxyjLGalSIAFWyFrncOaegRFD6VuiOUivmTj3obkSjuhSuCRceyd9dKsxk2BPD3zld Yj6NJw/1ZRjoe9a5yInUcOlZKPR09Mg= X-MC-Unique: ykr8AH7zNWiaMRw3TU8r3A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/6] tests: refactor testSELinuxLoadDef Date: Sat, 4 Sep 2021 21:34:51 +0200 Message-Id: <40ff260392ea7db66b14e7d9b6362b4682ce4dbd.1630784040.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630784320199100001 Since its introduction in commit 907a39e735d256b8428ed4c77009d1f713aea19b Add a test suite for validating SELinux labelling this function did not return NULL on OOM. Since we abort on OOM now, switch testSELinuxMungePath to void, return NULL explicitly on XML parsing failure and remove the (now pointless) cleanup label. Signed-off-by: J=C3=A1n Tomko --- tests/securityselinuxlabeltest.c | 36 +++++++++++--------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index 3d886fd827..aab1561335 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -83,16 +83,11 @@ testUserXattrEnabled(void) return ret; } =20 -static int +static void testSELinuxMungePath(char **path) { - char *tmp; - - tmp =3D g_strdup_printf("%s/securityselinuxlabeldata%s", abs_builddir,= *path); - - VIR_FREE(*path); - *path =3D tmp; - return 0; + g_free(*path); + *path =3D g_strdup_printf("%s/securityselinuxlabeldata%s", abs_builddi= r, *path); } =20 static int @@ -162,7 +157,7 @@ testSELinuxLoadFileList(const char *testname, static virDomainDef * testSELinuxLoadDef(const char *testname) { - char *xmlfile =3D NULL; + g_autofree char *xmlfile =3D NULL; virDomainDef *def =3D NULL; size_t i; =20 @@ -171,15 +166,14 @@ testSELinuxLoadDef(const char *testname) =20 if (!(def =3D virDomainDefParseFile(xmlfile, driver.xmlopt, NULL, 0))) - goto cleanup; + return NULL; =20 for (i =3D 0; i < def->ndisks; i++) { if (def->disks[i]->src->type !=3D VIR_STORAGE_TYPE_FILE && def->disks[i]->src->type !=3D VIR_STORAGE_TYPE_BLOCK) continue; =20 - if (testSELinuxMungePath(&def->disks[i]->src->path) < 0) - goto cleanup; + testSELinuxMungePath(&def->disks[i]->src->path); } =20 for (i =3D 0; i < def->nserials; i++) { @@ -190,23 +184,17 @@ testSELinuxLoadDef(const char *testname) continue; =20 if (def->serials[i]->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX)= { - if (testSELinuxMungePath(&def->serials[i]->source->data.nix.pa= th) < 0) - goto cleanup; + testSELinuxMungePath(&def->serials[i]->source->data.nix.path); } else { - if (testSELinuxMungePath(&def->serials[i]->source->data.file.p= ath) < 0) - goto cleanup; + testSELinuxMungePath(&def->serials[i]->source->data.file.path); } } =20 - if (def->os.kernel && - testSELinuxMungePath(&def->os.kernel) < 0) - goto cleanup; - if (def->os.initrd && - testSELinuxMungePath(&def->os.initrd) < 0) - goto cleanup; + if (def->os.kernel < 0) + testSELinuxMungePath(&def->os.kernel); + if (def->os.initrd < 0) + testSELinuxMungePath(&def->os.initrd); =20 - cleanup: - VIR_FREE(xmlfile); return def; } =20 --=20 2.31.1