From nobody Sun Feb 8 08:22:43 2026 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=1686556557; cv=none; d=zohomail.com; s=zohoarc; b=T8+1hWWds0wOF/yHMcVrWUdbqTBZIWYsdSWkEC3DWD+8oxn4nEDDc1CYkqnnkHGECL/Mof4Kxr2GHQ8XSWm/uvZ1/E+5MleAz5Q/lujsH6Td07ntWJYD8AulH+DymudOIpIPfyDKslrHewYLfHtdpF7wq+AG1DAQTrGQz/Y9ZPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686556557; 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=PuakEZx2OVhWq6FJ49FvD5B9uiepHVSh0PL+4nhu/7w=; b=S/Zd5QAJpFRDycvwSgwuXr3sQlex+1M1KY5NYOzj1eW2KjHT4IObSvEF5dJN8d8T2WK9nk9K2R6YuqQyLIZ/a9hLUb0Ww/ogYGRjIeSIHje+1NW24g4ex35n4mCTFpdetiPtqF3NTMzTNTOcXSbwm8JcST7xoyKJW+3RF5Lik7c= 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 1686556557243797.6785530686645; Mon, 12 Jun 2023 00:55:57 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-39--YA5M3WuNdiDnjskgvu02w-1; Mon, 12 Jun 2023 03:55:52 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6EC9805B2E; Mon, 12 Jun 2023 07:55:48 +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 CE68D202F344; Mon, 12 Jun 2023 07:55:48 +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 E93DB19466DF; Mon, 12 Jun 2023 07:55:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 802CA19465A3 for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3CF962166B26; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 356232166B25 for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 167AE801585 for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-8wPSZLOuMOaqHx7fGiqzmw-1; Mon, 12 Jun 2023 03:55:42 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-97455ea1c14so365551966b.2 for ; Mon, 12 Jun 2023 00:55:42 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id kt5-20020a170906aac500b00978868cb24csm4920863ejb.144.2023.06.12.00.55.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 00:55:40 -0700 (PDT) Received: from wheatley.. (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 6E5D911B85752 for ; Mon, 12 Jun 2023 09:55:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686556556; 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=PuakEZx2OVhWq6FJ49FvD5B9uiepHVSh0PL+4nhu/7w=; b=V20DhcMJLP+waqO9KQQ/7C3uqfTQPNI5F+1RePsnb708AluYI0eEhkCVONOTSe9z6IqJ0N 5NLWlUAklZqfJdpkS9L4XG2gzhnq3oZNGShEibUgFcZm2CyAOi1RNd850zVV7LL6tanCrk HYM3VRFfbOcO4p89y94LhXUByDcinWE= X-MC-Unique: -YA5M3WuNdiDnjskgvu02w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 8wPSZLOuMOaqHx7fGiqzmw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686556541; x=1689148541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PuakEZx2OVhWq6FJ49FvD5B9uiepHVSh0PL+4nhu/7w=; b=K/w4q7CB90SRXX2bSH2AATqNPEBNA/hXhTlrnMbZk85LfG1Evk5iSFOm4X2wFEg+fF lwI7jvqpDqrPEOHJwl4VsOK1a+WXCxqZyyMBc3IEp9F4B0vrJ9eYa0gEO0IuilyGYr6K DI0iDz63MNE0VbZRPhSeHos09NuRn7thDGvSiAdh/xD1y8HwbTf2YCaof1/cawpUcUeJ 3TkSs/KjjaIiO2/svVCYeZt+H72szjhog8fNT2tNLTgPIi0EuB7XqU+LgcWzSpnlqnjr JvWM0jgtSbpi3uLQSndHkbXV04ldmlkjhq50e4+YlRAvZIlwbk1FAgclTiGi/IeDLgHT pcMg== X-Gm-Message-State: AC+VfDwo9wBU1dB1Sd0/9HFUk845QzS7l5VrhMUYrEzFl5lwjIjM1Kwk +Nk1//yydfpVWDzjVvV52CNwVd4L+Zs3szzXZt3kzXGO+V2ZPVlN3HYjNi8WoZ6AytLiZC/C42A 0iGnrTtCZNL537qpz3rs1A3VI6pB6a/gmolSxpWC/NlYPWulaRiFREMYZlNQP6PGbWQuVwDezHP jYB2pXuQ== X-Received: by 2002:a17:907:6288:b0:974:1c90:4c02 with SMTP id nd8-20020a170907628800b009741c904c02mr7309370ejc.5.1686556541571; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QxwsmcpBi1cFDwKmMOzcK0NcJVAlNdSsngMcd+3D8PO0XpDF+GSkKYY/YXE4Wzx6Duuez1w== X-Received: by 2002:a17:907:6288:b0:974:1c90:4c02 with SMTP id nd8-20020a170907628800b009741c904c02mr7309358ejc.5.1686556541229; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 1/4] util: Parse RSS into ullp Date: Mon, 12 Jun 2023 09:55:34 +0200 Message-ID: <526bf8cbed388b10f355f2abe2e1be851d1365de.1686556413.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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 3.1 on 10.11.54.4 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: 1686556558694100003 Content-Type: text/plain; charset="utf-8"; x-default="true" It is used to fill an unsigned long long anyway and if it is negative than there is really an issue somewhere. Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 2 +- src/util/virprocess.c | 17 ++++++++++------- src/util/virprocess.h | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 56f4cd619715..857fbfb7992c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9937,7 +9937,7 @@ qemuDomainMemoryStatsInternal(virDomainObj *vm, =20 { int ret =3D -1; - long rss; + unsigned long long rss; =20 if (virDomainObjCheckActive(vm) < 0) return -1; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index d12fe4f7171f..a9f249413ce1 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -23,6 +23,7 @@ #include =20 #include +#include #include #ifndef WIN32 # include @@ -1739,7 +1740,7 @@ virProcessGetStatInfo(unsigned long long *cpuTime, unsigned long long *userTime, unsigned long long *sysTime, int *lastCpu, - long *vm_rss, + unsigned long long *vm_rss, pid_t pid, pid_t tid) { @@ -1748,14 +1749,16 @@ virProcessGetStatInfo(unsigned long long *cpuTime, unsigned long long stime =3D 0; const unsigned long long jiff2nsec =3D 1000ull * 1000ull * 1000ull / (unsigned long long) sysconf(_SC_= CLK_TCK); - long rss =3D 0; + long pagesize =3D virGetSystemPageSizeKB(); + unsigned long long rss =3D 0; int cpu =3D 0; =20 if (!proc_stat || virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_UTIME], NULL, 10, &ut= ime) < 0 || virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_STIME], NULL, 10, &st= ime) < 0 || - virStrToLong_l(proc_stat[VIR_PROCESS_STAT_RSS], NULL, 10, &rss) < = 0 || - virStrToLong_i(proc_stat[VIR_PROCESS_STAT_PROCESSOR], NULL, 10, &c= pu) < 0) { + virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_RSS], NULL, 10, &rss)= < 0 || + virStrToLong_i(proc_stat[VIR_PROCESS_STAT_PROCESSOR], NULL, 10, &c= pu) < 0 || + rss > ULLONG_MAX / pagesize) { VIR_WARN("cannot parse process status data"); } =20 @@ -1771,10 +1774,10 @@ virProcessGetStatInfo(unsigned long long *cpuTime, *lastCpu =3D cpu; =20 if (vm_rss) - *vm_rss =3D rss * virGetSystemPageSizeKB(); + *vm_rss =3D rss * pagesize; =20 =20 - VIR_DEBUG("Got status for %d/%d user=3D%llu sys=3D%llu cpu=3D%d rss=3D= %ld", + VIR_DEBUG("Got status for %d/%d user=3D%llu sys=3D%llu cpu=3D%d rss=3D= %lld", (int) pid, tid, utime, stime, cpu, rss); =20 return 0; @@ -1851,7 +1854,7 @@ virProcessGetStatInfo(unsigned long long *cpuTime, unsigned long long *userTime, unsigned long long *sysTime, int *lastCpu, - long *vm_rss, + unsigned long long *vm_rss, pid_t pid G_GNUC_UNUSED, pid_t tid G_GNUC_UNUSED) { diff --git a/src/util/virprocess.h b/src/util/virprocess.h index 4e216788389f..c18f87e80ec9 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -198,7 +198,7 @@ int virProcessGetStatInfo(unsigned long long *cpuTime, unsigned long long *userTime, unsigned long long *sysTime, int *lastCpu, - long *vm_rss, + unsigned long long *vm_rss, pid_t pid, pid_t tid); int virProcessGetSchedInfo(unsigned long long *cpuWait, --=20 2.41.0 From nobody Sun Feb 8 08:22:43 2026 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=1686556560; cv=none; d=zohomail.com; s=zohoarc; b=imzIydfrQ5qoJ/yDgVVtAjq/0UowCLCPGdo/qmPIOTRKxTi8IFJdsVpoaS4YrOPkR7weVm8pQaD3/gIuLHXyAnxPwcE1aG3gEAvIJFETKWdhQ1ZucgVaqPCAQM7xubJywLdMSx/IBTotdyj9imY9/Rc0Z6MRn/QZaW0usPDQl0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686556560; 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=n44wSrGqTt0oNsoQrbrd0z4d1q7iBEMVX60D1ID6bLs=; b=aE7MdKWCoFzSKILesej5xAB4Yp/nOdn83vTkSnam77tkJKfkgO9WaB19XcZiqunCFEj4TzrpH8gDhYn5HW2vjJxioxw2obk3Eun4c7otFWyv4CnGTM0BqO9BTWir+LsMAjYLHI8VIJ0OKX6ec/P+UrrZrPn6ZjjL7eIpoOUHvc0= 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 1686556560331348.7104131035311; Mon, 12 Jun 2023 00:56:00 -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-21-Os_F5oMYN1GmTGcCTJ1Tdw-1; Mon, 12 Jun 2023 03:55:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F98F381D1FE; Mon, 12 Jun 2023 07:55:50 +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 2934D440CB; Mon, 12 Jun 2023 07:55:50 +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 6D29219451DF; Mon, 12 Jun 2023 07:55:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 61B35194658C for ; Mon, 12 Jun 2023 07:55:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4274D20234B4; Mon, 12 Jun 2023 07:55:45 +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 3B82B20234B3 for ; Mon, 12 Jun 2023 07:55:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (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 2150985A5BA for ; Mon, 12 Jun 2023 07:55:45 +0000 (UTC) Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-94-5cXHrlQFNFC2xZZumRdWNA-1; Mon, 12 Jun 2023 03:55:43 -0400 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2b1d8fa4629so31152851fa.0 for ; Mon, 12 Jun 2023 00:55:42 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g25-20020a50ee19000000b0050bfeb15049sm4645730eds.60.2023.06.12.00.55.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 00:55:40 -0700 (PDT) Received: from wheatley.. (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 79E2E11B85753 for ; Mon, 12 Jun 2023 09:55:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686556559; 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=n44wSrGqTt0oNsoQrbrd0z4d1q7iBEMVX60D1ID6bLs=; b=LntanF5nhILYFAw7ZdlipEljQ2Anm7H26F3SSlSKmKFDqkCL2rz9FCWM2pcqBrVy31a3l/ 1iKeS1cS1xVX2W9A72djnPIjtEwEIEtc6yhaG2NdL/Z+1PWaVo2jPwASPeq0spibSlo9BB BuhKP9XyLK48ULLKEc529A98YcoLGj4= X-MC-Unique: Os_F5oMYN1GmTGcCTJ1Tdw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 5cXHrlQFNFC2xZZumRdWNA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686556542; x=1689148542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n44wSrGqTt0oNsoQrbrd0z4d1q7iBEMVX60D1ID6bLs=; b=UChct0Cg8rSM+vt/l5s2BCeAn9wPOS3JJBthNSJ7bfiq2cRL+Iy+CdzI2ZszZbwj01 jjvOjXNpYVZaH1bfNUbF51FWuRb4efGLdCXcR8RY5bO3GK/3ZacUZEchAUCN8NFWVEsa Elmj6JTLkp91INJyrftowxc79e3rEzxwZedkkQMARDpXbBSXyekGhWv05y3nnqwxYVjR HgDZdBJGKxZRyUBMWy1Y05SoTqGeBRHZ1dGzhTNcjz+Tra4EFifdKTJXOP7FneXqXsQ+ ThmPu9aIpqX1hhe7o7RtrwPHabUxrHcv1YId2vkDU+7R8y9at5VB4o9DZz/FlRvQWEyl q5dw== X-Gm-Message-State: AC+VfDz4h6PFxO8ycfOOMX5UYiCGRHwF3kfkh9sAHTP8IN8vTa8VSRZC A42CUgPvo6tUutM18pL+lwKO6qp46LsRlxEGLVDcvAhR1V+FDXSoMwFA7fMP+i9gV0n9Kqsxi9X /wxh69WMgrxvdp5kiadlx56w4dasQjFCIWRy6Mzae/pWH+8DEtM6zl23Ylg5Vj+Mn3i0WAHb7FR 8VtN8v/w== X-Received: by 2002:a2e:9942:0:b0:2b1:b7d0:bd5e with SMTP id r2-20020a2e9942000000b002b1b7d0bd5emr2183755ljj.6.1686556541808; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VFL5ChqGDsppc/W7qObGTZ7BQxZIUbwcxHZ0AnXJZ0eAER0PHrHU7ndO28L5jFxGrb8oEFg== X-Received: by 2002:a2e:9942:0:b0:2b1:b7d0:bd5e with SMTP id r2-20020a2e9942000000b002b1b7d0bd5emr2183747ljj.6.1686556541361; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 2/4] util: Remove virStrToLong_l Date: Mon, 12 Jun 2023 09:55:35 +0200 Message-ID: <8b447faad1a40d0641d2b6899a0315b600786c0a.1686556413.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 3.1 on 10.11.54.5 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: 1686556560835100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With the last user gone this function can be abolished. It is preferable to use _ll instead since that is not a subject to 32/64 bit scaling. Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 - src/util/virstring.c | 19 +------------------ src/util/virstring.h | 5 ----- tests/virstringtest.c | 4 ---- 4 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 436d5a07702e..fb7ad9c85511 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3414,7 +3414,6 @@ virStringToUpper; virStringTrimOptionalNewline; virStrToDouble; virStrToLong_i; -virStrToLong_l; virStrToLong_ll; virStrToLong_ui; virStrToLong_uip; diff --git a/src/util/virstring.c b/src/util/virstring.c index d9c9c8f73807..635685eed4a4 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -113,24 +113,7 @@ virStrToLong_uip(char const *s, char **end_ptr, int ba= se, unsigned int *result) return 0; } =20 -/* Just like virStrToLong_i, above, but produce a "long" value. */ -int -virStrToLong_l(char const *s, char **end_ptr, int base, long *result) -{ - long int val; - char *p; - int err; - - errno =3D 0; - val =3D strtol(s, &p, base); /* exempt from syntax-check */ - err =3D (errno || (!end_ptr && *p) || p =3D=3D s); - if (end_ptr) - *end_ptr =3D p; - if (err) - return -1; - *result =3D val; - return 0; -} +/* virStrToLong_l is intentionally skipped, consider virStrToLong_ll inste= ad */ =20 /* Just like virStrToLong_i, above, but produce an "unsigned long" * value. This version allows twos-complement wraparound of negative diff --git a/src/util/virstring.h b/src/util/virstring.h index 0f8b5d066425..16dcce98f42a 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -38,11 +38,6 @@ int virStrToLong_uip(char const *s, int base, unsigned int *result) G_GNUC_WARN_UNUSED_RESULT; -int virStrToLong_l(char const *s, - char **end_ptr, - int base, - long *result) - G_GNUC_WARN_UNUSED_RESULT; int virStrToLong_ul(char const *s, char **end_ptr, int base, diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 7d8d9204cce0..6e697cc240e6 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -258,7 +258,6 @@ testStringToLong(const void *opaque) const struct stringToLongData *data =3D opaque; int ret =3D 0; char *end; - long l; unsigned long ul; bool negative; =20 @@ -308,9 +307,6 @@ testStringToLong(const void *opaque) =20 /* We hate adding new API with 'long', and prefer 'int' or 'long * long' instead, since platform-specific results are evil */ - l =3D (sizeof(int) =3D=3D sizeof(long)) ? data->si : data->ll; - TEST_ONE(data->str, data->suffix, long, l, "%ld", - l, (sizeof(int) =3D=3D sizeof(long)) ? data->si_ret : data->l= l_ret); ul =3D (sizeof(int) =3D=3D sizeof(long)) ? data->ui : data->ull; TEST_ONE(data->str, data->suffix, unsigned long, ul, "%lu", ul, (sizeof(int) =3D=3D sizeof(long)) ? data->ui_ret : data->= ull_ret); --=20 2.41.0 From nobody Sun Feb 8 08:22:43 2026 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=1686556557; cv=none; d=zohomail.com; s=zohoarc; b=QHvna9cyB++nUY+U9gqkpsxrsOCJMdWNBfeOrkZEtl91z7e4oCNwuJEluRinPXTChF8B/i2BXXFl9p0AdRzWYLgU9W94VD2/fIjlBGsG0vGyLUlQYQ6YIYFnq4Vj984qIFbJbyUkZF2mDTHZDtLWb9fNkjOG6WOXZU2uq8T8fwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686556557; 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=Td9anoz6+cDuUTNHgQChjPKP1n+5WzBbXThkUKoER9E=; b=C+K5+GBLxVt9vFDFmnzLzFDlE0wGhaGNn593S2gnPBUXoLWDZ+6UaO68M5Whsh2X1ns8/Fcz+3TwqUlReAxMsPVvX0jock5ZXq9vGoyIG+Nt5Qwhw6tjXgDZO65VfuUkGg4J2F+4j4HoDtdtCyffcl/j4QtTgg5xU5949wh5vmc= 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 1686556557118162.746565875486; Mon, 12 Jun 2023 00:55:57 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-671-soQeGjLrPAyBC-GPENgAVQ-1; Mon, 12 Jun 2023 03:55:51 -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 605738582A4; Mon, 12 Jun 2023 07:55:49 +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 4A5B4492CAC; Mon, 12 Jun 2023 07:55:49 +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 2CC7319451C4; Mon, 12 Jun 2023 07:55:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BAFDE194658C for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ABEFD10ED7; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A52FC11324 for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 88411185A78B for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-0SWDUGZROn2Fg-hnIQd-ew-1; Mon, 12 Jun 2023 03:55:43 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-977d0333523so493496566b.0 for ; Mon, 12 Jun 2023 00:55:42 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id gz18-20020a170906f2d200b009659ad1072fsm4822871ejb.113.2023.06.12.00.55.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 00:55:41 -0700 (PDT) Received: from wheatley.. (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 85CD711B85754 for ; Mon, 12 Jun 2023 09:55:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686556556; 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=Td9anoz6+cDuUTNHgQChjPKP1n+5WzBbXThkUKoER9E=; b=EeDj5qm82fYAESXDWAUwNfjpJRE5VgOvtq8HE2E25bzrAvpFyINRawgbgywHe0ie8el8RJ ZAwHVMbPuhV6a2pl4ivTaLWo4ggi/9ZfZCE8L1Khv777cBNgBlIynSZa3UnOTIyiQER88M N1WuaGw3xqblP5RdYXIVEs2fRd2RmRQ= X-MC-Unique: soQeGjLrPAyBC-GPENgAVQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 0SWDUGZROn2Fg-hnIQd-ew-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686556542; x=1689148542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Td9anoz6+cDuUTNHgQChjPKP1n+5WzBbXThkUKoER9E=; b=ZuyeOYy/EtX2/OVGGjwLafqZLyv9A1XFlLqSR3Bm6XRSlSpm7yTUmIFZkWVy1PgKWM O1E1Z0NmwrLluxzoVm5mn+nAr1O0rmhy/pIvBxs0jObK0J+fKJL8YtichsUJizyrnqyT UlYKxziagc2Lbn4JQLTInANq/RYbZf5UKLmgltW73Tblj4n8CX2lUbl1JEvrTsNd5pNn 6ZFxnZyc18wE9IRBtwx8vzVLUAQOpf1622JWWeZLMMchAIlCjqVuViIfGxPY/f4ryQiD UV36DaSVXhcDU4ItFU3mo6SJFLH+t4zDF0dMEPJI6HOr/L78EdH0U95OCCYWBjxtGJRr sPtQ== X-Gm-Message-State: AC+VfDw1GpVpum/y22OBapJHjbEGfI1/PXjWor9a8+1pUxvTPQwX5ojM oVtjd1nAtna8YJq22AoOQdcB3uIrqAVF/5zxpslt0zINwGfwDjSsQkEQ2Q8nfL0P/Dwz33Ozrkh QX437A8BvSNqoh/QQt71ndZTHV/W+GE1Mk94EA3ddaCDFQlVaPhrfF5VT5wdkpGvpyDNI8Icgk5 PRHngmwA== X-Received: by 2002:a17:907:3da7:b0:974:c32c:b484 with SMTP id he39-20020a1709073da700b00974c32cb484mr10796164ejc.72.1686556542062; Mon, 12 Jun 2023 00:55:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4jklDJqdU7EzJo59ZVDn4i2F7KckfubqA0gSQ6DxVl2XWiFtQRexnDDkKtbTnQ1S6sLl6kfQ== X-Received: by 2002:a17:907:3da7:b0:974:c32c:b484 with SMTP id he39-20020a1709073da700b00974c32cb484mr10796151ejc.72.1686556541675; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 3/4] util: Use g_ascii_strtoll Date: Mon, 12 Jun 2023 09:55:36 +0200 Message-ID: <3f1c61194a6f761b192b31c8fc843a759fe8c0bb.1686556413.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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 3.1 on 10.11.54.9 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: 1686556558703100004 Content-Type: text/plain; charset="utf-8"; x-default="true" This has two main advantages: - it parses the number with C locale explicitly - it behaves the same on Windows as on Linux and BSD both of which are wanted behaviours. Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/util/virstring.c | 54 +++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/src/util/virstring.c b/src/util/virstring.c index 635685eed4a4..6b728ff04759 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -35,7 +35,7 @@ =20 VIR_LOG_INIT("util.string"); =20 -/* Like strtol, but produce an "int" result, and check more carefully. +/* Like strtol with C locale, but produce an "int" result, and check more = carefully. Return 0 upon success; return -1 to indicate failure. When END_PTR is NULL, the byte after the final valid digit must be NUL. Otherwise, it's like strtol and lets the caller check any suffix for @@ -44,12 +44,12 @@ VIR_LOG_INIT("util.string"); int virStrToLong_i(char const *s, char **end_ptr, int base, int *result) { - long int val; + long long val; char *p; int err; =20 errno =3D 0; - val =3D strtol(s, &p, base); /* exempt from syntax-check */ + val =3D g_ascii_strtoll(s, &p, base); err =3D (errno || (!end_ptr && *p) || p =3D=3D s || (int) val !=3D val= ); if (end_ptr) *end_ptr =3D p; @@ -65,22 +65,22 @@ virStrToLong_i(char const *s, char **end_ptr, int base,= int *result) int virStrToLong_ui(char const *s, char **end_ptr, int base, unsigned int *res= ult) { - unsigned long int val; + unsigned long long val; char *p; bool err =3D false; =20 errno =3D 0; - val =3D strtoul(s, &p, base); /* exempt from syntax-check */ + val =3D g_ascii_strtoull(s, &p, base); =20 /* This one's tricky. We _want_ to allow "-1" as shorthand for * UINT_MAX regardless of whether long is 32-bit or 64-bit. But - * strtoul treats "-1" as ULONG_MAX, and going from ulong back - * to uint differs depending on the size of long. */ - if (sizeof(long) > sizeof(int) && memchr(s, '-', p - s)) { + * g_ascii_strtoull treats "-1" as ULLONG_MAX, and going from ullong b= ack + * to uint differs depending on the size of uint. */ + if (memchr(s, '-', p - s)) { if (-val > UINT_MAX) err =3D true; else - val &=3D 0xffffffff; + val &=3D UINT_MAX; } =20 err |=3D (errno || (!end_ptr && *p) || p =3D=3D s || (unsigned int) va= l !=3D val); @@ -97,12 +97,12 @@ virStrToLong_ui(char const *s, char **end_ptr, int base= , unsigned int *result) int virStrToLong_uip(char const *s, char **end_ptr, int base, unsigned int *re= sult) { - unsigned long int val; + unsigned long long val; char *p; bool err =3D false; =20 errno =3D 0; - val =3D strtoul(s, &p, base); /* exempt from syntax-check */ + val =3D g_ascii_strtoull(s, &p, base); err =3D (memchr(s, '-', p - s) || errno || (!end_ptr && *p) || p =3D=3D s || (unsigned int) val != =3D val); if (end_ptr) @@ -121,13 +121,25 @@ virStrToLong_uip(char const *s, char **end_ptr, int b= ase, unsigned int *result) int virStrToLong_ul(char const *s, char **end_ptr, int base, unsigned long *re= sult) { - unsigned long int val; + unsigned long long val; char *p; - int err; + bool err =3D false; =20 errno =3D 0; - val =3D strtoul(s, &p, base); /* exempt from syntax-check */ - err =3D (errno || (!end_ptr && *p) || p =3D=3D s); + val =3D g_ascii_strtoull(s, &p, base); + + /* This one's tricky. We _want_ to allow "-1" as shorthand for + * ULONG_MAX regardless of whether long is 32-bit or 64-bit. But + * g_ascii_strtoull treats "-1" as ULLONG_MAX, and going from ullong b= ack + * to ulong differs depending on the size of ulong. */ + if (memchr(s, '-', p - s)) { + if (-val > ULONG_MAX) + err =3D true; + else + val &=3D ULONG_MAX; + } + + err |=3D (errno || (!end_ptr && *p) || p =3D=3D s || (unsigned long) v= al !=3D val); if (end_ptr) *end_ptr =3D p; if (err) @@ -142,14 +154,14 @@ int virStrToLong_ulp(char const *s, char **end_ptr, int base, unsigned long *result) { - unsigned long int val; + unsigned long long val; char *p; int err; =20 errno =3D 0; - val =3D strtoul(s, &p, base); /* exempt from syntax-check */ + val =3D g_ascii_strtoull(s, &p, base); err =3D (memchr(s, '-', p - s) || - errno || (!end_ptr && *p) || p =3D=3D s); + errno || (!end_ptr && *p) || p =3D=3D s || (unsigned long) val = !=3D val); if (end_ptr) *end_ptr =3D p; if (err) @@ -167,7 +179,7 @@ virStrToLong_ll(char const *s, char **end_ptr, int base= , long long *result) int err; =20 errno =3D 0; - val =3D strtoll(s, &p, base); /* exempt from syntax-check */ + val =3D g_ascii_strtoll(s, &p, base); err =3D (errno || (!end_ptr && *p) || p =3D=3D s); if (end_ptr) *end_ptr =3D p; @@ -189,7 +201,7 @@ virStrToLong_ull(char const *s, char **end_ptr, int bas= e, int err; =20 errno =3D 0; - val =3D strtoull(s, &p, base); /* exempt from syntax-check */ + val =3D g_ascii_strtoull(s, &p, base); err =3D (errno || (!end_ptr && *p) || p =3D=3D s); if (end_ptr) *end_ptr =3D p; @@ -210,7 +222,7 @@ virStrToLong_ullp(char const *s, char **end_ptr, int ba= se, int err; =20 errno =3D 0; - val =3D strtoull(s, &p, base); /* exempt from syntax-check */ + val =3D g_ascii_strtoull(s, &p, base); err =3D (memchr(s, '-', p - s) || errno || (!end_ptr && *p) || p =3D=3D s); if (end_ptr) --=20 2.41.0 From nobody Sun Feb 8 08:22:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1686556555; cv=none; d=zohomail.com; s=zohoarc; b=fuLuUwMXgxuU55D66F3W92AI7wyju20levxEOjXhzIMTUVJ+UhDkrCfN5dJ9sQ+gmuXk7wyeVmEvL4Cebxbou/q/IHh9Id+nbKcNBq5R8U2fnQlHKaQj1edb5yuJ0zh2S7flFbx94PzL7dHRE1e9ewSKcttBVjDJsG9nUDxdaQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686556555; 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=I6WNWeg/ORGXuXtRNPCoTbDCyFXRgvwSVCIDmw0oB/k=; b=j1DQciTHrKb6LIenotzl9DsHomnnXdvgWjTxyLD1MzbsOJcpxMeZva80Iw/tQdBwxI+jQm5Oe4dTmKsVIe4tAKv9lBfkK/QTVw8t7CsVK/4R9CU13YOKdPS09OIh8UyXeZJWBnoAzKZGPIATRBhDPecL+k4rkU0C+1EVen6fokg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1686556555464703.7384915333901; Mon, 12 Jun 2023 00:55:55 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-1-ltPsOvM4mybzGAYuKyDw-1; Mon, 12 Jun 2023 03:55:50 -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 8B47E8030D3; Mon, 12 Jun 2023 07:55:48 +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 D5170492CA6; Mon, 12 Jun 2023 07:55:47 +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 B344B19465A3; Mon, 12 Jun 2023 07:55:45 +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 7DFA9194658C for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 508E4C1604D; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4899EC1604C for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 21F7938173C3 for ; Mon, 12 Jun 2023 07:55:44 +0000 (UTC) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-Etc-Ey6vPIWduYUUkXD-rA-1; Mon, 12 Jun 2023 03:55:42 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-977d4b0d9e3so338610466b.0 for ; Mon, 12 Jun 2023 00:55:42 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id p4-20020a17090628c400b00977ca819248sm4763848ejd.110.2023.06.12.00.55.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 00:55:41 -0700 (PDT) Received: from wheatley.. (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 9162211B85755 for ; Mon, 12 Jun 2023 09:55:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686556554; 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=I6WNWeg/ORGXuXtRNPCoTbDCyFXRgvwSVCIDmw0oB/k=; b=ejsTGjPXQgNNQH3EGiNzN6piJUkB7XJdABl0qklxAlQK2Gc1PVjDHuWg1a0RuiRMHkavCj 7BB0DlIYfaw59S8uMm8MnlWN8IXHajJ/Sau3hQs/w5VXzBxpkWAZUxK3CcEWy3hggh8M24 8GkzwX/FQWC/nVQfBe3X66PTHdZOvDw= X-MC-Unique: 1-ltPsOvM4mybzGAYuKyDw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Etc-Ey6vPIWduYUUkXD-rA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686556541; x=1689148541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I6WNWeg/ORGXuXtRNPCoTbDCyFXRgvwSVCIDmw0oB/k=; b=WMekijDZjcRCE6o7d6sQw2P9KiZGMyR54kkhoGErGGAwnbEHoxTbWWDwGOo/ph5P4t Paz8JRO38WjfXEOOAZF3WvJdjfeNO9dFgCe4BknIjgTTU1kGTaYovJk+lErCdEQMBIBR ZoMGwHTv96Ma8MCkQlnWrGgpxRGZJApxsinyVwKavCcpByfDSqpSJPWl+6z82K8RI3xt 7l7WXNqVj5X8V5eJ5P55/qddUFozb2WgJkNdGItSN+NfXb7BsTFz7K1K6yHJDeIQFg6M GbwALV9mvOOwoYgkVpkiqIY+U9JRCoWpPyGCB8QHsIJNO5fbd/vXDv9LveRdjJI7VtrE HsQA== X-Gm-Message-State: AC+VfDzfFSEWCvvCSJTC/7Vd8Rk6t2oXwK5aD4njA0dzWPs0Cholv2He qHCdd5rKGLzNQI/qMFbeFDlfNnnJ1199+7OzbfO6qZPrqyFKwno0+hyvSIIh2jAjGP6M2nKoLWM S/VFpbUGMgJOPQGacRDPSoCfysq0c/n3Hdww8LgWDilzSboczwbmtSmGywlqHSckDAlm3XPG/eR GDlN41tg== X-Received: by 2002:a17:907:728f:b0:973:d43f:5fdf with SMTP id dt15-20020a170907728f00b00973d43f5fdfmr8042879ejc.61.1686556541794; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6uGTdbPfdC6NDmk9O2JGStocXa6khyxrm7pZYxsZtq6fXv64/Nux7/a3SYOEbll+8QdXzJFw== X-Received: by 2002:a17:907:728f:b0:973:d43f:5fdf with SMTP id dt15-20020a170907728f00b00973d43f5fdfmr8042871ejc.61.1686556541598; Mon, 12 Jun 2023 00:55:41 -0700 (PDT) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH 4/4] meson-dist: Use shutil.copy for copying a file Date: Mon, 12 Jun 2023 09:55:37 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 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 3.1 on 10.11.54.9 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: 1686556557236100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Using os.system("cp {0} {1}".format(...)) has two issues, it does not work on Windows, but more importantly it can cause issues in case one of the directories has a space in it. Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- scripts/meson-dist.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/meson-dist.py b/scripts/meson-dist.py index a1d36c2533da..1c2364f6b67e 100755 --- a/scripts/meson-dist.py +++ b/scripts/meson-dist.py @@ -2,13 +2,12 @@ =20 import os import sys +import shutil =20 meson_build_root =3D sys.argv[1] file_name =3D sys.argv[2] =20 meson_dist_root =3D os.environ['MESON_DIST_ROOT'] =20 -os.system('cp {0} {1}'.format( - os.path.join(meson_build_root, file_name), - os.path.join(meson_dist_root, file_name) -)) +shutil.copy(os.path.join(meson_build_root, file_name), + os.path.join(meson_dist_root, file_name)) --=20 2.41.0