From nobody Mon May 13 04:08:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1649083962; cv=none; d=zohomail.com; s=zohoarc; b=WqVyA9mL5h3yKPXcfJ/4iQSvrEHd1oc2Imvr6h6StQ7d7Hlvy40+GqHM89x+iNwdQaXhGCQhRYjHIaTS7eFrHVXsrZJJGth4f9I57tmocJ7V0j1gTQFEVNw22FxoTmtDftrAdX5qw92jG8gPwoEvaEZXNh67djQx4N8EOTeEuTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649083962; 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; bh=zaLtEOKSQUUIehndSfuuig3TK5BTxQLkS3JxM+NxH/U=; b=gVF8mMoa870MtLSFlvY8PctxxVZ89V4Bhn7zxrUz5jV4lD3WCpTsZg/ggiULT4g120YZl3jTHp1soMVoRvqJaBeMO95IJ7FzntATJ6gyQoQIqnWKagKQQGzGJW/psMNeug++GyqjhDt52WE/yY567XeacUS8Fx2dfnDuKZ+qMIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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 [170.10.129.124]) by mx.zohomail.com with SMTPS id 1649083962902460.993688914121; Mon, 4 Apr 2022 07:52:42 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-253-b3jKap4QNdSxdmb3BqF2sg-1; Mon, 04 Apr 2022 10:52:39 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B00D61C05EAC; Mon, 4 Apr 2022 14:52:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E3D046A0DC; Mon, 4 Apr 2022 14:52:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 932B019451F2; Mon, 4 Apr 2022 14:52:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 28C0F19451EF for ; Mon, 4 Apr 2022 14:52:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CF921C44B1C; Mon, 4 Apr 2022 14:52:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 783B5C2813B for ; Mon, 4 Apr 2022 14:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649083961; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zaLtEOKSQUUIehndSfuuig3TK5BTxQLkS3JxM+NxH/U=; b=h2Iy2EFd/r7pQyt34ufATuhUh5fy+kALdLmmJ0La4bMzIxxM+jv2WNbbVQ83Dm2aOsOC2g kwwzKAocLH4jzCLsAbrUJe2kma86jFILFE9Vym2N7whP61kFirgOPUonT2ziOyhpA9zwRx n3r3JL0tJkTcn7AGZfgWtwvj1k1Na+M= X-MC-Unique: b3jKap4QNdSxdmb3BqF2sg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] lib: Use virReportSystemError() more Date: Mon, 4 Apr 2022 16:52:10 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1649083965163100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Instead of reporting virReportError(..., g_strerror(), ...) let's use proper virReportSystemError(). Generated with help of cocci: @@ expression c; @@ <... - virReportError(c, + virReportSystemError(errno, ..., - g_strerror(errno), ...); ...> But then I had to hand fix format strings, because I'm not sure if cocci even knows how to do that. And even if it did, I surely don't. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/libxl/libxl_conf.c | 7 +++---- src/libxl/libxl_driver.c | 35 +++++++++++++++-------------------- src/qemu/qemu_interface.c | 8 ++++---- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index a0fc51c74a..6398129195 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1775,10 +1775,9 @@ libxlDriverConfigInit(libxlDriverConfig *cfg) uint64_t free_mem; =20 if (g_mkdir_with_parents(cfg->logDir, 0777) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create log dir '%s': %s"), - cfg->logDir, - g_strerror(errno)); + virReportSystemError(errno, + _("failed to create log dir '%s'"), + cfg->logDir); return -1; } =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 01f281d0a5..5d76eb9752 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -721,38 +721,33 @@ libxlStateInitialize(bool privileged, =20 libxl_driver->config =3D cfg; if (g_mkdir_with_parents(cfg->stateDir, 0777) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create state dir '%s': %s"), - cfg->stateDir, - g_strerror(errno)); + virReportSystemError(errno, + _("failed to create state dir '%s'"), + cfg->stateDir); goto error; } if (g_mkdir_with_parents(cfg->libDir, 0777) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create lib dir '%s': %s"), - cfg->libDir, - g_strerror(errno)); + virReportSystemError(errno, + _("failed to create lib dir '%s'"), + cfg->libDir); goto error; } if (g_mkdir_with_parents(cfg->saveDir, 0777) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create save dir '%s': %s"), - cfg->saveDir, - g_strerror(errno)); + virReportSystemError(errno, + _("failed to create save dir '%s'"), + cfg->saveDir); goto error; } if (g_mkdir_with_parents(cfg->autoDumpDir, 0777) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create dump dir '%s': %s"), - cfg->autoDumpDir, - g_strerror(errno)); + virReportSystemError(errno, + _("failed to create dump dir '%s'"), + cfg->autoDumpDir); goto error; } if (g_mkdir_with_parents(cfg->channelDir, 0777) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to create channel dir '%s': %s"), - cfg->channelDir, - g_strerror(errno)); + virReportSystemError(errno, + _("failed to create channel dir '%s'"), + cfg->channelDir); goto error; } =20 diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index 676bc896d6..d0dcce5690 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -370,10 +370,10 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig = *cfg, if (errbuf && *errbuf) errstr =3D g_strdup_printf("\nstderr=3D%s", errbuf); =20 - virReportError(VIR_ERR_INTERNAL_ERROR, - _("%s: failed to communicate with bridge helper: %s%s"), - cmdstr, g_strerror(errno), - NULLSTR_EMPTY(errstr)); + virReportSystemError(errno, + _("%s: failed to communicate with bridge help= er: %s"), + cmdstr, + NULLSTR_EMPTY(errstr)); VIR_FREE(errstr); goto cleanup; } --=20 2.35.1