From nobody Sat May 4 20:21:17 2024 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=1604491286; cv=none; d=zohomail.com; s=zohoarc; b=hYXEEq4v46F4H8/U5P2NfXE3gt7NiwssCdGNDdDuQ5Ainwzge7rcNyq7O2jn09Hb+ei3LBD4mBM1CGeTqOWIisUyC7vFHEloyibSaQgPyNPUR8sxi9EZvD0+lXubNzMr5av0R9NsENSukS69ay+S19S0G4aoEjV2vFfIn/+LHAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604491286; 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=9bUbbLZzns7bC80D4G1b+5G33sYgPYJr6xsusByIHoM=; b=NlB629MJeo6LYKrR7lDPCJbO4ZEGDfbpWa1n7X5L16IzpNcRAxENQpiTbZB2YKbwmQos72goVWShBCu8KLs0yFjAVOzzmZsu/0I+ARvw/JFfYLGGSGTEEBZn5PhQXRzATPehntXC8+FaaNJvJge4GtbfVuUSkF2dNuWz9UzlkAI= 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) header.from= 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 1604491286290732.6023792044706; Wed, 4 Nov 2020 04:01:26 -0800 (PST) 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-415-ZdOx8qT7NbeCvKOFFaefiA-1; Wed, 04 Nov 2020 07:01:21 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57DA41902EA4; Wed, 4 Nov 2020 12:01:15 +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 0DB135DA6B; Wed, 4 Nov 2020 12:01:15 +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 BE15C1832FB5; Wed, 4 Nov 2020 12:01:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A4C1AiR022218 for ; Wed, 4 Nov 2020 07:01:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id A62981E2; Wed, 4 Nov 2020 12:01:10 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 141165C63E for ; Wed, 4 Nov 2020 12:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604491283; 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=9bUbbLZzns7bC80D4G1b+5G33sYgPYJr6xsusByIHoM=; b=aGGNVaAd4QCprx+qvDgenfe5Vctod7rzEk5EATRlYgWdz2VLZuhe+stb0D8UP3Zk1dK6Xu 241z+ozq+xkPVUlA3OuQ6qZOhFYIf7NDYTQpII6lsGRmI5gs8vHYo4wlW+SaijvrMpYqy0 wC7d7SMtMijChllQpqnChuA0hxeu+g8= X-MC-Unique: ZdOx8qT7NbeCvKOFFaefiA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] util: use g_autofree in virSCSIHostGetUniqueId Date: Wed, 4 Nov 2020 13:01:00 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.79 on 10.5.11.14 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) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/util/virscsihost.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c index c259e63000..4d314c3ceb 100644 --- a/src/util/virscsihost.c +++ b/src/util/virscsihost.c @@ -46,17 +46,16 @@ int virSCSIHostGetUniqueId(const char *sysfs_prefix, int host) { - char *sysfs_path =3D NULL; + g_autofree char *sysfs_path =3D NULL; char *p =3D NULL; - int ret =3D -1; - char *buf =3D NULL; + g_autofree char *buf =3D NULL; int unique_id; =20 sysfs_path =3D g_strdup_printf("%s/host%d/unique_id", sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_= HOST_PATH, host); =20 if (virFileReadAll(sysfs_path, 1024, &buf) < 0) - goto cleanup; + return -1; =20 if ((p =3D strchr(buf, '\n'))) *p =3D '\0'; @@ -65,15 +64,10 @@ virSCSIHostGetUniqueId(const char *sysfs_prefix, virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to parse unique_id: %s"), buf); =20 - goto cleanup; + return -1; } =20 - ret =3D unique_id; - - cleanup: - VIR_FREE(sysfs_path); - VIR_FREE(buf); - return ret; + return unique_id; } =20 =20 --=20 2.26.2 From nobody Sat May 4 20:21:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1604491326; cv=none; d=zohomail.com; s=zohoarc; b=PzgrvDyHJgM17ioqO0CtgDforJLnoTJzK5fkD/WZxkg950Uxbws+IOlfOcIi5b0Ki1UGayhz/vp6Yw63DrrLaetXxPfK33faxnPlsQlvTcMUNeqKKIeGu9nQpS7FLijLvKFOBCPsDV5Ngh7+2KrK69Sc5sWcIee236XxxVqnTpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604491326; 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=slS9uGIdQMeKlfjd4Ko3vqrpJD48IPgw2YZP/IHBvXo=; b=Ay5ksyeGsc3GxchVtgAfarGQct//uLmCyIiuujXZkp0BieI5HyrdJReG6s8J1n3Jcckk1dZA4I/+R8OEbptdO6w8zo/VSDaEpJda7h27PzVw11fBE36/B9TjDW3Km6NTDxR5gJXO78F+Lu5naQEvcEH/SZUBGVwWmAZT7ujShZU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604491326421783.6373877883682; Wed, 4 Nov 2020 04:02:06 -0800 (PST) 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-155-x-ZXPPVuNvSJlhWU9eUSBQ-1; Wed, 04 Nov 2020 07:01:37 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 432F010866BF; Wed, 4 Nov 2020 12:01:32 +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 1FD0F5DA6B; Wed, 4 Nov 2020 12:01:32 +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 D41811832FB8; Wed, 4 Nov 2020 12:01:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A4C1BjT022233 for ; Wed, 4 Nov 2020 07:01:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id B79AF1E2; Wed, 4 Nov 2020 12:01:11 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11AB75C5DE for ; Wed, 4 Nov 2020 12:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604491323; 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=slS9uGIdQMeKlfjd4Ko3vqrpJD48IPgw2YZP/IHBvXo=; b=cdada577GOxVfP9gp9J2ranl+E4pkyTTGG+Ffsw+OavgnuJ5VOMsItXfnSEACnqgG6+b+H B9b54s6RwKTM4zSGrCT5pRHLxg62hUuW4OZ5f8C43lbS1PlQzu4O3zCgAUEMPz0EUx4Bf0 rgYWEC8PVuau93cyxms0rf1lIgNQxl4= X-MC-Unique: x-ZXPPVuNvSJlhWU9eUSBQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] util: quieten virSCSIHostGetUniqueId Date: Wed, 4 Nov 2020 13:01:01 +0100 Message-Id: <21a63219d4059945b0416ff997e52d5a7f8d88b7.1604491232.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.79 on 10.5.11.14 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) The only caller of this function ignores failure and just sets the unique_id to -1. Failing to read the file is likely to the device no longer being present, not a real error. Stop reporting errors in this function. https://bugzilla.redhat.com/show_bug.cgi?id=3D1692100 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/util/virscsihost.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c index 4d314c3ceb..969cdd9f79 100644 --- a/src/util/virscsihost.c +++ b/src/util/virscsihost.c @@ -41,6 +41,8 @@ VIR_LOG_INIT("util.scsi_host"); * Read the value of the "scsi_host" unique_id file. * * Returns the value on success or -1 on failure. + * + * No errors are reported. */ int virSCSIHostGetUniqueId(const char *sysfs_prefix, @@ -54,16 +56,14 @@ virSCSIHostGetUniqueId(const char *sysfs_prefix, sysfs_path =3D g_strdup_printf("%s/host%d/unique_id", sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_= HOST_PATH, host); =20 - if (virFileReadAll(sysfs_path, 1024, &buf) < 0) + if (virFileReadAllQuiet(sysfs_path, 1024, &buf) < 0) return -1; =20 if ((p =3D strchr(buf, '\n'))) *p =3D '\0'; =20 if (virStrToLong_i(buf, NULL, 10, &unique_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to parse unique_id: %s"), buf); - + VIR_DEBUG("unable to parse unique_id: '%s'", buf); return -1; } =20 --=20 2.26.2