From nobody Mon Feb 9 13:57:55 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=huawei.com 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 1626941130263384.21875055746204; Thu, 22 Jul 2021 01:05:30 -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-255-_30aUznkM8SjzX2F16ijig-1; Thu, 22 Jul 2021 04:05:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB057802C89; Thu, 22 Jul 2021 08:05:21 +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 A038F60C9B; Thu, 22 Jul 2021 08:05:21 +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 5C9554BB7C; Thu, 22 Jul 2021 08:05:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16M85Js6012352 for ; Thu, 22 Jul 2021 04:05:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 832AC202865A; Thu, 22 Jul 2021 08:05:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C70D2028668 for ; Thu, 22 Jul 2021 08:05:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DF30185828D for ; Thu, 22 Jul 2021 08:05:17 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-242-bzub2RgqPMSf8Cri9rTaZQ-1; Thu, 22 Jul 2021 04:05:13 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GVlJn1g7yz7x80; Thu, 22 Jul 2021 16:01:29 +0800 (CST) Received: from dggpeml500009.china.huawei.com (7.185.36.209) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 16:05:09 +0800 Received: from 90078.china.huawei.com (10.174.187.199) by dggpeml500009.china.huawei.com (7.185.36.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 16:05:08 +0800 X-MC-Unique: _30aUznkM8SjzX2F16ijig-1 X-MC-Unique: bzub2RgqPMSf8Cri9rTaZQ-1 From: Yang Fei To: Subject: [PATCH v4 1/3] util: Add virFileReadValueUllongQuiet Date: Thu, 22 Jul 2021 16:05:00 +0800 Message-ID: <20210722080502.20364-2-yangfei85@huawei.com> In-Reply-To: <20210722080502.20364-1-yangfei85@huawei.com> References: <20210722080502.20364-1-yangfei85@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.187.199] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500009.china.huawei.com (7.185.36.209) X-CFilter-Loop: Reflected X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 16M85Js6012352 X-loop: libvir-list@redhat.com Cc: yubihong@huawei.com, pkrempa@redhat.com, mprivozn@redhat.com, yangfei85@huawei.com, xiexiangyou@huawei.com, liangpeng10@huawei.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.13 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-ZM-MESSAGEID: 1626941131783100001 Content-Type: text/plain; charset="utf-8" Use function virFileReadValueUllongQuiet to read unsigned long long value without error report. Signed-off-by: Yang Fei --- src/libvirt_private.syms | 1 + src/util/virfile.c | 24 ++++++++++++++++++++++++ src/util/virfile.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4bc2974e7f..5429a82a7c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2242,6 +2242,7 @@ virFileReadValueScaledInt; virFileReadValueString; virFileReadValueUint; virFileReadValueUllong; +virFileReadValueUllongQuiet; virFileRelLinkPointsTo; virFileRemove; virFileRemoveLastComponent; diff --git a/src/util/virfile.c b/src/util/virfile.c index 723e1ca6e5..70737f4751 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4065,6 +4065,30 @@ virFileReadValueUllong(unsigned long long *value, co= nst char *format, ...) return 0; } =20 +int +virFileReadValueUllongQuiet(unsigned long long *value, const char *format,= ...) +{ + g_autofree char *str =3D NULL; + g_autofree char *path =3D NULL; + va_list ap; + + va_start(ap, format); + path =3D g_strdup_vprintf(format, ap); + va_end(ap); + + if (!virFileExists(path)) + return -2; + + if (virFileReadAllQuiet(path, VIR_INT64_STR_BUFLEN, &str) < 0) + return -1; + + virStringTrimOptionalNewline(str); + + if (virStrToLong_ullp(str, NULL, 10, value) < 0) + return -1; + + return 0; +} =20 /** * virFileReadValueScaledInt: diff --git a/src/util/virfile.h b/src/util/virfile.h index 72368495bf..967c9a9b4f 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -339,6 +339,8 @@ int virFileReadValueUint(unsigned int *value, const cha= r *format, ...) G_GNUC_PRINTF(2, 3); int virFileReadValueUllong(unsigned long long *value, const char *format, = ...) G_GNUC_PRINTF(2, 3); +int virFileReadValueUllongQuiet(unsigned long long *value, const char *for= mat, ...) + G_GNUC_PRINTF(2, 3); int virFileReadValueBitmap(virBitmap **value, const char *format, ...) G_GNUC_PRINTF(2, 3); int virFileReadValueScaledInt(unsigned long long *value, const char *forma= t, ...) --=20 2.23.0