From nobody Fri Apr 26 08:25:09 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1555061171; cv=none; d=zoho.com; s=zohoarc; b=TWBoSRsN9AfelgpIpZNBUs4E/+UduStsozr3jAJ+Jdy/LLENzjpPbBJ0/l7RBd0iaY4NVGVm/0pFkGP75mNLz7HN58+aXxUwhjjD6vnl9dCwwAVC3DG/l9zLnVYBNwZPbdk99DG+I3j1ykkfn6LahLkRBC/Y6PeqrRohYy8F1Cg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555061171; 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=MUkhAReuFsvuNmR1su511tOqODWv3rI5oxdaHVgLpg4=; b=aHqWgQoseYENSeVIYumXTzxVWUzA5Wm4oDJ+Br5jtWRhRkK7pDl4UEfjk4Z6pSwk32uJubu01MNpY6CP3nKBGu9ddD2JRWSQnGkz4lHvsixPBMX18ON6LC3BmCMDAL+DB8ux7j2LucpYDnORQ5MSzQmT6C4QnE3sBO1/SwtqGrE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1555061171817900.7213715888147; Fri, 12 Apr 2019 02:26:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58DA7309EA78; Fri, 12 Apr 2019 09:26:09 +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 B8B8461102; Fri, 12 Apr 2019 09:26:08 +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 95C2C181AC44; Fri, 12 Apr 2019 09:26:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3C9Q7ju024198 for ; Fri, 12 Apr 2019 05:26:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12B725D9CC; Fri, 12 Apr 2019 09:26:07 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F6495D9CD for ; Fri, 12 Apr 2019 09:26:04 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Fri, 12 Apr 2019 11:25:36 +0200 Message-Id: <318fd3b76a045dc9ea662efbe9828b9559cd2575.1555061088.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] lib: Don't use virReportSystemError() if virCommandRun() fails 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 12 Apr 2019 09:26:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Firstly, virCommandRun() does report an error on failure (which in most cases is more accurate than what we overwrite it with). Secondly, usually errno is not set (or gets overwritten in the cleanup code) which makes virReportSystemError() report useless error messages. Drop all virReportSystemError() calls in cases like this (I've found three occurrences). Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- I was under impression that I've sent this one earlier. Well, maybe I did not. src/storage/storage_backend_fs.c | 7 +------ src/util/virdnsmasq.c | 10 ++-------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 97148acebe..ae4e9a03a3 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -425,13 +425,8 @@ virStorageBackendExecuteMKFS(const char *device, =20 virCommandAddArg(cmd, device); =20 - if (virCommandRun(cmd, NULL) < 0) { - virReportSystemError(errno, - _("Failed to make filesystem of " - "type '%s' on device '%s'"), - format, device); + if (virCommandRun(cmd, NULL) < 0) return -1; - } =20 return 0; } diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 550f3179ae..42f62682c4 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -751,22 +751,16 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool = force) virCommandSetOutputBuffer(cmd, &version); virCommandAddEnvPassCommon(cmd); virCommandClearCaps(cmd); - if (virCommandRun(cmd, NULL) < 0) { - virReportSystemError(errno, _("failed to run '%s --version': %s"), - caps->binaryPath, version); + if (virCommandRun(cmd, NULL) < 0) goto cleanup; - } virCommandFree(cmd); =20 cmd =3D virCommandNewArgList(caps->binaryPath, "--help", NULL); virCommandSetOutputBuffer(cmd, &help); virCommandAddEnvPassCommon(cmd); virCommandClearCaps(cmd); - if (virCommandRun(cmd, NULL) < 0) { - virReportSystemError(errno, _("failed to run '%s --help': %s"), - caps->binaryPath, help); + if (virCommandRun(cmd, NULL) < 0) goto cleanup; - } =20 if (virAsprintf(&complete, "%s\n%s", version, help) < 0) goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list