From nobody Mon May 6 20:05:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1561043559; cv=none; d=zoho.com; s=zohoarc; b=nGGJrhuAYV7IajK3gDHF4Z0eKmovMIfanS3CogZce1D3nwk0Be53lcPHOlyI+/uDOfZrhJ02tFFR68LSejD+qJVHZGMs54lYBrgLvDiqkkDs0CdFO226SipUkLpVf8gl9R8mRwlyaokviwbnUI1OwUSUW27ZvMCNm8gL00NiUgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561043559; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=zLKvrq4/PDnXPHi9xPcxJ2sJNwIg98oSBdfva+FTiL4=; b=UaGgdDlijjA3asy3aOxi/OhRWGElB+90k2CINZCtf9G3mC3T55h1hXg/v5IIKsk6F3RZ54TiHyyy/LL3gS7f5FNJKQQbaz9ObJ/fbxTAsOHrTuiFMYV+Vmuj5hcS5JbJ4Cc4t6R4rw0Y6FFEh38uOIjnqiK3tHGfTwnwVvM3rrs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156104355971070.97174117481802; Thu, 20 Jun 2019 08:12:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49D1D308793B; Thu, 20 Jun 2019 15:12:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22E965D9E5; Thu, 20 Jun 2019 15:12:19 +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 D6E9D206D3; Thu, 20 Jun 2019 15:12:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5KFCDhX016708 for ; Thu, 20 Jun 2019 11:12:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id E70BD1972E; Thu, 20 Jun 2019 15:12:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E154C19722 for ; Thu, 20 Jun 2019 15:12:11 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C699D309264C for ; Thu, 20 Jun 2019 15:12:02 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id c6so3576229wml.0 for ; Thu, 20 Jun 2019 08:12:02 -0700 (PDT) Received: from archpc.localdomain (x8d1ee222.agdsn.tu-dresden.de. [141.30.226.34]) by smtp.gmail.com with ESMTPSA id x6sm25477855wru.0.2019.06.20.08.11.59 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 08:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZeU0kt6kJcEMJE4VWrrTbtKO3v81htf958i4Y0Q6m/g=; b=kjE4Kr9zzGfiKDJISKab18h3NEFYJSQdJ91M8VZnXbbTnvDAy5tdaRGsJpr1mD85hv 36AyuGL3K2Fpyd12sDtgiS8X6nRHwaxVM0hffdma59lVO1/BDC3cY6YzR9gij2RihTFg U0sky9x2LucDuqsYTkq8InMe1/vw7EDBIA+kojmB7DCMVGsZcNgunX+ziGER7orl0oU5 McJjCTyZ0BXxkZQFbwwZ46qY0QkTr8YkLyfA4DEIbpYsyDPyms/BENa72wIsdwoIh4Xt OQJ9wIK3XuzOqUKHOZdcihgyCNYxJSppLxlZIh2ThmPLF3gaZHnkEja7QuCJrz8tMGjL FtgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZeU0kt6kJcEMJE4VWrrTbtKO3v81htf958i4Y0Q6m/g=; b=uJtci1RJgC3+6qTo3xXpkc0fzqwyKjhNDy1JNQGTIAgug+9zf8gGLY9ZjbeWnOYJVS GxZ60ljZOHGuP3VTgFZ9j7Daeq8DQO/SUIRca22CGIj6Koly/9bLHpTMNP9PjUZBjSXP EgYm2BOy/SSutdRh32ErmgX86I2Rb/BdsnAZRHOJtmpsPYoGiVgnZ4FfMZXeF9PkASnK bxPhSfEoJC8n0v1ASbwjLf8sqFYPaI1+3P4HOLBfKNFiALV8oSi5wIYP0/e5FA09I7AY N1mOwm+EYadyr7NEcglddMegCfNu8Rky/cz674CCp86Z+c4FbcZKAjJPuAYNLzQ2Juwv z8eA== X-Gm-Message-State: APjAAAX7YpIN5tZoODBIvk5aRrk7EytHlZUWfRnRBdUJlCj7rachnGv2 bfoqlzHvI6/4gMnirDwm5HlURhQA3rVXKw== X-Google-Smtp-Source: APXvYqyV7A6AMFuVovtuCNE3NWV9OdVKPXSfRt+03Sat/5bU9nkPLixgZp1XqKu06xedsBD1xdYCRw== X-Received: by 2002:a1c:9dc5:: with SMTP id g188mr84641wme.93.1561043521035; Thu, 20 Jun 2019 08:12:01 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Thu, 20 Jun 2019 17:11:57 +0200 Message-Id: <20190620151157.1171-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 20 Jun 2019 15:12:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 20 Jun 2019 15:12:03 +0000 (UTC) for IP:'209.85.128.67' DOMAIN:'mail-wm1-f67.google.com' HELO:'mail-wm1-f67.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.128.67 mail-wm1-f67.google.com 209.85.128.67 mail-wm1-f67.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] test_driver: fix some bugs on testDomainGetDiskErrors 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 20 Jun 2019 15:12:38 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The current implementation has the following bugs: - the vm variable is accessed after calling virDomainObjEndAPI on it - if VIR_STRDUP fails and we jump to the cleanup section, we're calling VIR_FREE on pointers for which we haven't allocated memory - the error type VIR_DOMAIN_DISK_ERROR_NONE is used which contradicts the documentation of the API that says that disks with no errors are not reported This patch fixes all of them and additionally reports errors only for every second disk (instead of reporting errors for all disks) which was the initial intention. Signed-off-by: Ilias Stamatis --- src/test/test_driver.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2a0ffbc6c5..a7e40112d1 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -3246,6 +3246,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom, unsigned int flags) { virDomainObjPtr vm =3D NULL; + int n =3D 0; int ret =3D -1; size_t i; @@ -3258,12 +3259,13 @@ static int testDomainGetDiskErrors(virDomainPtr dom, goto cleanup; if (errors) { - for (i =3D 0; i < MIN(vm->def->ndisks, maxerrors); i++) { - if (VIR_STRDUP(errors[i].disk, vm->def->disks[i]->dst) < 0) + for (i =3D 1; i < vm->def->ndisks && n < maxerrors; i +=3D 2) { + if (VIR_STRDUP(errors[n].disk, vm->def->disks[i]->dst) < 0) goto cleanup; - errors[i].error =3D i % VIR_DOMAIN_DISK_ERROR_LAST; + errors[n].error =3D (n % (VIR_DOMAIN_DISK_ERROR_LAST - 1)) + 1; + n++; } - ret =3D i; + ret =3D n; } else { ret =3D vm->def->ndisks; } @@ -3271,7 +3273,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom, cleanup: virDomainObjEndAPI(&vm); if (ret < 0) { - for (i =3D 0; i < MIN(vm->def->ndisks, maxerrors); i++) + for (i =3D 0; i < n; i++) VIR_FREE(errors[i].disk); } return ret; -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list