From nobody Fri May 3 20:08:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1596406318; cv=none; d=zohomail.com; s=zohoarc; b=ElcCSe9veWpFokGXhngDyomkXjiRxoVQLeysIsWMd+LQpQzW0++xXXCdFVJK4enVwEfZMak30YmOfGx7QyLVbMylLPExQyNonz14bKJN0mZFuPZSVMgPEltFK9YdZ8aSuhwNX+xYVSv5MhHNmgq2F6E5peKICp98rudA6TYaRII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406318; 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=8oyPwL60yP/5kk/7ow6z93UnoJulOje4PLlQ/YU4Jco=; b=fOjPMs7ItndyLgD81xJSCsrXEimofmt1d4xidEz8CnfmJ/NFZBi5fiez4vuwC1WhDKcIHCp2YrC8gg4tdFI6Ok24kTISiqrN39Wyi3eE/eWn4piTge/4fAFyqP3+v5uDEjDz5v9HKtcellGG7vCHzuFzJEg14kRdF5F/hVClzcM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1596406318198169.04836434021274; Sun, 2 Aug 2020 15:11:58 -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-39-xEDa5Fw2N7ao32BE3eEmnQ-1; Sun, 02 Aug 2020 18:11:54 -0400 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 D60AE1893DDF; Sun, 2 Aug 2020 22:11:49 +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 E06B65D9CD; Sun, 2 Aug 2020 22:11:47 +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 22E231809554; Sun, 2 Aug 2020 22:11:44 +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 072MBfAM010566 for ; Sun, 2 Aug 2020 18:11:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1C60C5C6DD; Sun, 2 Aug 2020 22:11:41 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C5F05C5B7 for ; Sun, 2 Aug 2020 22:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406316; 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=8oyPwL60yP/5kk/7ow6z93UnoJulOje4PLlQ/YU4Jco=; b=fOmnzPBefDJWCrTRDvcCPymWRwOKPx7YI/BWzW0tSdCrrwsqa4jXzc7WAFFs2u4KuL/Gfi Qbmw86VxO3XpckYAeNIpSBgRCDHkQ2vn6eV6cO9Wb5tdZp/BXyr8eOWTsDIw4qbqrpeHm+ 2ttApIPtn5RhyT5mfLz37su53AVONiQ= X-MC-Unique: xEDa5Fw2N7ao32BE3eEmnQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/8] vz: remove redundant NULL pointer check Date: Mon, 3 Aug 2020 00:11:24 +0200 Message-Id: <1c9685bb425193d96e564e29d9ae74245e83396a.1596406221.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 'dom' pointer is already dereferenced earlier. src/vz/vz_sdk.c:249:24: warning: Either the condition 'if(dom)' is redundant or there is possible null pointer dereference: dom. [nullPointerRedundantCheck] Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/vz/vz_sdk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index b5e69b385f..bb1ef0ea47 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -256,11 +256,11 @@ waitDomainJobHelper(PRL_HANDLE job, virDomainObjPtr d= om, unsigned int timeout, } =20 pdom->job.sdkJob =3D job; - if (dom) - virObjectUnlock(dom); + + virObjectUnlock(dom); ret =3D waitJobHelper(job, timeout, filename, funcname, linenr); - if (dom) - virObjectLock(dom); + virObjectLock(dom); + pdom->job.sdkJob =3D NULL; =20 return ret; --=20 2.26.2 From nobody Fri May 3 20:08:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1596406343; cv=none; d=zohomail.com; s=zohoarc; b=mC4WYJL3rc1nLaN0BtkX2q2YtNH7a/RJTEWXs0k1QidgZViBa0x8rXPYPUKyPNep8l2ZQA9IaBbxOiebAGJhlumEUF6yzJtkhS7tFmKQL6zc2ciltWo2KSawHu8CBd+LspmxZWWo4CWgK/IM36/RxPCaws02Mz7ecSIA1mcMgjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406343; 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=S3E8KgEwlqyPiZ5+0/uPEheNjBR56wD00MOtqvH5ZMg=; b=AqjuDm7q03vkoT/DINhyqJzh4jwZWoGYjpQ2FmnaV9/chTsCg4pGcIGN/7tB2EtFqjiGKEtRDyqL36cqqkVnCJj73DjCbRumBWONg07O6obtwM7BsulMH1loTpiAs4whqixX7WdMRSh61PL+UyQikIVeAXX+lRKqoEEc1rgClmQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1596406343320293.29743629928714; Sun, 2 Aug 2020 15:12:23 -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-405-EGlagY20OkyTRWY4Urqgzg-1; Sun, 02 Aug 2020 18:12:20 -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 BBF451893DCC; Sun, 2 Aug 2020 22:12:14 +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 9D10E8BEC7; Sun, 2 Aug 2020 22:12:14 +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 6D24B1809561; Sun, 2 Aug 2020 22:12:14 +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 072MBgTZ010575 for ; Sun, 2 Aug 2020 18:11:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3B6E85FC2F; Sun, 2 Aug 2020 22:11:42 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 813C25C5B7 for ; Sun, 2 Aug 2020 22:11:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406342; 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=S3E8KgEwlqyPiZ5+0/uPEheNjBR56wD00MOtqvH5ZMg=; b=LWH8VPK7HSXTxQB8cXCEMXIEW7fE+qrK6silSCeDae/1BTlXQV+bYedqTpxIz2KZHz0z+b nMWRlOPmVCAdlei1sxrtkHdAbd5ilVVu5gZV5dbPrIh0vK1TkVPbIF0l/JlNdhssm4rx2E JNMjGKZS0dltXII+ST+XVeNpw3XycNc= X-MC-Unique: EGlagY20OkyTRWY4Urqgzg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/8] Remove redundant conditions Date: Mon, 3 Aug 2020 00:11:25 +0200 Message-Id: <7ecf882a11f4459b860765a8885866ad3c370de1.1596406221.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.13 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) All of these have been checked earlier. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/hypervisor/virhostdev.c | 2 +- src/libxl/xen_xl.c | 2 +- src/qemu/qemu_hotplug.c | 3 +-- src/qemu/qemu_process.c | 6 +++--- src/rpc/virnetsocket.c | 2 +- src/util/virlease.c | 2 +- src/vbox/vbox_common.c | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 9017cc3be8..69102b8ebf 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -1425,7 +1425,7 @@ virHostdevFindUSBDevice(virDomainHostdevDefPtr hostde= v, usbsrc->bus, usbsrc->device, bus, device); } - } else if (!vendor && bus) { + } else if (bus) { if (virUSBDeviceFindByBus(bus, device, NULL, mandatory, usb) < 0) return -1; } diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index f9dc18ab18..e83a019bcc 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -450,7 +450,7 @@ xenParseXLVnuma(virConfPtr conf, unsigned long long kbsize =3D 0; =20 /* Is there a sublist (vnode)? */ - if (list && list->type =3D=3D VIR_CONF_LIST) { + if (list->type =3D=3D VIR_CONF_LIST) { vnode =3D list->list; =20 while (vnode && vnode->type =3D=3D VIR_CONF_STRING) { diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 26912334d2..b902c1aba1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4711,8 +4711,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver, =20 qemuDomainObjEnterMonitor(driver, vm); =20 - if (rc =3D=3D 0 && - qemuMonitorDelObject(priv->mon, objAlias, true) < 0) + if (qemuMonitorDelObject(priv->mon, objAlias, true) < 0) rc =3D -1; =20 if (rng->backend =3D=3D VIR_DOMAIN_RNG_BACKEND_EGD && diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ec6ca14bbd..e99d9f76fe 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6888,11 +6888,11 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; VIR_DEBUG("Handshake complete, child running"); =20 - if (rv =3D=3D -1) /* The VM failed to start; tear filters before taps = */ + if (rv =3D=3D -1) { + /* The VM failed to start; tear filters before taps */ virDomainConfVMNWFilterTeardown(vm); - - if (rv =3D=3D -1) /* The VM failed to start */ goto cleanup; + } =20 if (qemuDomainObjStartWorker(vm) < 0) goto cleanup; diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 5a7f501923..977d2875fe 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -687,7 +687,7 @@ int virNetSocketNewConnectUNIX(const char *path, if (spawnDaemon) { g_autofree char *binname =3D NULL; =20 - if (spawnDaemon && !binary) { + if (!binary) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Auto-spawn of daemon requested, " "but no binary specified")); diff --git a/src/util/virlease.c b/src/util/virlease.c index 1cb9540d80..aeb605862f 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -244,7 +244,7 @@ virLeaseNew(virJSONValuePtr *lease_ret, return -1; if (ip && virJSONValueObjectAppendString(lease_new, "ip-address", ip) = < 0) return -1; - if (mac && virJSONValueObjectAppendString(lease_new, "mac-address", ma= c) < 0) + if (virJSONValueObjectAppendString(lease_new, "mac-address", mac) < 0) return -1; if (hostname && virJSONValueObjectAppendString(lease_new, "hostname", = hostname) < 0) return -1; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 15f8eb074a..bdbb929ad6 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1201,7 +1201,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine) if (disk->src->readonly) { gVBoxAPI.UIMedium.SetType(medium, MediumType_Immutable); VIR_DEBUG("Setting hard disk to immutable"); - } else if (!disk->src->readonly) { + } else { gVBoxAPI.UIMedium.SetType(medium, MediumType_Normal); VIR_DEBUG("Setting hard disk type to normal"); } --=20 2.26.2 From nobody Fri May 3 20:08:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1596406318; cv=none; d=zohomail.com; s=zohoarc; b=Dwbc3HBPO8GxKAWCT+tZgxDrVcVxhaX17jqN/XRdhedSaHtAkQVw0n4ODgyxx2FpEDlT3VTjbuY83LB/5brR1nzT/FDnnrhimZzaAe4WhuQnRve+gNsFpACRXU3b18p5e1xvQPXxVwKoaC0q3GVypWEtyAdMSpjC/kYMPHibDzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406318; 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=ew2tyrDbbodtWPDc+UxNhC3RGw6e8qwEd8/9SjNCCf8=; b=Wz6pLCdDZpWdX43e807IjeuDQruFkQ2jm4RQLieT6dHfrt7ajimANDt2HcilxPYsS3Ozv+xnXrrJ5QEo57oFVI9vBlBdzWrfYSh+88QBa7La3DoKXJKG5ILmC64P/FZx6ercDCupGxsxj212tNQfc/ce3EKemJkKVCXB8pqueV0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1596406318296531.2867266604114; Sun, 2 Aug 2020 15:11:58 -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-369-8i89IiuPMki8tG-O2knmdA-1; Sun, 02 Aug 2020 18:11:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B76CA1DE4; Sun, 2 Aug 2020 22:11:49 +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 7B3A987E1C; Sun, 2 Aug 2020 22:11:48 +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 BE6BD4EDB7; Sun, 2 Aug 2020 22:11:44 +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 072MBhrT010589 for ; Sun, 2 Aug 2020 18:11:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B0925FC2F; Sun, 2 Aug 2020 22:11:43 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id A467E5C5B7 for ; Sun, 2 Aug 2020 22:11:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406317; 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=ew2tyrDbbodtWPDc+UxNhC3RGw6e8qwEd8/9SjNCCf8=; b=UwFvpeo5UUAOmoWDrSJC1B3rz9hzmDeoM2dIDgxgVkgqF+bIeAserJW8PzenDwBsyPDCi9 BqN/lDo4RlO8bUKoXV0MiqqQX40T8Dx0k08hux8OreN2s14HZoh9284pe8Qd8P+X489CkC NmKLyxp1cgsl2KMiLAJuQ/g8bbh+qo8= X-MC-Unique: 8i89IiuPMki8tG-O2knmdA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/8] util: command: do not return after abort Date: Mon, 3 Aug 2020 00:11:26 +0200 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.11 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: Martin Kletzander --- src/util/vircommand.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 5ce69ef241..76f7eb9a3d 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1509,7 +1509,6 @@ virCommandAddArg(virCommandPtr cmd, const char *val) if (val =3D=3D NULL) { cmd->has_error =3D EINVAL; abort(); - return; } =20 arg =3D g_strdup(val); --=20 2.26.2 From nobody Fri May 3 20:08:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1596406384; cv=none; d=zohomail.com; s=zohoarc; b=j7bC42RFZQoQYDYjF6f9VJuWJlFdSDDPn3YbzsqW/g/u9UH9jxAZJr/1VTIPaBO/ivoeyfrWzcazgPc6iomwQu5odmdn49HwivNSTlX4hB0ch1+9SQIoOGWYz2mwft9Kedx22t1LzZkvY/r1ya8qrGfKMIttlFobkQMHqrki1NU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406384; 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=Fn2HVRnY0zemCc7lxsIv+50ToNyg97rMegUI+9JWbWY=; b=X8uPgaGkVd8UyYnaMwOVUysXp8NRpvsfJhrb5WIZNHYtKfkX/TnLscNVeDp1yH+MrOxNqHXNbzR3o52/qfmbCZ8c/DSWyJBxX7IL6FbcHP7FtaYQ+BJKuMVteQG7LSCYvi9mTH0XMQD3QduJDoedY9oavAIZov28Su6SUuMCWsg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1596406384289116.27623939307853; Sun, 2 Aug 2020 15:13:04 -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-148-nf_5Ae7uN1eLDg6HBYLr5A-1; Sun, 02 Aug 2020 18:12:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 96D1B800461; Sun, 2 Aug 2020 22:12:17 +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 7A24969314; Sun, 2 Aug 2020 22:12:17 +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 4AD079A0EF; Sun, 2 Aug 2020 22:12:17 +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 072MBi3A010605 for ; Sun, 2 Aug 2020 18:11:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 920FF177F9; Sun, 2 Aug 2020 22:11:44 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7D1D5C5B7 for ; Sun, 2 Aug 2020 22:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406383; 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=Fn2HVRnY0zemCc7lxsIv+50ToNyg97rMegUI+9JWbWY=; b=YSL3GuBS3cDvkNqrPvVHyDBCV3k1D/XSXtYvhW10F2gH+CuXXVfcIre6T1KCqk7fyPQrXF YpgyOuDxh7MTWRK/+5JjWJR14wLbsJ9fQKjnZLj1/JU65iYcreGE+6Vj1e2534CxtayNVn xguA0uqMVCJJK4w81KWWrpgZeXwOm4I= X-MC-Unique: nf_5Ae7uN1eLDg6HBYLr5A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/8] util: virhostmem: do not use scanf without field limits Date: Mon, 3 Aug 2020 00:11:27 +0200 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.16 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) We use an array of size VIR_NODE_MEMORY_STATS_FIELD_LENGTH to store the string read from sysfs, but pass unbound "%s" to sscanf. Make the array larger by one and simply stringify that constant as the field width specifier. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virhostmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c index 9097716f54..2f60e2a250 100644 --- a/src/util/virhostmem.c +++ b/src/util/virhostmem.c @@ -148,7 +148,7 @@ virHostMemGetStatsLinux(FILE *meminfo, int found =3D 0; int nr_param; char line[1024]; - char meminfo_hdr[VIR_NODE_MEMORY_STATS_FIELD_LENGTH]; + char meminfo_hdr[VIR_NODE_MEMORY_STATS_FIELD_LENGTH + 1]; unsigned long val; struct field_conv { const char *meminfo_hdr; /* meminfo header */ @@ -207,8 +207,10 @@ virHostMemGetStatsLinux(FILE *meminfo, buf =3D p; } =20 - if (sscanf(buf, "%s %lu kB", meminfo_hdr, &val) < 2) +# define MEM_MAX_LEN G_STRINGIFY(VIR_NODE_MEMORY_STATS_FIELD_LENGTH) + if (sscanf(buf, "%" MEM_MAX_LEN "s %lu kB", meminfo_hdr, &val) < 2) continue; +# undef MEM_MAX_LEN =20 for (j =3D 0; field_conv[j].meminfo_hdr !=3D NULL; j++) { struct field_conv *convp =3D &field_conv[j]; --=20 2.26.2 From nobody Fri May 3 20:08:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1596406344; cv=none; d=zohomail.com; s=zohoarc; b=JM2oFN0AgMNRB8esYhH0EGlNf5SXjrl+vh0ou523tWGwLB0KBj8Mli9WxExIntrEAFbMHae9SVYx5hej+8ZRWNs//BbSB5c5C84Gqf3YLPNt5cXDplC41yb34iMaUlm/+d/qlJtlgN2FL5S1HSvdOXVSn7FHa45xK+U2ZwiPxJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406344; 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=v6M4JsGHjF2AsNP5wpMxMrj2tIdLCFAVw4doaA7G9s4=; b=U4y3L+PGEUEqZl+M5TLw8opujtTnorczf3g/Y5AwerDGS5DhFzjSQl49RQoVQga4G8no6fhTeJYq8wtNSRMHL/pYREUGU796yrRWtx0eDANqHhmjGtkUEW5M7Aa18DcvBGzZjkgw1l/1jzxOtNe0H4k+mbkSCt1TxZw8phGxbqc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 159640634408496.0940357034267; Sun, 2 Aug 2020 15:12:24 -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-338-nImTV8_5PlKKmXSVMJFwtA-1; Sun, 02 Aug 2020 18:12:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5201E1893DD5; Sun, 2 Aug 2020 22:12: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 3370769318; Sun, 2 Aug 2020 22:12: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 01F181800BB2; Sun, 2 Aug 2020 22:12:15 +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 072MBjRc010616 for ; Sun, 2 Aug 2020 18:11:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id B164857; Sun, 2 Aug 2020 22:11:45 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C9125C5B7 for ; Sun, 2 Aug 2020 22:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406342; 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=v6M4JsGHjF2AsNP5wpMxMrj2tIdLCFAVw4doaA7G9s4=; b=gmjP/tumc5oqdkhL7RrPD4E8grYTfW5WExYJX9eS58f+q71xwdbXnFHt0712Ofa4rG7T36 Wj53rI7gERUmnkMygRlTZoUd85HW0eE/cl79G1ikik8ViL0UuiBBYZ1U8NpINGogpbhtHJ ur8Jmm7Dh/A0x9vYFSRPY40PNBvQwh4= X-MC-Unique: nImTV8_5PlKKmXSVMJFwtA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/8] util: sync variable names between header and C files Date: Mon, 3 Aug 2020 00:11:28 +0200 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.16 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: Martin Kletzander --- src/util/virresctrl.h | 2 +- src/util/virsocketaddr.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/virresctrl.h b/src/util/virresctrl.h index dcd9ca2bb2..2f84401dfb 100644 --- a/src/util/virresctrl.h +++ b/src/util/virresctrl.h @@ -151,7 +151,7 @@ virResctrlAllocSetMemoryBandwidth(virResctrlAllocPtr al= loc, unsigned int memory_bandwidth); =20 int -virResctrlAllocForeachMemory(virResctrlAllocPtr resctrl, +virResctrlAllocForeachMemory(virResctrlAllocPtr alloc, virResctrlAllocForeachMemoryCallback cb, void *opaque); =20 diff --git a/src/util/virsocketaddr.h b/src/util/virsocketaddr.h index d06e751f73..6c08f8b35c 100644 --- a/src/util/virsocketaddr.h +++ b/src/util/virsocketaddr.h @@ -83,10 +83,10 @@ int virSocketAddrParseIPv6(virSocketAddrPtr addr, =20 int virSocketAddrResolveService(const char *service); =20 -void virSocketAddrSetIPv4AddrNetOrder(virSocketAddrPtr s, uint32_t addr); -void virSocketAddrSetIPv4Addr(virSocketAddrPtr s, uint32_t addr); -void virSocketAddrSetIPv6AddrNetOrder(virSocketAddrPtr s, uint32_t addr[4]= ); -void virSocketAddrSetIPv6Addr(virSocketAddrPtr s, uint32_t addr[4]); +void virSocketAddrSetIPv4AddrNetOrder(virSocketAddrPtr addr, uint32_t val); +void virSocketAddrSetIPv4Addr(virSocketAddrPtr addr, uint32_t val); +void virSocketAddrSetIPv6AddrNetOrder(virSocketAddrPtr addr, uint32_t val[= 4]); +void virSocketAddrSetIPv6Addr(virSocketAddrPtr addr, uint32_t val[4]); =20 char *virSocketAddrFormat(const virSocketAddr *addr); char *virSocketAddrFormatFull(const virSocketAddr *addr, --=20 2.26.2 From nobody Fri May 3 20:08:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1596406395; cv=none; d=zohomail.com; s=zohoarc; b=bxeqsMloKF9sSgYJCPV+/GyoidIP/FCleYwz++voOWlO9/gFl+KYtwH1C8cAtUvTyMzQANjuAja9VO5K8w4/6Wk9222acHpjRjIbMeNF/LJaLPRxLkGLwoopkgsh/nbxn+xyd9Lc2UAiuW0ItSvAVrJamYuooVYtlWtSy2bUZCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406395; 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=7Icu1gTh0bAhOnjYM3UmRvc/SdtHb3lbHu1JdF4VwJ4=; b=jgjtneGxM1eXZSNffTLLwMkto0Sl+yw0c2CPCKjxrLXVxScrBBgVd5CnF51qeliNqfoHSg7f/rrAQUwvouHqD4xRT9/Q2ExsnwIDlSPK7avECJ5Ug//y2Zl4mG83Bd6BMKEt/POGuT7LHOQYW4AnbCxOA1rtNpRXNAnw4Sj6uGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1596406395854105.9097083797601; Sun, 2 Aug 2020 15:13:15 -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-322-7WqjotlmO32-JbjKiF4nLA-1; Sun, 02 Aug 2020 18:12:25 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBDC910059AA; Sun, 2 Aug 2020 22:12:17 +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 9717B6115F; Sun, 2 Aug 2020 22:12:17 +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 6A5269A0FB; Sun, 2 Aug 2020 22:12:17 +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 072MBkDR010629 for ; Sun, 2 Aug 2020 18:11:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id D13175FC36; Sun, 2 Aug 2020 22:11:46 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 215F75FC2F for ; Sun, 2 Aug 2020 22:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406394; 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=7Icu1gTh0bAhOnjYM3UmRvc/SdtHb3lbHu1JdF4VwJ4=; b=d4iROqo3q/6BxeCEhLf5FE04dM9gnDcMLXvpnEbEYqFs5nSGEYDb8d6na4OdIWMECFqMIT kiNjNQ3LUzuFkcB+bc38vzzAi+7DDnbIP7gKnUFesHSqQvKSoI2XZ4fHNDj1pA61k3OgMx u9n8sDwR6j0/Kj9nDaSBY5fXEkunvb0= X-MC-Unique: 7WqjotlmO32-JbjKiF4nLA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/8] virsh: completer: use signed variable for XPathNodeSet errors Date: Mon, 3 Aug 2020 00:11:29 +0200 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.12 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) Although virXPathNodeSet is unlikely to return -1, we should check for it properly or not at all. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-completer-host.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index 35e6bba661..8893888ec2 100644 --- a/tools/virsh-completer-host.c +++ b/tools/virsh-completer-host.c @@ -55,7 +55,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, { g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControlPtr priv =3D ctl->privData; - unsigned int npages =3D 0; + int npages =3D 0; g_autofree xmlNodePtr *pages =3D NULL; g_autoptr(xmlDoc) doc =3D NULL; size_t i =3D 0; @@ -106,7 +106,7 @@ virshCellnoCompleter(vshControl *ctl, { g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControlPtr priv =3D ctl->privData; - unsigned int ncells =3D 0; + int ncells =3D 0; g_autofree xmlNodePtr *cells =3D NULL; g_autoptr(xmlDoc) doc =3D NULL; size_t i =3D 0; --=20 2.26.2 From nobody Fri May 3 20:08:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1596406349; cv=none; d=zohomail.com; s=zohoarc; b=YCIK9kP9nNXreQqeiP0BHvwXD7wGDm7wPOZdVuT/arvmb6QJvKeO35ldE74DH/tseaTQBA4z/jkE7YgKFMU9/2E1evVaoQVHGiujOnyE5In3pWmGw8plzRES2Nrwi0RokWqVd2w91qhOWdA/GQyBncO8LwU1JDovieLXecR8Z+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406349; 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=3y5144SAO6p2ff8i5Dlv1Z3njRinPPUqaMK1czhXdPU=; b=eqrNAy6D/q/NCNiDW2ufmRs6DSYcV5RcX/n8UA4HwtDxl+NuJLFsv+C8MfMLQC0fY3cmm/LO0m9yKNMwV9gYbnVzWclF9Lxt+glWpDnMlpDqAe+KMsOv+KA2+mTXfEVwjfrgP400ic8kH3xO6aatVO/cpCAUnKZxykyZXBoaLCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1596406349517978.005828132408; Sun, 2 Aug 2020 15:12:29 -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-381-J93o9D5UM2eJc1RCF3QZSw-1; Sun, 02 Aug 2020 18:12:26 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D1B510059BE; Sun, 2 Aug 2020 22:12:20 +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 DE8AD10013C1; Sun, 2 Aug 2020 22:12:19 +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 AE7DE9A10D; Sun, 2 Aug 2020 22:12:19 +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 072MBnEs010652 for ; Sun, 2 Aug 2020 18:11:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7DC6769314; Sun, 2 Aug 2020 22:11:49 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D7E61799 for ; Sun, 2 Aug 2020 22:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406348; 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=3y5144SAO6p2ff8i5Dlv1Z3njRinPPUqaMK1czhXdPU=; b=DYK79wMMgYKhrB8dnwuW2Vi+5LmaT0WLv+iqsReUTt6SqyeGXhi65Y5Lo/G2WmXay0lMB9 l8RSgUDFXNbBRNt+aDM5g2BCX8pYHWgT3Pqeoqg3hSU5ByOF/a5uKqnj4pi8XJqYUXf0hJ LDGT0VqB6mSW66XGz8xxIRVLzU7dlM0= X-MC-Unique: J93o9D5UM2eJc1RCF3QZSw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 7/8] tools: remove unread variables Date: Mon, 3 Aug 2020 00:11:30 +0200 Message-Id: <5d5b57f8f900330a2999b41f5415d3cfbc2d2165.1596406221.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.84 on 10.5.11.22 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) Some of libvirt APIs return the number of elements, but we don't need them, only whether the API failed or not. Delete the redundant variables. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain.c | 7 +++---- tools/virt-admin.c | 9 +++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index aaf3b9a6a5..97d6427638 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6886,7 +6886,6 @@ virshVcpuinfoInactive(vshControl *ctl, { g_autofree unsigned char *cpumaps =3D NULL; size_t cpumaplen; - int ncpus; g_autoptr(virBitmap) vcpus =3D NULL; ssize_t nextvcpu =3D -1; bool first =3D true; @@ -6897,9 +6896,9 @@ virshVcpuinfoInactive(vshControl *ctl, cpumaplen =3D VIR_CPU_MAPLEN(maxcpu); cpumaps =3D vshMalloc(ctl, virBitmapSize(vcpus) * cpumaplen); =20 - if ((ncpus =3D virDomainGetVcpuPinInfo(dom, virBitmapSize(vcpus), - cpumaps, cpumaplen, - VIR_DOMAIN_AFFECT_CONFIG)) < 0) + if (virDomainGetVcpuPinInfo(dom, virBitmapSize(vcpus), + cpumaps, cpumaplen, + VIR_DOMAIN_AFFECT_CONFIG) < 0) return false; =20 while ((nextvcpu =3D virBitmapNextSetBit(vcpus, nextvcpu)) >=3D 0) { diff --git a/tools/virt-admin.c b/tools/virt-admin.c index fef0332a0d..4856758b4e 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1040,7 +1040,6 @@ static const vshCmdOptDef opts_daemon_log_filters[] = =3D { static bool cmdDaemonLogFilters(vshControl *ctl, const vshCmd *cmd) { - int nfilters; char *filters =3D NULL; vshAdmControlPtr priv =3D ctl->privData; =20 @@ -1052,8 +1051,8 @@ cmdDaemonLogFilters(vshControl *ctl, const vshCmd *cm= d) return false; } } else { - if ((nfilters =3D virAdmConnectGetLoggingFilters(priv->conn, - &filters, 0)) < 0) { + if (virAdmConnectGetLoggingFilters(priv->conn, + &filters, 0) < 0) { vshError(ctl, _("Unable to get daemon logging filters informat= ion")); return false; } @@ -1094,7 +1093,6 @@ static const vshCmdOptDef opts_daemon_log_outputs[] = =3D { static bool cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd) { - int noutputs; char *outputs =3D NULL; vshAdmControlPtr priv =3D ctl->privData; =20 @@ -1106,8 +1104,7 @@ cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cm= d) return false; } } else { - if ((noutputs =3D virAdmConnectGetLoggingOutputs(priv->conn, - &outputs, 0)) < 0) { + if (virAdmConnectGetLoggingOutputs(priv->conn, &outputs, 0) < 0) { vshError(ctl, _("Unable to get daemon logging outputs informat= ion")); return false; } --=20 2.26.2 From nobody Fri May 3 20:08:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1596406351; cv=none; d=zohomail.com; s=zohoarc; b=LzqU1kh7F7v6Z5F9wiueJ4anUf3O1c/lUOyPYYIH7WoRsr5DEHMwT5kpgNSLPOguZFj6RnRGBhL3ZZ3rMlJMFY65JkG7zsYJT1BfO2R4EW6fM7XeWV9WDgx8DF+pZKUI0N9x9aLLKi2eg2uckoCwhI4Xixp3dHBkTy0y4np7dxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596406351; 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=jbsRosP4f2+ouecxavF8jOOa9+0avisObVylBbl5wtE=; b=PVxqSqJG/ikxHy8PtAuoi+GzA1xeyQ16s9NFW2TUlBn+uMWeUlI2IlkbCP9b2wlFWbBPFrwiM/BdxLYiPHIlNWplITx825NJarsNiiRoOAoxXqgsAeOjiyD7lC9SjrRylXLpPst+VN4abEKNaWkdDReBLX5AvknK7UIW2O+TaYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1596406351584328.2571364730859; Sun, 2 Aug 2020 15:12:31 -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-21-t5jmb3jYN6OobcNZ1qrvCQ-1; Sun, 02 Aug 2020 18:12:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48A5610059A9; Sun, 2 Aug 2020 22:12:22 +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 2A98387E27; Sun, 2 Aug 2020 22:12:22 +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 E88181800BB2; Sun, 2 Aug 2020 22:12:21 +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 072MBrXA010670 for ; Sun, 2 Aug 2020 18:11:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A11E5C5B7; Sun, 2 Aug 2020 22:11:53 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id A68AF5FC2F for ; Sun, 2 Aug 2020 22:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596406350; 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=jbsRosP4f2+ouecxavF8jOOa9+0avisObVylBbl5wtE=; b=Dvn5FVY7Zy4YCz5dewW9P+kfM3uSnmAxa1++rcedWM4OCqO04kkFQlYTHJ7GjT88wGCJs1 PZ2cbwEO/DGoA04Bi/8lVyRTkWwAGFB3/YvbitBeyHJtYBglYRj8wB5OIHh9hEqbj1v7N3 BYv0phgKh6giZ115mNsR07Y9fnWFKPs= X-MC-Unique: t5jmb3jYN6OobcNZ1qrvCQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 8/8] tools: virt-admin: do not leak daemon-log settings Date: Mon, 3 Aug 2020 00:11:31 +0200 Message-Id: <2c9c05a1f5e942a6fa610b364098bb5670fde9a7.1596406221.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.11 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 commands daemon-log-filters and daemon-log-outputs are used both for getting and setting the variables. But the getter receives an allocated string, which we do not free. Use separate variables for the getter and the setter to get rid of the memory leak and to stop casting away the const. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virt-admin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 4856758b4e..07d5f49825 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1040,17 +1040,17 @@ static const vshCmdOptDef opts_daemon_log_filters[]= =3D { static bool cmdDaemonLogFilters(vshControl *ctl, const vshCmd *cmd) { - char *filters =3D NULL; vshAdmControlPtr priv =3D ctl->privData; =20 if (vshCommandOptBool(cmd, "filters")) { - if ((vshCommandOptStringReq(ctl, cmd, "filters", - (const char **) &filters) < 0 || + const char *filters =3D NULL; + if ((vshCommandOptStringReq(ctl, cmd, "filters", &filters) < 0 || virAdmConnectSetLoggingFilters(priv->conn, filters, 0) < 0)) { vshError(ctl, _("Unable to change daemon logging settings")); return false; } } else { + g_autofree char *filters =3D NULL; if (virAdmConnectGetLoggingFilters(priv->conn, &filters, 0) < 0) { vshError(ctl, _("Unable to get daemon logging filters informat= ion")); @@ -1093,17 +1093,17 @@ static const vshCmdOptDef opts_daemon_log_outputs[]= =3D { static bool cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd) { - char *outputs =3D NULL; vshAdmControlPtr priv =3D ctl->privData; =20 if (vshCommandOptBool(cmd, "outputs")) { - if ((vshCommandOptStringReq(ctl, cmd, "outputs", - (const char **) &outputs) < 0 || + const char *outputs =3D NULL; + if ((vshCommandOptStringReq(ctl, cmd, "outputs", &outputs) < 0 || virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) { vshError(ctl, _("Unable to change daemon logging settings")); return false; } } else { + g_autofree char *outputs =3D NULL; if (virAdmConnectGetLoggingOutputs(priv->conn, &outputs, 0) < 0) { vshError(ctl, _("Unable to get daemon logging outputs informat= ion")); return false; --=20 2.26.2