From nobody Sun May 19 15:29:28 2024 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=1691058996; cv=none; d=zohomail.com; s=zohoarc; b=PhSmdP4W1bns4cmZzEsOOAjC033vhS8OXePB2jCfNXlEsn+JvYxBLLySSeWpdaEDgz9dkuEC9QjO4VENAdp+rwRCH6G3+us+coqosVKmHeXQvsojXewT1GeTuRmqLhxehhdJDVNUSfljsVx3gLenrmDgVIxlt2JABRRHab23slk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691058996; 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=Wo3usVoSNPrwtszWYxyGbn/p1aom04kI05SNjQ1zyn8=; b=ceWmjbB1p+yPNUa3zFkPKRWXJmF7wyNZ8POwY4QckH4bStY2B2xSwFMx/4VLrgeKypahQwmMBkuwcVzRxIpzwJTlfpq1ZlP0eeteCk7/VI3kkG3L/6SF2L0XOMXDDFLkjl3gjFmDS2W3uHo6/h7nqlgzeMaDLFVpL1UG0aFJylg= 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 1691058996556361.10625704648555; Thu, 3 Aug 2023 03:36:36 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-690-JjBm4yGhPP2KaD0eMlqTgw-1; Thu, 03 Aug 2023 06:36:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F088F3C0C4A3; Thu, 3 Aug 2023 10:36:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7C4C40C6CCC; Thu, 3 Aug 2023 10:36:26 +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 5ED311947230; Thu, 3 Aug 2023 10:36:25 +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 7AAD81946A45 for ; Thu, 3 Aug 2023 10:36:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6B398F7FA6; Thu, 3 Aug 2023 10:36:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12B3FF77BD for ; Thu, 3 Aug 2023 10:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691058992; 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=Wo3usVoSNPrwtszWYxyGbn/p1aom04kI05SNjQ1zyn8=; b=WktmMREnlF77E/NUz/oyq5mvDuAd35CtoY53Mn9RZR+3s58q09nF0rDae0PfUVLzRtSsnC 3C51ENUdS5I7qWN4TqNm5n/yuK632mkYi4vlRf/OyVeimbH0Te0KYu+vSW11BItEIayt7b sBaA+lt/ovH/vA7G3oRJhOpYZzEIcjY= X-MC-Unique: JjBm4yGhPP2KaD0eMlqTgw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 01/13] tools: Fix vshControl declaration and initialization Date: Thu, 3 Aug 2023 12:36:08 +0200 Message-ID: <94b61f4472665c7f953bc2812ff6130a21f0aaea.1691058853.git.mprivozn@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.2 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: 1691058997011100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Both virsh and virt-admin have vshControl typed variables and also pointers to these variables. In both cases these are declared on a single line. Do the following: 1) break declaration into two lines, 2) use struct zero initializer for vshControl and virshControl/vshAdmControl structs, 3) drop explicit memset(.., 0, ...) ; Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- tools/virsh.c | 7 +++---- tools/virt-admin.c | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 963e886860..40c23e4180 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -831,12 +831,11 @@ static const vshClientHooks hooks =3D { int main(int argc, char **argv) { - vshControl _ctl, *ctl =3D &_ctl; - virshControl virshCtl; + vshControl _ctl =3D { 0 }; + vshControl *ctl =3D &_ctl; + virshControl virshCtl =3D { 0 }; bool ret =3D true; =20 - memset(ctl, 0, sizeof(vshControl)); - memset(&virshCtl, 0, sizeof(virshControl)); ctl->name =3D "virsh"; /* hardcoded name of the binary */ ctl->env_prefix =3D "VIRSH"; ctl->log_fd =3D -1; /* Initialize log file descriptor */ diff --git a/tools/virt-admin.c b/tools/virt-admin.c index db246dc3a6..9d01890447 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1554,12 +1554,11 @@ static const vshClientHooks hooks =3D { int main(int argc, char **argv) { - vshControl _ctl, *ctl =3D &_ctl; - vshAdmControl virtAdminCtl; + vshControl _ctl =3D { 0 }; + vshControl *ctl =3D &_ctl; + vshAdmControl virtAdminCtl =3D { 0 }; bool ret =3D true; =20 - memset(ctl, 0, sizeof(vshControl)); - memset(&virtAdminCtl, 0, sizeof(vshAdmControl)); ctl->name =3D "virt-admin"; /* hardcoded name of the binary */ ctl->env_prefix =3D "VIRT_ADMIN"; ctl->log_fd =3D -1; /* Initialize log file descriptor */ --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 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=1691059023; cv=none; d=zohomail.com; s=zohoarc; b=h3ECWroZO9AMz0HJP3VoB9wfAycjWeKT8T4QghESAwPlyUuAkaMAGAJR1NOf/4lANhgW2jn7uT9wrSTqNaqq8RM5QC+9dBlOJ57g/vhdP3sH+zzCGnqrPeINeb/JGPzR87KXHYmvY7vJPV7VtYS19EBxxwrUt03xHSqoqoSw3uY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059023; 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=k+5HISJmaXA1wbSYQpEt3JITeINECTqaCtIZZpuZ+sU=; b=h5z3E61gRXiZok3Gpt3q+0F4laUInaYJ8RPIDvy6krXFcBGAZdwOj6VtiH9GIvurszW4EbOP+9/lkssZ+38HrpdejChAIux3bE66uaF/4vJJu3BVWvbXDP4nWdJHS/3ZCf8U6z6QXqRGoNzTFKRKlMBMMGTgPRN2JgJhe+R1s00= 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 1691059023762230.8206994587116; Thu, 3 Aug 2023 03:37:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-655-axgHiai1OLeAhZXzymo5AQ-1; Thu, 03 Aug 2023 06:36:29 -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 EF9B71C05B06; Thu, 3 Aug 2023 10:36:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CEAA48FB00; Thu, 3 Aug 2023 10:36:25 +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 AD68C1947222; Thu, 3 Aug 2023 10:36:24 +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 238A91946A78 for ; Thu, 3 Aug 2023 10:36:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0681EF7FA6; Thu, 3 Aug 2023 10:36:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2263F7FBA for ; Thu, 3 Aug 2023 10:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059022; 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=k+5HISJmaXA1wbSYQpEt3JITeINECTqaCtIZZpuZ+sU=; b=FPpTnPQkQ2zpDjAIVllbdjjbpt2gEyCG4c8J9CM+DlTMFNdb0lU6mlMD69ax4C3Xf25+rV VxaCU8qyf2+FpjKTlxLj85L0qs+kl6c9GDYuWRA6rzB8YwgoBkzCwKlH5xJQ6sdx0Ulms3 wz5urLEIF+TCv4/C0uaevHoFkWocYAI= X-MC-Unique: axgHiai1OLeAhZXzymo5AQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/13] virt-aa-helper: Use struct zero initializer instead of memset Date: Thu, 3 Aug 2023 12:36:09 +0200 Message-ID: <55a87f03b758722453d98bc912d14c165f166053.1691058853.git.mprivozn@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: 1691059024664100003 Content-Type: text/plain; charset="utf-8"; x-default="true" This is similar to the previous commit, except this is for a different type (vahControl) and also fixes the case where _ctl is passed not initialized to vah_error() (via ctl pointer so that's probably why compilers don't complain). Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/security/virt-aa-helper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 3ee59b32bb..da1e4fc3e4 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1433,7 +1433,8 @@ vahParseArgv(vahControl * ctl, int argc, char **argv) int main(int argc, char **argv) { - vahControl _ctl, *ctl =3D &_ctl; + vahControl _ctl =3D { 0 }; + vahControl *ctl =3D &_ctl; int rc =3D -1; char *profile =3D NULL; char *include_file =3D NULL; @@ -1466,8 +1467,6 @@ main(int argc, char **argv) else progname++; =20 - memset(ctl, 0, sizeof(vahControl)); - if (vahParseArgv(ctl, argc, argv) !=3D 0) vah_error(ctl, 1, _("could not parse arguments")); =20 --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 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=1691059001; cv=none; d=zohomail.com; s=zohoarc; b=CS2cEYuC049sxTP/Lqb6qA5AxXSvKEF+5ptZt91qps3Cuc55Pd+O8Fr/7LzViy0EQ7r/u1L9YU9Pr7rnCROLbaErVqRdMBDaXPBgFrF+39WXqbl9+zFSYDExSSeFmqv+Rt3mkRyvbxgjfh6E6i6C5SjntuN47jRexdelb1rIi4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059001; 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=Ug49Nvq2zJgOt6XiWK/SMMuRyl6AqpLNuxwpTYFzmEA=; b=P2m0ufwU99WNkuofJ+yimM5YmagbCAQxoN0oc8/0eaxk4FL385M8IbGYZiTq4N4CLmsWvg2hG85raqeN3lUbrKQJVifOdJz69SFNGOMnxV8cjE9RIXDAZrlzXGJ7x3iFBiUYrwL8IblZB/4pnJiPQs3EqY+ZMGUAnkl7ic7qmwU= 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 169105900163489.53226482614093; Thu, 3 Aug 2023 03:36:41 -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-638-fgTs3dwpMH2ZonA08qX0rA-1; Thu, 03 Aug 2023 06:36:35 -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 B1D9D830DB6; Thu, 3 Aug 2023 10:36:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 889A6492CB1; Thu, 3 Aug 2023 10:36:27 +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 E9C3E1947223; Thu, 3 Aug 2023 10:36:25 +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 B99051947226 for ; Thu, 3 Aug 2023 10:36:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 96BA3F77BD; Thu, 3 Aug 2023 10:36:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DE5AF7FA6 for ; Thu, 3 Aug 2023 10:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059000; 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=Ug49Nvq2zJgOt6XiWK/SMMuRyl6AqpLNuxwpTYFzmEA=; b=g7qnU638TDd+lnsqyVgV4aUuWC369mbC+DbBYuXAIC2UzSQQNIlddquI6VbEdEfAvFGQVX XQB8jCMZtIZlJ/ZCExzZx2YLUsCih2rDEDE0H3CuK2IlRdOnqG60tH/mY2GPJ4FL3kEche ac1xF2SC31Y4Bjg9eRUvFeUUIlPwuyU= X-MC-Unique: fgTs3dwpMH2ZonA08qX0rA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 03/13] Decrease scope of some variables Date: Thu, 3 Aug 2023 12:36:10 +0200 Message-ID: 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: 1691059002785100003 Content-Type: text/plain; charset="utf-8"; x-default="true" There are couple of variables that are declared at function beginning but then used solely within a block (either for() loop or if() statement). And just before their use they are zeroed explicitly using memset(). Decrease their scope, use struct zero initializer and drop explicit memset(). Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/qemu/qemu_driver.c | 4 +--- src/remote/remote_driver.c | 7 +++---- src/rpc/virnetsshsession.c | 5 ++--- src/util/virnetdevmacvlan.c | 3 +-- src/util/virnetdevtap.c | 6 ++---- src/util/viruuid.c | 4 ++-- tests/virnetsockettest.c | 7 ++----- tools/virsh-domain-monitor.c | 7 ++----- 8 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 497923ffee..1d7b78d73b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17124,7 +17124,6 @@ qemuDomainGetStatsInterface(virQEMUDriver *driver G= _GNUC_UNUSED, unsigned int privflags G_GNUC_UNUSED) { size_t i; - struct _virDomainInterfaceStats tmp; =20 if (!virDomainObjIsActive(dom)) return 0; @@ -17135,12 +17134,11 @@ qemuDomainGetStatsInterface(virQEMUDriver *driver= G_GNUC_UNUSED, for (i =3D 0; i < dom->def->nnets; i++) { virDomainNetDef *net =3D dom->def->nets[i]; virDomainNetType actualType; + struct _virDomainInterfaceStats tmp =3D { 0 }; =20 if (!net->ifname) continue; =20 - memset(&tmp, 0, sizeof(tmp)); - actualType =3D virDomainNetGetActualType(net); =20 virTypedParamListAddString(params, net->ifname, "net.%zu.name", i); diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 65ec239fb7..d775f65fe2 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3728,8 +3728,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_dat= a *priv, remote_auth_sasl_init_ret iret; remote_auth_sasl_start_args sargs =3D {0}; remote_auth_sasl_start_ret sret; - remote_auth_sasl_step_args pargs =3D {0}; - remote_auth_sasl_step_ret pret; const char *clientout; char *serverin =3D NULL; size_t clientoutlen, serverinlen; @@ -3866,6 +3864,9 @@ remoteAuthSASL(virConnectPtr conn, struct private_dat= a *priv, * Even if the server has completed, the client must *always* do at le= ast one step * in this loop to verify the server isn't lying about something. Mutu= al auth */ for (;;) { + remote_auth_sasl_step_args pargs =3D { 0 }; + remote_auth_sasl_step_ret pret =3D { 0 }; + if ((err =3D virNetSASLSessionClientStep(sasl, serverin, serverinlen, @@ -3893,14 +3894,12 @@ remoteAuthSASL(virConnectPtr conn, struct private_d= ata *priv, =20 /* Not done, prepare to talk with the server for another iteration= */ /* NB, distinction of NULL vs "" is *critical* in SASL */ - memset(&pargs, 0, sizeof(pargs)); pargs.nil =3D clientout ? 0 : 1; pargs.data.data_val =3D (char*)clientout; pargs.data.data_len =3D clientoutlen; VIR_DEBUG("Server step with %zu bytes %p", clientoutlen, clientout); =20 - memset(&pret, 0, sizeof(pret)); if (call(conn, priv, 0, REMOTE_PROC_AUTH_SASL_STEP, (xdrproc_t) xdr_remote_auth_sasl_step_args, (char *) &par= gs, (xdrproc_t) xdr_remote_auth_sasl_step_ret, (char *) &pret= ) !=3D 0) diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index 1df43bb044..98be120a11 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -271,7 +271,6 @@ virNetSSHCheckHostKey(virNetSSHSession *sess) size_t keyLength; char *errmsg; g_auto(virBuffer) buff =3D VIR_BUFFER_INITIALIZER; - virConnectCredential askKey; struct libssh2_knownhost *knownHostEntry =3D NULL; size_t i; char *hostnameStr =3D NULL; @@ -303,6 +302,8 @@ virNetSSHCheckHostKey(virNetSSHSession *sess) case LIBSSH2_KNOWNHOST_CHECK_NOTFOUND: /* key was not found, query to add it to database */ if (sess->hostKeyVerify =3D=3D VIR_NET_SSH_HOSTKEY_VERIFY_NORMAL) { + virConnectCredential askKey =3D { 0 }; + /* ask to add the key */ if (!sess->cred || !sess->cred->cb) { virReportError(VIR_ERR_SSH, "%s", @@ -312,8 +313,6 @@ virNetSSHCheckHostKey(virNetSSHSession *sess) } =20 /* prepare data for the callback */ - memset(&askKey, 0, sizeof(virConnectCredential)); - for (i =3D 0; i < sess->cred->ncredtype; i++) { if (sess->cred->credtype[i] =3D=3D VIR_CRED_ECHOPROMPT) break; diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index db5f41bae8..cde9d70eef 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -217,12 +217,11 @@ int virNetDevMacVLanTapSetup(int *tapfd, size_t tapfdSize, bool vnet_hdr) { unsigned int features; - struct ifreq ifreq; short new_flags =3D 0; size_t i; =20 for (i =3D 0; i < tapfdSize; i++) { - memset(&ifreq, 0, sizeof(ifreq)); + struct ifreq ifreq =3D { 0 }; =20 if (ioctl(tapfd[i], TUNGETIFF, &ifreq) < 0) { virReportSystemError(errno, "%s", diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index b85b753c96..3e25f18770 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -172,7 +172,6 @@ int virNetDevTapCreate(char **ifname, unsigned int flags) { size_t i =3D 0; - struct ifreq ifr; int rc; int ret =3D -1; int fd =3D -1; @@ -204,8 +203,9 @@ int virNetDevTapCreate(char **ifname, if (!tunpath) tunpath =3D "/dev/net/tun"; =20 - memset(&ifr, 0, sizeof(ifr)); for (i =3D 0; i < tapfdSize; i++) { + struct ifreq ifr =3D { 0 }; + if ((fd =3D open(tunpath, O_RDWR)) < 0) { virReportSystemError(errno, _("Unable to open %1$s, is tun module loa= ded?"), @@ -213,8 +213,6 @@ int virNetDevTapCreate(char **ifname, goto cleanup; } =20 - memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_flags =3D IFF_TAP | IFF_NO_PI; /* If tapfdSize is greater than one, request multiqueue */ if (tapfdSize > 1) diff --git a/src/util/viruuid.c b/src/util/viruuid.c index ca22c91d48..a4f3a50fa5 100644 --- a/src/util/viruuid.c +++ b/src/util/viruuid.c @@ -215,13 +215,13 @@ int virSetHostUUIDStr(const char *uuid) { int rc; - char dmiuuid[VIR_UUID_STRING_BUFLEN]; =20 if (virUUIDIsValid(host_uuid)) return EEXIST; =20 if (!uuid) { - memset(dmiuuid, 0, sizeof(dmiuuid)); + char dmiuuid[VIR_UUID_STRING_BUFLEN] =3D { 0 }; + if (!getDMISystemUUID(dmiuuid, sizeof(dmiuuid))) { if (!virUUIDParse(dmiuuid, host_uuid)) return 0; diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 2295e29777..0e9cd8a81c 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -44,8 +44,6 @@ static int checkProtocols(bool *hasIPv4, bool *hasIPv6, int *freePort) { - struct sockaddr_in in4; - struct sockaddr_in6 in6; size_t i; =20 *freePort =3D 0; @@ -53,6 +51,8 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6, return -1; =20 for (i =3D 0; i < 50; i++) { + struct sockaddr_in in4 =3D { 0 }; + struct sockaddr_in6 in6 =3D { 0 }; VIR_AUTOCLOSE s4 =3D -1; VIR_AUTOCLOSE s6 =3D -1; =20 @@ -71,9 +71,6 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6, return -1; } =20 - memset(&in4, 0, sizeof(in4)); - memset(&in6, 0, sizeof(in6)); - in4.sin_family =3D AF_INET; in4.sin_port =3D htons(BASE_PORT + i); in4.sin_addr.s_addr =3D htonl(INADDR_LOOPBACK); diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index ec99b9f99a..c74fc19347 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -444,7 +444,6 @@ cmdDomblkinfoGet(const virDomainBlockInfo *info, static bool cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) { - virDomainBlockInfo info; g_autoptr(virshDomain) dom =3D NULL; bool human =3D false; bool all =3D false; @@ -491,6 +490,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) g_autofree char *cap =3D NULL; g_autofree char *alloc =3D NULL; g_autofree char *phy =3D NULL; + virDomainBlockInfo info =3D { 0 }; =20 ctxt->node =3D disks[i]; protocol =3D virXPathString("string(./source/@protocol)", ctxt= ); @@ -513,10 +513,6 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) return false; } } - } else { - /* if we don't call virDomainGetBlockInfo() who clears 'in= fo' - * we have to do it manually */ - memset(&info, 0, sizeof(info)); } =20 if (!cmdDomblkinfoGet(&info, &cap, &alloc, &phy, human)) @@ -531,6 +527,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) g_autofree char *cap =3D NULL; g_autofree char *alloc =3D NULL; g_autofree char *phy =3D NULL; + virDomainBlockInfo info =3D { 0 }; =20 if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) return false; --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1691058996; cv=none; d=zohomail.com; s=zohoarc; b=hn5eVufcqi1G1rA71EnVqwVkslfFWR38j0j50A6cn6Sdxr8TSlyhbEY4pW5QOt/M+NTWEwnxOQx7m1ll80EOqENp6TzLVNanQfUfK2fp9iT18Pm43hTyrONUTiBbA1rZ3sgRFbeVbXbVUzFrEnSu2/ZAHDYi7zA4aAfxQ1h8gKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691058996; 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=/6vj1OvpGEWj0+goLA1sEk5YFdcXQy0lawZRoE5ggWk=; b=WupV/+F1oT8Mq5GRIiidIjfEhUmlPYBr3nAvw0SthxxDS/9CaGTFhhB1ZdTSx6Z90QM+WzWfF8WCHPEdoSHmfbKRDttGgOgN8C0ZwVbeBhGrZH8qhiBUYg3st1rh2LYhdgzeHnc6lBJdCsX4LDmFJ2VzjlUYKYvUC3SMvc+oXlg= 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 1691058996528434.9925786777875; Thu, 3 Aug 2023 03:36:36 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-253-VLnATJ72P1uKP9nR6Tp8Hg-1; Thu, 03 Aug 2023 06:36:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A5D31C05ED2; Thu, 3 Aug 2023 10:36:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 370D62166B2B; Thu, 3 Aug 2023 10:36:28 +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 2DE6419452C8; Thu, 3 Aug 2023 10:36:26 +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 52C491947209 for ; Thu, 3 Aug 2023 10:36:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3212EF7FB4; Thu, 3 Aug 2023 10:36:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD7AEF77BD for ; Thu, 3 Aug 2023 10:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691058995; 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=/6vj1OvpGEWj0+goLA1sEk5YFdcXQy0lawZRoE5ggWk=; b=bV/zgV/L0FO2D7nBaaXuMt1mTG6dvXudfAfGu0U7I8bV6B1bbUPRW2NAHw0k6kXQ/S6sF2 vWLiykDvWBFoDlMQCsYR/AhJoSTsQ4UydOYdQvia8631cXXMWptrgCjiH034Af5AV9b4Bt VzRcFwZIk5XZtYfs9TWPzfc940oYqn4= X-MC-Unique: VLnATJ72P1uKP9nR6Tp8Hg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 04/13] qemu: Don't reuse variable in processSerialChangedEvent() Date: Thu, 3 Aug 2023 12:36:11 +0200 Message-ID: <1dee2b2a9b11689dc1de49a6032a79bbb20fa52f.1691058853.git.mprivozn@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.6 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: 1691059001267100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When a VSERPORT_CHANGE event is processed, we firstly do a little detour and try to detect whether the event is coming from guest agent. If so, we notify threads that are currently talking to the agent about this fact. Then we proceed with usual event processing (BeginJob(), update domain def, emit event, and so on). In both cases we use the same @dev variable to refer to domain device. While this works, it will make writing semantic patch unnecessary harder (see next commit(s)). Therefore, introduce a separate variable for the detour code. Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/qemu/qemu_driver.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1d7b78d73b..1f388306f4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3781,20 +3781,19 @@ processSerialChangedEvent(virQEMUDriver *driver, =20 if (newstate =3D=3D VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED && virDomainObjIsActive(vm) && priv->agent) { + virDomainDeviceDef agentDev; + /* peek into the domain definition to find the channel */ - if (virDomainDefFindDevice(vm->def, devAlias, &dev, true) =3D=3D 0= && - dev.type =3D=3D VIR_DOMAIN_DEVICE_CHR && - dev.data.chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHA= NNEL && - dev.data.chr->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_= TYPE_VIRTIO && - STREQ_NULLABLE(dev.data.chr->target.name, "org.qemu.guest_agen= t.0")) + if (virDomainDefFindDevice(vm->def, devAlias, &agentDev, true) =3D= =3D 0 && + agentDev.type =3D=3D VIR_DOMAIN_DEVICE_CHR && + agentDev.data.chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYP= E_CHANNEL && + agentDev.data.chr->targetType =3D=3D VIR_DOMAIN_CHR_CHANNEL_TA= RGET_TYPE_VIRTIO && + STREQ_NULLABLE(agentDev.data.chr->target.name, "org.qemu.guest= _agent.0")) { /* Close agent monitor early, so that other threads * waiting for the agent to reply can finish and our * job we acquire below can succeed. */ qemuAgentNotifyClose(priv->agent); - - /* now discard the data, since it may possibly change once we unlo= ck - * while entering the job */ - memset(&dev, 0, sizeof(dev)); + } } =20 if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY_MIGRATION_SAFE) < 0) --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1691059005; cv=none; d=zohomail.com; s=zohoarc; b=UQDlwPw+uCAbVT3nvVHn0p0uYxgdPJBt2of0oWba7YypdmOCfT1L/SIECS1ZEcsfrIVYFkfuWKbfkvsNT5T+K6Txm9SE7Pm5qriX+F6LIF/XjQX8rbZMIB2k93fo+/hin3we7SmWi8ue+r0Ywy4G/PSQlukSnQeRguYaQWo0dMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059005; 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=hxOs7YtgR84U47vE/hHwr+FZr96D6spjVX/r9M0irC4=; b=AxsF4+PfczBkZeir5EBvHWef6MLiQZGvsoPm/ZVVn1bMEusf3ryGK+L8q0Q8vP6s+ch5dDgaf/uM3nBNY7Qul2xHUF/95DdgSRFQg7BMQeLQP7JKKwDZD9WBcmQTIaqKmVASJAheI11RisMtrbrBko8PDohCuFY+EQ+VKuRa8Yc= 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 1691059005717416.9792589550949; Thu, 3 Aug 2023 03:36:45 -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-215-sLsd_tvhNJig3yD7tzkjEw-1; Thu, 03 Aug 2023 06:36:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE3038870D8; Thu, 3 Aug 2023 10:36:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABF7540C2071; Thu, 3 Aug 2023 10:36:33 +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 66D7C19451C4; Thu, 3 Aug 2023 10:36:26 +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 DC8C01947218 for ; Thu, 3 Aug 2023 10:36:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C1A9CF7FB4; Thu, 3 Aug 2023 10:36:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68D5EF7FA6 for ; Thu, 3 Aug 2023 10:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059001; 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=hxOs7YtgR84U47vE/hHwr+FZr96D6spjVX/r9M0irC4=; b=aoQQkykNhJUNC9fcNyjrYl4MVT0rO+sh2hrk9d/jhAhmvBrfK8CbE/lxWv5GPHo+mNPhy9 8a328+qMJdEsFOXtL0tegeCNXF9lbSScqSXXT3Qb34T668jdSON5ppu3JuX4LySpZaD/wx EgEVuqmmZubpTQ7HhqjXqdE9TBTvRPM= X-MC-Unique: sLsd_tvhNJig3yD7tzkjEw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/13] remote_driver: Drop explicit memset(&sargs) in remoteAuthSASL() Date: Thu, 3 Aug 2023 12:36:12 +0200 Message-ID: <1dfc5fe8d948b97c192e01a2975c4e5a172a92d8.1691058853.git.mprivozn@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.1 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: 1691059010385100013 Content-Type: text/plain; charset="utf-8"; x-default="true" Inside of remoteAuthSASL() the sargs variable is already initialized to zero during declaration. There's no need to memset() it again as it's unused in between it's declaration and said memset(). Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/remote/remote_driver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index d775f65fe2..7ccf550dff 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3833,7 +3833,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_dat= a *priv, goto cleanup; } /* NB, distinction of NULL vs "" is *critical* in SASL */ - memset(&sargs, 0, sizeof(sargs)); sargs.nil =3D clientout ? 0 : 1; sargs.data.data_val =3D (char*)clientout; sargs.data.data_len =3D clientoutlen; --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1691059023; cv=none; d=zohomail.com; s=zohoarc; b=HotzFw3wdoUyPXGH8CgW/+VNas2LAn4QOkzCOVMXuUFHz/zUiQwSxRJReuLSbzaqA/a+sl7qHuOUTuFY3BiC7fbymRjR4ugU0os121wTmOw462vx3vzrCIlWcI8LinUpEfyWI0IOqDDgLvC9K/lfGQQM7XU5jyqmfX553L+IDxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059023; 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=eZuViPOXhIOtTl1DCp61Y+whQDNKPZ3VMxCtWnWyQ00=; b=lAIXueLk9MdZF3613o4BC+c3j9ktxik56S1zeIrviBAUO3tSXdaWWoK5BeXbbK0sSmBl+eodcyJ99lkzXkrQt3idwONTgwS1tYQOJXshTxza+eOxg5J7aoT2hGmFJO9D9h8ZlFhiNhNEyljHx52ntIUe24J/zlmmmN2KzLd49ZE= 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 1691059023326428.2628249840068; Thu, 3 Aug 2023 03:37:03 -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-584-rc-y_G2UOuyiIP0WFlxXHQ-1; Thu, 03 Aug 2023 06:36:33 -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 921BB8870D5; Thu, 3 Aug 2023 10:36:31 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D7CD492CAC; Thu, 3 Aug 2023 10:36:31 +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 A011F1946A78; Thu, 3 Aug 2023 10:36:27 +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 679C219451C5 for ; Thu, 3 Aug 2023 10:36:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5D199F7FA6; Thu, 3 Aug 2023 10:36:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0443AF77BD for ; Thu, 3 Aug 2023 10:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059022; 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=eZuViPOXhIOtTl1DCp61Y+whQDNKPZ3VMxCtWnWyQ00=; b=KUDbV3zlBsoREBjJmAyuQD3hN/cQ0sQf4HDY3+f0O4JRfMP+AC3JXTZ7S2qQqjRxkNjEDx YMdI/5LjaABDYYy3Xma2/4HybAgz3mexvgV7Tg1iT9Okh/pwUq5u/AjI28I9NbV/CPUojy XjB+RZiCAo4P34C8XEN+xEXq7HGzsg0= X-MC-Unique: rc-y_G2UOuyiIP0WFlxXHQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 06/13] virfirewalld: Drop useless memset() in virFirewallDApplyRule() Date: Thu, 3 Aug 2023 12:36:13 +0200 Message-ID: <090087d6f4373a863068ce306b1a8f32fba28c5f.1691058853.git.mprivozn@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: 1691059024298100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This is a residue of v6.8.0-rc1~100. The error variable inside of virFirewallDApplyRule() is already initialized to NULL. There's no need to memset() it to zero again. Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/util/virfirewalld.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/util/virfirewalld.c b/src/util/virfirewalld.c index 6fc54f357d..827e201dbb 100644 --- a/src/util/virfirewalld.c +++ b/src/util/virfirewalld.c @@ -360,8 +360,6 @@ virFirewallDApplyRule(virFirewallLayer layer, if (!sysbus) return -1; =20 - memset(&error, 0, sizeof(error)); - if (!ipv) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown firewall layer %1$d"), --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 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=1691059002; cv=none; d=zohomail.com; s=zohoarc; b=cDu7ZvI1VHFfkK9AxxtF8A9pPIFull80wN9eAmR23XGTVIuXSsKN69/am+DQe3ZkXkU1b03gH9by/GyJOKsDSBaJ+Y48Tce/jSTlryw1Wx9S+4ensIGdvihlRdDfF6XkTAmqZr9uQB2IddDswCMNjrVTxKsyTwRiC1rrql9Qtww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059002; 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=OAQK2j18NxM6hlkaktkwMZIJTCeU6PpzrQUdrsEIG9g=; b=egkRAsLNxjmMsgICgelKufz2ezVwHjyGDog7aWPwGvyMPnrxrwN2lSdtFVVzstwuIzHsYHeYXD6wwA9+JkfmxTihwpD+45+4jQsmCOsDUWsPw8gdNpG492binNqAbGBHOLZzEAplAJXJUN+5yIQhSEJ/5ZY94ZJNQcDOSr6b9o0= 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 1691059002874739.2142443333523; Thu, 3 Aug 2023 03:36:42 -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-628-Xv1WYmv_OvOU-HuhgFOxpg-1; Thu, 03 Aug 2023 06:36:38 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38A3B881B26; Thu, 3 Aug 2023 10:36:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EC1A1454145; Thu, 3 Aug 2023 10:36:35 +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 B2EBB19452D1; Thu, 3 Aug 2023 10:36:29 +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 088751946A75 for ; Thu, 3 Aug 2023 10:36:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id ECDEAF77BD; Thu, 3 Aug 2023 10:36:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94301F7FA6 for ; Thu, 3 Aug 2023 10:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059001; 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=OAQK2j18NxM6hlkaktkwMZIJTCeU6PpzrQUdrsEIG9g=; b=bncxPf6zHtqvd1fytrQa2iki1/uP9LieNbQbISLIhn7MoQgD4fkgAXBK+1QGqY+8Kmpfip vGtfCnBRcyQhvJWhMe7DT7aJ+upyTfPtHHTJArPZU4+ksOfvOhsI2IpVwT3wILY2hvmol+ n+FLp/OUK/yMrlbDEjFZaYs/X+bHOWA= X-MC-Unique: Xv1WYmv_OvOU-HuhgFOxpg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/13] virnetlink: Drop unused variable from virNetlinkCommand() Date: Thu, 3 Aug 2023 12:36:14 +0200 Message-ID: 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.7 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: 1691059004550100005 Content-Type: text/plain; charset="utf-8"; x-default="true" The fds variable inside of virNetlinkCommand() is not used really. It's passed to memset() (hence compilers do not complain), but that's about it. Drop it. Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/util/virnetlink.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index 866f4d8f2b..d964c439b4 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -333,13 +333,10 @@ int virNetlinkCommand(struct nl_msg *nl_msg, .nl_pid =3D dst_pid, .nl_groups =3D 0, }; - struct pollfd fds[1]; g_autofree struct nlmsghdr *temp_resp =3D NULL; g_autoptr(virNetlinkHandle) nlhandle =3D NULL; int len =3D 0; =20 - memset(fds, 0, sizeof(fds)); - if (!(nlhandle =3D virNetlinkSendRequest(nl_msg, src_pid, nladdr, protocol, groups))) return -1; --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1691059083; cv=none; d=zohomail.com; s=zohoarc; b=H4eg0O9Lr6coQNv4FyYDJGAdpHCxvBXegjG+bqbD1qfs4dFyHVaJh7U9MrZA4HYdmWQusQl5XHP/ncfg1VjeHYXJn9Y1YlIRoKemsL3BKvvQ57SD92AjhheoUgcojtP1qKVBN/P1JjkRE2XHlhj7VnwMS7HDSq0SjvB81IMXOYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059083; 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=vGFyEwPxFKE1shMdr9resqfoC8DkvP+SfVh3z+9TNF0=; b=k5/hvAhTvNO6XFOfZ4tTN7qnM59cQLmdT/iFWIkJu0v64KnvFvIWtqyHErZneQzu8PcOHF+733WsjBCbxyhf8I/QP4ZHze2ddU/HON0d/QCwmpvBsniac0h6NlIgqgztC3UGlMbn+QutblYwgt49Di3aILoCrYxEFL31VKf3TNI= 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 1691059083354206.57429304038249; Thu, 3 Aug 2023 03:38:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-602-rJoBVlioPwaet-dgQzHodQ-1; Thu, 03 Aug 2023 06:36:35 -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 EA7083C0D193; Thu, 3 Aug 2023 10:36:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5B54492B03; Thu, 3 Aug 2023 10:36:32 +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 DEBCF1947225; Thu, 3 Aug 2023 10:36:28 +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 AD5291947217 for ; Thu, 3 Aug 2023 10:36:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8AC2EF7FB4; Thu, 3 Aug 2023 10:36:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FF5BF77BD for ; Thu, 3 Aug 2023 10:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059082; 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=vGFyEwPxFKE1shMdr9resqfoC8DkvP+SfVh3z+9TNF0=; b=ZXkKLzC8hMwHuCfP1CqKNpEEo3FXFua8gX14CGBQfNb+W38fr6kk8dvvAitTIt3qIaf7Vc OovzjQPISiSgcitPu4bqO//AWMoVLH31dq747ujVsdyvgQXxcdVztoOYizrEVvBABDDBfK Dp93kqf5YhN6/Ut+QUEFRKA/mmRKfi4= X-MC-Unique: rJoBVlioPwaet-dgQzHodQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/13] securityselinuxhelper: Use g_new0() instead of malloc()+memset() combo Date: Thu, 3 Aug 2023 12:36:15 +0200 Message-ID: <3dcafd011671839abfd09943973c6fe64efda8aa.1691058853.git.mprivozn@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: 1691059085539100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Inside of securityselinuxhelper we still use malloc() + memset(.., 0, ...) combo. Convert it to g_new0(). Signed-off-by: Michal Privoznik --- tests/securityselinuxhelper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c index c32c90c17e..797f090a7e 100644 --- a/tests/securityselinuxhelper.c +++ b/tests/securityselinuxhelper.c @@ -173,9 +173,8 @@ int getfilecon_raw(const char *path, char **con) } if (len < 0) return -1; - if (!(constr =3D malloc(len+1))) - return -1; - memset(constr, 0, len); + + constr =3D g_new0(char, len + 1); if (getxattr(path, "user.libvirt.selinux", constr, len) < 0) { free(constr); return -1; --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1691059005; cv=none; d=zohomail.com; s=zohoarc; b=kN8Lati+Wc4uJ6YCPzJsQSiBiyZ+6vSoQti+TZWl273K1QrD61mlneMrvKfQeWbR4u6IDtmkuZnwG4U838yIJVLapyTxMnyzwTXqeaRZWz/xqN9AWuu7DKtEeHWZ4lOwa3yxHOGfZIAzL+fFuK+auCsJrZ/9FxcETA72FKSNft0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059005; 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=o5/7q1sK5qhN63b7KajC9W6+R8HLwfGl+8//AvpV46w=; b=TETAr7bGCFRE/yYm65w9x6mn5AMdZPNOhO1J2ylpVRQwnFQkQb2YrnljkZfVaWP4qp7fvSr5Xc/a/6bUYcRYsjo8CLsA8lR1wZeqN9JB2vNejNIchHi1NYJYR7+rX5AfxJiTW7fxqgvFV3zM3ZvsDktQ9flFyj195EG6AL4zFvQ= 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 1691059005985459.7982491614441; Thu, 3 Aug 2023 03:36:45 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-659-vMLhg-lpPqqQ9Y2mO-KMpw-1; Thu, 03 Aug 2023 06:36:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FA3D1C060DD; Thu, 3 Aug 2023 10:36:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28C8240C6CCC; Thu, 3 Aug 2023 10:36:39 +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 1C6FB194723E; Thu, 3 Aug 2023 10:36:29 +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 41D2E1947218 for ; Thu, 3 Aug 2023 10:36:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 26708F7FB4; Thu, 3 Aug 2023 10:36:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1C61F7FB8 for ; Thu, 3 Aug 2023 10:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059005; 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=o5/7q1sK5qhN63b7KajC9W6+R8HLwfGl+8//AvpV46w=; b=OHgAFhZj20X98WgVknruid9iAMaKg2CoeBeq47ITy8v88Sz95+6shjow76l0HZDjs/HGDL j7KmetkuaEgJXx2MpDwR8pzQrWZJeap8i/Tv39j9QIgJWPDhYER8X5NQYR7VHUaw4UzdtS fTDoTpuLHedJoNrDm5uF00Hs1Z+UJWE= X-MC-Unique: vMLhg-lpPqqQ9Y2mO-KMpw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 09/13] virnetclient: Update comment about memset() Date: Thu, 3 Aug 2023 12:36:16 +0200 Message-ID: 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.2 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: 1691059008183100009 Content-Type: text/plain; charset="utf-8"; x-default="true" Instead of suggesting to zero structs out using memset() we should suggest initializing structs with zero initializer. Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/rpc/virnetclient.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index df2958935b..18f87653f5 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1857,8 +1857,8 @@ static void virNetClientIOUpdateCallback(virNetClient= *client, * which come from the user). It does however free any intermediate * results, eg. the error structure if there is one. * - * NB(2). Make sure to memset (&ret, 0, sizeof(ret)) before calling, - * else Bad Things will happen in the XDR code. + * NB(2). Make sure to initialize ret variable to { 0 } before calling, + * else Bad things will happen in the XDR code. * * NB(3) You must have the client lock before calling this * --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 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=1691059005; cv=none; d=zohomail.com; s=zohoarc; b=MKvJ7M5NVNRpmsO0nU/Nxh9yMgl/wNlsqjNN8naExGJjaQ79BZk6UYJe5sHaJ1cGmeioggidG/kpTkKjCQ8P4Iu4x+L7Ikkl2SHK+k3fnCObjovJx6nX4n2JfytZqIsosys65MpX3AMNJLZRa4qr724vIGU+patWEZGAOSOIzzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059005; 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=inw8sfUYHUh+GZuTeP/yiDQ4MeHcvi8LfnvPFyLXzg8=; b=kdUTACr62FU7+8t4a70uLXLYX8m0niKoHuD5M2Ha1S0YhbX83VFSFnn9dbYzS+fg/JpnG4xcvt5LsxAdWICdb1Jcg/TQyFKcuD4maG8lnX8XGr9U1CTssXNek7voTbOUcNNsjxRwk1S2xqEcriVfuvvI649twA/eiA834tVJQQc= 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 1691059005364945.5251106495961; Thu, 3 Aug 2023 03:36:45 -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-630-B1BQdL36MO-zVnKhByT3Tw-1; Thu, 03 Aug 2023 06:36:40 -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 8D2C08910F5; Thu, 3 Aug 2023 10:36:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7575F207B34D; Thu, 3 Aug 2023 10:36:37 +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 51DE819451E4; Thu, 3 Aug 2023 10:36:30 +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 C53BE1947218 for ; Thu, 3 Aug 2023 10:36:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B5C92F77BD; Thu, 3 Aug 2023 10:36:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D171F7FB4 for ; Thu, 3 Aug 2023 10:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059004; 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=inw8sfUYHUh+GZuTeP/yiDQ4MeHcvi8LfnvPFyLXzg8=; b=aAZbz5h/JkPkuNcDhu29EkEJ9Et1Jfe9NcNFY0V8mXhUpcp73Bts83MyFTiyhAF/L4QzM1 Z22xs+CQNOlr1GVcmv2hvlxjua+/cd8Q71664nsC/d0Uzd1EseTi5IIu2ACk/D5WVGPzQS 7k5YFZy58qBtZ02NCtnabqzEvj6Zh2o= X-MC-Unique: B1BQdL36MO-zVnKhByT3Tw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/13] virnetdaemon.c: Use struct zero initializer instead of memset Date: Thu, 3 Aug 2023 12:36:17 +0200 Message-ID: <864feb8ede33267e2734048c0a8b25d253880ea0.1691058853.git.mprivozn@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.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: 1691059006510100007 Content-Type: text/plain; charset="utf-8"; x-default="true" Ideally, these would be fixed by coccinelle (see next commit), but because of various reasons they aren't. Fix them manually. Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/rpc/virnetdaemon.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 554b8852e4..d37984d207 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -134,7 +134,7 @@ virNetDaemonNew(void) { virNetDaemon *dmn; #ifndef WIN32 - struct sigaction sig_action; + struct sigaction sig_action =3D { 0 }; #endif /* !WIN32 */ =20 if (virNetDaemonInitialize() < 0) @@ -160,7 +160,6 @@ virNetDaemonNew(void) dmn->autoShutdownTimerID =3D -1; =20 #ifndef WIN32 - memset(&sig_action, 0, sizeof(sig_action)); sig_action.sa_handler =3D SIG_IGN; sigaction(SIGPIPE, &sig_action, NULL); #endif /* !WIN32 */ @@ -599,12 +598,10 @@ virNetDaemonSignalHandler(int sig, siginfo_t * siginf= o, { int origerrno; int r; - siginfo_t tmp; + siginfo_t tmp =3D { 0 }; =20 if (SA_SIGINFO) tmp =3D *siginfo; - else - memset(&tmp, 0, sizeof(tmp)); =20 /* set the sig num in the struct */ tmp.si_signo =3D sig; --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 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=1691059007; cv=none; d=zohomail.com; s=zohoarc; b=iwjIcKnaQMOLZUkPuzQkUORHxdCCSCH4Yp9GhGfLAv9PdplWSH0KjBUXaoVutKz9NsI/qYtKcPye3T5bSEUfoAaOhG/LSvRaPPsUcEdRkdzAL/0wNLc11SxE2Rfjc/lCb2BkNECFPqIFi4/CXvoj785Zb1FBYElAEC3r0aIobuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059007; 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=Y41JHPasPnFwhfLxT5jo4Rl3pttftdtkWSgM6I+u+LY=; b=evdq5u820SEw3cj2QAnhJ55RhSrpXxnb9Hw3Ac/qwaLMzF1Aw5zDmmItaCbWrg92QJr0iluk8CrxpTeFcD8lkVhbQr0HhVMKPcHmdQHBJnvzB2HlyS8SCQFyBytcTToOnEP4T1Nhr52X6Ko9QXnhc7/n/eIGfu09pPvs1eP03ow= 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 1691059007214191.78565477732786; Thu, 3 Aug 2023 03:36:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-28-mM-fLWgRN8iWA2cWHt6Yjg-1; Thu, 03 Aug 2023 06:36:42 -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 7452D3C0E203; Thu, 3 Aug 2023 10:36:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 566C5200BA7C; Thu, 3 Aug 2023 10:36:39 +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 94E3F194721E; Thu, 3 Aug 2023 10:36:30 +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 B4DA419451C6 for ; Thu, 3 Aug 2023 10:36:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A6773F7FB4; Thu, 3 Aug 2023 10:36:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEA4DF77BD for ; Thu, 3 Aug 2023 10:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059006; 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=Y41JHPasPnFwhfLxT5jo4Rl3pttftdtkWSgM6I+u+LY=; b=XD5McFRkv+gCBfv+GQesXBDRonZkptNpKia4Gh/ulsKYg3cupi+3dmlrZIQq4e4TB2pEUh XD6fNNv7mORj6fJ2tE4h7GbeIoTfjUlXinpH+9S6x5hCX0FXotklvVpJQUvtUYAGO28YOr hUljYDX5QAoOur0dkJDVcsowLNoE69s= X-MC-Unique: mM-fLWgRN8iWA2cWHt6Yjg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 11/13] lib: use struct zero initializer instead of memset Date: Thu, 3 Aug 2023 12:36:18 +0200 Message-ID: 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.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: 1691059008752100011 Content-Type: text/plain; charset="utf-8"; x-default="true" This is a more concise approach and guarantees there is no time window where the struct is uninitialized. Generated using the following semantic patch: @@ type T; identifier X; @@ - T X; + T X =3D { 0 }; ... when exists ( - memset(&X, 0, sizeof(X)); | - memset(&X, 0, sizeof(T)); ) Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/ch/ch_monitor.c | 3 +- src/conf/domain_conf.c | 8 +- src/conf/network_conf.c | 28 ++---- src/cpu/cpu_x86.c | 4 +- src/esx/esx_driver.c | 20 ++--- src/esx/esx_interface_driver.c | 13 +-- src/esx/esx_storage_backend_iscsi.c | 11 +-- src/esx/esx_storage_backend_vmfs.c | 19 ++-- src/esx/esx_util.c | 4 +- src/libxl/libxl_driver.c | 9 +- src/locking/lock_driver_lockd.c | 19 ++-- src/logging/log_manager.c | 25 ++---- src/lxc/lxc_controller.c | 6 +- src/lxc/lxc_domain.c | 4 +- src/lxc/lxc_driver.c | 4 +- src/nwfilter/nwfilter_dhcpsnoop.c | 4 +- src/nwfilter/nwfilter_gentech_driver.c | 4 +- src/qemu/qemu_agent.c | 10 +-- src/qemu/qemu_command.c | 3 +- src/qemu/qemu_driver.c | 7 +- src/qemu/qemu_monitor.c | 6 +- src/qemu/qemu_monitor_json.c | 7 +- src/qemu/qemu_process.c | 3 +- src/remote/remote_daemon_dispatch.c | 115 ++++++++----------------- src/remote/remote_daemon_stream.c | 23 ++--- src/remote/remote_driver.c | 13 +-- src/rpc/virnetclientprogram.c | 4 +- src/rpc/virnetclientstream.c | 9 +- src/rpc/virnetdaemon.c | 3 +- src/rpc/virnetsaslcontext.c | 3 +- src/rpc/virnetserverprogram.c | 14 +-- src/rpc/virnetsocket.c | 49 +++-------- src/rpc/virnetsshsession.c | 3 +- src/storage/storage_backend_logical.c | 10 +-- src/util/virarptable.c | 3 +- src/util/virauth.c | 4 +- src/util/virbpf.c | 52 +++-------- src/util/virdevmapper.c | 8 +- src/util/virfdstream.c | 3 +- src/util/virfile.c | 3 +- src/util/virinitctl.c | 4 +- src/util/viriscsi.c | 4 +- src/util/virlog.c | 9 +- src/util/virnetdev.c | 8 +- src/util/virnetdevbridge.c | 10 +-- src/util/virnetdevip.c | 8 +- src/util/virnetdevtap.c | 3 +- src/util/virperf.c | 3 +- src/util/virprocess.c | 3 +- src/util/virsocket.c | 6 +- src/util/virsocketaddr.c | 7 +- src/util/viruri.c | 4 +- src/vbox/vbox_storage.c | 10 +-- src/vmx/vmx.c | 4 +- tests/nsstest.c | 8 +- tests/nwfilterxml2firewalltest.c | 4 +- tests/qemumonitorjsontest.c | 6 +- tests/qemumonitortestutils.c | 8 +- tests/qemuxml2argvtest.c | 4 +- tests/virhostcputest.c | 3 +- tests/virnetmessagetest.c | 8 +- tools/nss/libvirt_nss.c | 3 +- tools/virsh-domain-monitor.c | 3 +- tools/virsh-domain.c | 4 +- tools/vsh-table.c | 4 +- 65 files changed, 195 insertions(+), 483 deletions(-) diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index d902bc6959..a4b921931b 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -468,7 +468,7 @@ virCHMonitorBuildVMJson(virDomainDef *vmdef, static int chMonitorCreateSocket(const char *socket_path) { - struct sockaddr_un addr; + struct sockaddr_un addr =3D { 0 }; socklen_t addrlen =3D sizeof(addr); int fd; =20 @@ -478,7 +478,6 @@ chMonitorCreateSocket(const char *socket_path) goto error; } =20 - memset(&addr, 0, sizeof(addr)); addr.sun_family =3D AF_UNIX; if (virStrcpyStatic(addr.sun_path, socket_path) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5ac5c0b771..47693a49bf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28859,9 +28859,7 @@ int virDomainGraphicsListenAppendAddress(virDomainGraphicsDef *def, const char *address) { - virDomainGraphicsListenDef glisten; - - memset(&glisten, 0, sizeof(glisten)); + virDomainGraphicsListenDef glisten =3D { 0 }; =20 glisten.type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; =20 @@ -28877,9 +28875,7 @@ int virDomainGraphicsListenAppendSocket(virDomainGraphicsDef *def, const char *socketPath) { - virDomainGraphicsListenDef glisten; - - memset(&glisten, 0, sizeof(glisten)); + virDomainGraphicsListenDef glisten =3D { 0 }; =20 glisten.type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; =20 diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 73788b6d87..3e137cb562 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -2748,11 +2748,9 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDef *def, size_t i; int ret =3D -1; virNetworkIPDef *ipdef =3D virNetworkIPDefByIndex(def, parentIndex); - virNetworkDHCPHostDef host; + virNetworkDHCPHostDef host =3D { 0 }; bool partialOkay =3D (command =3D=3D VIR_NETWORK_UPDATE_COMMAND_DELETE= ); =20 - memset(&host, 0, sizeof(host)); - if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "host") < 0) goto cleanup; =20 @@ -2881,9 +2879,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDef *def, { size_t i; virNetworkIPDef *ipdef =3D virNetworkIPDefByIndex(def, parentIndex); - virNetworkDHCPRangeDef range; - - memset(&range, 0, sizeof(range)); + virNetworkDHCPRangeDef range =3D { 0 }; =20 if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "range") < 0) return -1; @@ -2990,9 +2986,7 @@ virNetworkDefUpdateForwardInterface(virNetworkDef *de= f, { size_t i; int ret =3D -1; - virNetworkForwardIfDef iface; - - memset(&iface, 0, sizeof(iface)); + virNetworkForwardIfDef iface =3D { 0 }; =20 if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "interface") = < 0) goto cleanup; @@ -3094,9 +3088,7 @@ virNetworkDefUpdatePortGroup(virNetworkDef *def, size_t i; int foundName =3D -1, foundDefault =3D -1; int ret =3D -1; - virPortGroupDef portgroup; - - memset(&portgroup, 0, sizeof(portgroup)); + virPortGroupDef portgroup =3D { 0 }; =20 if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "portgroup") = < 0) goto cleanup; @@ -3184,13 +3176,11 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def, size_t i, j, k; int foundIdx =3D -1, ret =3D -1; virNetworkDNSDef *dns =3D &def->dns; - virNetworkDNSHostDef host; + virNetworkDNSHostDef host =3D { 0 }; bool isAdd =3D (command =3D=3D VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST || command =3D=3D VIR_NETWORK_UPDATE_COMMAND_ADD_LAST); int foundCt =3D 0; =20 - memset(&host, 0, sizeof(host)); - if (command =3D=3D VIR_NETWORK_UPDATE_COMMAND_MODIFY) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("DNS HOST records cannot be modified, " @@ -3283,13 +3273,11 @@ virNetworkDefUpdateDNSSrv(virNetworkDef *def, size_t i; int foundIdx =3D -1, ret =3D -1; virNetworkDNSDef *dns =3D &def->dns; - virNetworkDNSSrvDef srv; + virNetworkDNSSrvDef srv =3D { 0 }; bool isAdd =3D (command =3D=3D VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST || command =3D=3D VIR_NETWORK_UPDATE_COMMAND_ADD_LAST); int foundCt =3D 0; =20 - memset(&srv, 0, sizeof(srv)); - if (command =3D=3D VIR_NETWORK_UPDATE_COMMAND_MODIFY) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("DNS SRV records cannot be modified, " @@ -3368,12 +3356,10 @@ virNetworkDefUpdateDNSTxt(virNetworkDef *def, { int foundIdx, ret =3D -1; virNetworkDNSDef *dns =3D &def->dns; - virNetworkDNSTxtDef txt; + virNetworkDNSTxtDef txt =3D { 0 }; bool isAdd =3D (command =3D=3D VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST || command =3D=3D VIR_NETWORK_UPDATE_COMMAND_ADD_LAST); =20 - memset(&txt, 0, sizeof(txt)); - if (command =3D=3D VIR_NETWORK_UPDATE_COMMAND_MODIFY) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("DNS TXT records cannot be modified, " diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 3c0163c4d1..b9513e24d5 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1073,9 +1073,7 @@ static int x86ParseMSR(xmlNodePtr node, virCPUx86DataItem *item) { - virCPUx86MSR msr; - - memset(&msr, 0, sizeof(msr)); + virCPUx86MSR msr =3D { 0 }; =20 if (virXMLPropUInt(node, "index", 0, VIR_XML_PROP_REQUIRED, &msr.index= ) < 0) return -1; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 0d1b10fe8b..b243bbf411 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2536,14 +2536,12 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned i= nt flags) g_autofree char *url =3D NULL; g_autofree char *vmx =3D NULL; virVMXContext ctx; - esxVMX_Data data; + esxVMX_Data data =3D { 0 }; g_autoptr(virDomainDef) def =3D NULL; char *xml =3D NULL; =20 virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL); =20 - memset(&data, 0, sizeof(data)); - if (esxVI_EnsureSession(priv->primary) < 0) return NULL; =20 @@ -2622,14 +2620,12 @@ esxConnectDomainXMLFromNative(virConnectPtr conn, c= onst char *nativeFormat, { esxPrivate *priv =3D conn->privateData; virVMXContext ctx; - esxVMX_Data data; + esxVMX_Data data =3D { 0 }; g_autoptr(virDomainDef) def =3D NULL; char *xml =3D NULL; =20 virCheckFlags(0, NULL); =20 - memset(&data, 0, sizeof(data)); - if (STRNEQ(nativeFormat, VMX_CONFIG_FORMAT_ARGV)) { virReportError(VIR_ERR_INVALID_ARG, _("Unsupported config format '%1$s'"), nativeFormat= ); @@ -2665,14 +2661,12 @@ esxConnectDomainXMLToNative(virConnectPtr conn, con= st char *nativeFormat, esxPrivate *priv =3D conn->privateData; int virtualHW_version; virVMXContext ctx; - esxVMX_Data data; + esxVMX_Data data =3D { 0 }; g_autoptr(virDomainDef) def =3D NULL; char *vmx =3D NULL; =20 virCheckFlags(0, NULL); =20 - memset(&data, 0, sizeof(data)); - if (STRNEQ(nativeFormat, VMX_CONFIG_FORMAT_ARGV)) { virReportError(VIR_ERR_INVALID_ARG, _("Unsupported config format '%1$s'"), nativeFormat= ); @@ -2870,7 +2864,7 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flags) esxVI_ObjectContent *virtualMachine =3D NULL; int virtualHW_version; virVMXContext ctx; - esxVMX_Data data; + esxVMX_Data data =3D { 0 }; g_autofree char *datastoreName =3D NULL; g_autofree char *directoryName =3D NULL; g_autofree char *escapedName =3D NULL; @@ -2892,8 +2886,6 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flags) if (flags & VIR_DOMAIN_DEFINE_VALIDATE) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA; =20 - memset(&data, 0, sizeof(data)); - if (esxVI_EnsureSession(priv->primary) < 0) return NULL; =20 @@ -4058,14 +4050,12 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr sn= apshot, esxVI_VirtualMachineSnapshotTree *rootSnapshotList =3D NULL; esxVI_VirtualMachineSnapshotTree *snapshotTree =3D NULL; esxVI_VirtualMachineSnapshotTree *snapshotTreeParent =3D NULL; - virDomainSnapshotDef def; + virDomainSnapshotDef def =3D { 0 }; char uuid_string[VIR_UUID_STRING_BUFLEN] =3D ""; char *xml =3D NULL; =20 virCheckFlags(0, NULL); =20 - memset(&def, 0, sizeof(def)); - if (esxVI_EnsureSession(priv->primary) < 0) return NULL; =20 diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c index d6b6410d1a..125155da99 100644 --- a/src/esx/esx_interface_driver.c +++ b/src/esx/esx_interface_driver.c @@ -157,21 +157,16 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigne= d int flags) char *xml =3D NULL; esxPrivate *priv =3D iface->conn->privateData; esxVI_PhysicalNic *physicalNic =3D NULL; - virInterfaceDef def; + virInterfaceDef def =3D { 0 }; bool hasAddress =3D false; virInterfaceProtocolDef *protocols; - virInterfaceProtocolDef protocol; - virSocketAddr socketAddress; + virInterfaceProtocolDef protocol =3D { 0 }; + virSocketAddr socketAddress =3D { 0 }; virInterfaceIPDef *ips; - virInterfaceIPDef ip; + virInterfaceIPDef ip =3D { 0 }; =20 virCheckFlags(VIR_INTERFACE_XML_INACTIVE, NULL); =20 - memset(&def, 0, sizeof(def)); - memset(&protocol, 0, sizeof(protocol)); - memset(&socketAddress, 0, sizeof(socketAddress)); - memset(&ip, 0, sizeof(ip)); - if (esxVI_EnsureSession(priv->primary) < 0 || esxVI_LookupPhysicalNicByMACAddress(priv->primary, iface->mac, &physicalNic, diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index 087365392b..c00b1e4f32 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -302,12 +302,10 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsi= gned int flags) esxPrivate *priv =3D pool->conn->privateData; esxVI_HostInternetScsiHba *hostInternetScsiHba =3D NULL; esxVI_HostInternetScsiHbaStaticTarget *target; - virStoragePoolDef def; + virStoragePoolDef def =3D { 0 }; =20 virCheckFlags(0, NULL); =20 - memset(&def, 0, sizeof(def)); - if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHb= a)) goto cleanup; =20 @@ -664,20 +662,17 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, { char *xml =3D NULL; esxPrivate *priv =3D volume->conn->privateData; - virStoragePoolDef pool; + virStoragePoolDef pool =3D { 0 }; esxVI_ScsiLun *scsiLunList =3D NULL; esxVI_ScsiLun *scsiLun; esxVI_HostScsiDisk *hostScsiDisk =3D NULL; - virStorageVolDef def; + virStorageVolDef def =3D { 0 }; /* VIR_CRYPTO_HASH_SIZE_MD5 =3D VIR_UUID_BUFLEN =3D 16 */ unsigned char md5[VIR_CRYPTO_HASH_SIZE_MD5]; char uuid_string[VIR_UUID_STRING_BUFLEN] =3D ""; =20 virCheckFlags(0, NULL); =20 - memset(&pool, 0, sizeof(pool)); - memset(&def, 0, sizeof(def)); - if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; =20 diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index f00c7eec4e..7c5df1c9cd 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -442,15 +442,13 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsi= gned int flags) esxVI_DatastoreHostMount *hostMount =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; esxVI_Boolean accessible =3D esxVI_Boolean_Undefined; - virStoragePoolDef def; + virStoragePoolDef def =3D { 0 }; esxVI_DatastoreInfo *info =3D NULL; esxVI_NasDatastoreInfo *nasInfo =3D NULL; char *xml =3D NULL; =20 virCheckFlags(0, NULL); =20 - memset(&def, 0, sizeof(def)); - if (esxVI_String_AppendValueListToList(&propertyNameList, "summary.accessible\0" "summary.capacity\0" @@ -833,7 +831,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, { virStorageVolPtr volume =3D NULL; esxPrivate *priv =3D pool->conn->privateData; - virStoragePoolDef poolDef; + virStoragePoolDef poolDef =3D { 0 }; char *tmp; g_autofree char *unescapedDatastorePath =3D NULL; g_autofree char *unescapedDirectoryName =3D NULL; @@ -853,8 +851,6 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, =20 virCheckFlags(0, NULL); =20 - memset(&poolDef, 0, sizeof(poolDef)); - if (esxLookupVMFSStoragePoolType(priv->primary, pool->name, &poolDef.type) < 0) { goto cleanup; @@ -1032,7 +1028,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, { virStorageVolPtr volume =3D NULL; esxPrivate *priv =3D pool->conn->privateData; - virStoragePoolDef poolDef; + virStoragePoolDef poolDef =3D { 0 }; g_autofree char *sourceDatastorePath =3D NULL; char *tmp; g_autofree char *unescapedDatastorePath =3D NULL; @@ -1052,8 +1048,6 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, =20 virCheckFlags(0, NULL); =20 - memset(&poolDef, 0, sizeof(poolDef)); - if (esxLookupVMFSStoragePoolType(priv->primary, pool->name, &poolDef.type) < 0) { goto cleanup; @@ -1312,20 +1306,17 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, unsigned int flags) { esxPrivate *priv =3D volume->conn->privateData; - virStoragePoolDef pool; + virStoragePoolDef pool =3D { 0 }; g_autofree char *datastorePath =3D NULL; esxVI_FileInfo *fileInfo =3D NULL; esxVI_VmDiskFileInfo *vmDiskFileInfo =3D NULL; esxVI_IsoImageFileInfo *isoImageFileInfo =3D NULL; esxVI_FloppyImageFileInfo *floppyImageFileInfo =3D NULL; - virStorageVolDef def; + virStorageVolDef def =3D { 0 }; char *xml =3D NULL; =20 virCheckFlags(0, NULL); =20 - memset(&pool, 0, sizeof(pool)); - memset(&def, 0, sizeof(def)); - if (esxLookupVMFSStoragePoolType(priv->primary, volume->pool, &pool.type) < 0) { return NULL; diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index fbbf226555..785701a518 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -272,13 +272,11 @@ esxUtil_ParseDatastorePath(const char *datastorePath,= char **datastoreName, int esxUtil_ResolveHostname(const char *hostname, char **ipAddress) { - struct addrinfo hints; + struct addrinfo hints =3D { 0 }; struct addrinfo *result =3D NULL; int errcode; g_autofree char *address =3D NULL; =20 - memset(&hints, 0, sizeof(hints)); - hints.ai_flags =3D AI_ADDRCONFIG; hints.ai_family =3D AF_INET; hints.ai_socktype =3D SOCK_STREAM; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 2644d1400a..3d10f45850 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1796,7 +1796,7 @@ libxlDoDomainSave(libxlDriverPrivate *driver, bool managed) { libxlDriverConfig *cfg =3D libxlDriverConfigGet(driver); - libxlSavefileHeader hdr; + libxlSavefileHeader hdr =3D { 0 }; virObjectEvent *event =3D NULL; g_autofree char *xml =3D NULL; uint32_t xml_len; @@ -1821,7 +1821,6 @@ libxlDoDomainSave(libxlDriverPrivate *driver, goto cleanup; xml_len =3D strlen(xml) + 1; =20 - memset(&hdr, 0, sizeof(hdr)); memcpy(hdr.magic, LIBXL_SAVE_MAGIC, sizeof(hdr.magic)); hdr.version =3D LIBXL_SAVE_VERSION; hdr.xmlLen =3D xml_len; @@ -5651,7 +5650,7 @@ libxlDomainBlockStats(virDomainPtr dom, virDomainBlockStatsPtr stats) { virDomainObj *vm; - libxlBlockStats blkstats; + libxlBlockStats blkstats =3D { 0 }; int ret =3D -1; =20 if (!(vm =3D libxlDomObjFromDomain(dom))) @@ -5666,7 +5665,6 @@ libxlDomainBlockStats(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto endjob; =20 - memset(&blkstats, 0, sizeof(libxlBlockStats)); if ((ret =3D libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0) goto endjob; =20 @@ -5695,7 +5693,7 @@ libxlDomainBlockStatsFlags(virDomainPtr dom, unsigned int flags) { virDomainObj *vm; - libxlBlockStats blkstats; + libxlBlockStats blkstats =3D { 0 }; int nstats; int ret =3D -1; =20 @@ -5722,7 +5720,6 @@ libxlDomainBlockStatsFlags(virDomainPtr dom, goto endjob; } =20 - memset(&blkstats, 0, sizeof(libxlBlockStats)); if ((ret =3D libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0) goto endjob; =20 diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index 6b294e2954..d75302dd0a 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -138,9 +138,7 @@ virLockManagerLockDaemonConnectionRegister(virLockManag= er *lock, int *counter) { virLockManagerLockDaemonPrivate *priv =3D lock->privateData; - virLockSpaceProtocolRegisterArgs args; - - memset(&args, 0, sizeof(args)); + virLockSpaceProtocolRegisterArgs args =3D { 0 }; =20 args.flags =3D 0; memcpy(args.owner.uuid, priv->uuid, VIR_UUID_BUFLEN); @@ -167,9 +165,7 @@ virLockManagerLockDaemonConnectionRestrict(virLockManag= er *lock G_GNUC_UNUSED, virNetClientProgram *program, int *counter) { - virLockSpaceProtocolRestrictArgs args; - - memset(&args, 0, sizeof(args)); + virLockSpaceProtocolRestrictArgs args =3D { 0 }; =20 args.flags =3D 0; =20 @@ -259,11 +255,10 @@ static int virLockManagerLockDaemonSetupLockspace(con= st char *path) { virNetClient *client; virNetClientProgram *program =3D NULL; - virLockSpaceProtocolCreateLockSpaceArgs args; + virLockSpaceProtocolCreateLockSpaceArgs args =3D { 0 }; int rv =3D -1; int counter =3D 0; =20 - memset(&args, 0, sizeof(args)); args.path =3D (char*)path; =20 if (!(client =3D virLockManagerLockDaemonConnectionNew(geteuid() =3D= =3D 0, &program))) @@ -671,9 +666,7 @@ static int virLockManagerLockDaemonAcquire(virLockManag= er *lock, if (!(flags & VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY)) { size_t i; for (i =3D 0; i < priv->nresources; i++) { - virLockSpaceProtocolAcquireResourceArgs args; - - memset(&args, 0, sizeof(args)); + virLockSpaceProtocolAcquireResourceArgs args =3D { 0 }; =20 args.path =3D priv->resources[i].lockspace; args.name =3D priv->resources[i].name; @@ -726,9 +719,7 @@ static int virLockManagerLockDaemonRelease(virLockManag= er *lock, goto cleanup; =20 for (i =3D 0; i < priv->nresources; i++) { - virLockSpaceProtocolReleaseResourceArgs args; - - memset(&args, 0, sizeof(args)); + virLockSpaceProtocolReleaseResourceArgs args =3D { 0 }; =20 if (priv->resources[i].lockspace) args.path =3D priv->resources[i].lockspace; diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c index 6e8e7e9f1a..d8490f4e5a 100644 --- a/src/logging/log_manager.c +++ b/src/logging/log_manager.c @@ -149,15 +149,12 @@ virLogManagerDomainOpenLogFile(virLogManager *mgr, ino_t *inode, off_t *offset) { - struct virLogManagerProtocolDomainOpenLogFileArgs args; - struct virLogManagerProtocolDomainOpenLogFileRet ret; + struct virLogManagerProtocolDomainOpenLogFileArgs args =3D { 0 }; + struct virLogManagerProtocolDomainOpenLogFileRet ret =3D { 0 }; int *fdout =3D NULL; size_t fdoutlen =3D 0; int rv =3D -1; =20 - memset(&args, 0, sizeof(args)); - memset(&ret, 0, sizeof(ret)); - args.driver =3D (char *)driver; memcpy(args.dom.uuid, domuuid, VIR_UUID_BUFLEN); args.dom.name =3D (char *)domname; @@ -208,11 +205,8 @@ virLogManagerDomainGetLogFilePosition(virLogManager *m= gr, ino_t *inode, off_t *offset) { - struct virLogManagerProtocolDomainGetLogFilePositionArgs args; - struct virLogManagerProtocolDomainGetLogFilePositionRet ret; - - memset(&args, 0, sizeof(args)); - memset(&ret, 0, sizeof(ret)); + struct virLogManagerProtocolDomainGetLogFilePositionArgs args =3D { 0 = }; + struct virLogManagerProtocolDomainGetLogFilePositionRet ret =3D { 0 }; =20 args.path =3D (char *)path; args.flags =3D flags; @@ -241,11 +235,8 @@ virLogManagerDomainReadLogFile(virLogManager *mgr, size_t maxlen, unsigned int flags) { - struct virLogManagerProtocolDomainReadLogFileArgs args; - struct virLogManagerProtocolDomainReadLogFileRet ret; - - memset(&args, 0, sizeof(args)); - memset(&ret, 0, sizeof(ret)); + struct virLogManagerProtocolDomainReadLogFileArgs args =3D { 0 }; + struct virLogManagerProtocolDomainReadLogFileRet ret =3D { 0 }; =20 args.path =3D (char *)path; args.flags =3D flags; @@ -275,11 +266,9 @@ virLogManagerDomainAppendMessage(virLogManager *mgr, const char *message, unsigned int flags) { - struct virLogManagerProtocolDomainAppendLogFileArgs args; + struct virLogManagerProtocolDomainAppendLogFileArgs args =3D { 0 }; struct virLogManagerProtocolDomainAppendLogFileRet ret; =20 - memset(&args, 0, sizeof(args)); - args.driver =3D (char *)driver; memcpy(args.dom.uuid, domuuid, VIR_UUID_BUFLEN); args.dom.name =3D (char *)domname; diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 86dcd880e8..51459b47e7 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -2235,10 +2235,9 @@ static int virLXCControllerEventSendExit(virLXCController *ctrl, int exitstatus) { - virLXCMonitorExitEventMsg msg; + virLXCMonitorExitEventMsg msg =3D { 0 }; =20 VIR_DEBUG("Exit status %d (client=3D%p)", exitstatus, ctrl->client); - memset(&msg, 0, sizeof(msg)); switch (exitstatus) { case 0: msg.status =3D VIR_LXC_MONITOR_EXIT_STATUS_SHUTDOWN; @@ -2272,10 +2271,9 @@ static int virLXCControllerEventSendInit(virLXCController *ctrl, pid_t initpid) { - virLXCMonitorInitEventMsg msg; + virLXCMonitorInitEventMsg msg =3D { 0 }; =20 VIR_DEBUG("Init pid %lld", (long long)initpid); - memset(&msg, 0, sizeof(msg)); msg.initpid =3D initpid; =20 virLXCControllerEventSend(ctrl, diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index e8c87423bf..cf9bf96a4e 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -339,13 +339,11 @@ virLXCDomainSetRunlevel(virDomainObj *vm, int runlevel) { virLXCDomainObjPrivate *priv =3D vm->privateData; - lxcDomainInitctlCallbackData data; + lxcDomainInitctlCallbackData data =3D { 0 }; size_t nfifos =3D 0; size_t i; int ret =3D -1; =20 - memset(&data, 0, sizeof(data)); - data.runlevel =3D runlevel; =20 for (nfifos =3D 0; virInitctlFifos[nfifos]; nfifos++) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 3bc01cbc23..f284798f1c 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3327,9 +3327,7 @@ lxcDomainAttachDeviceMknod(virLXCDriver *driver, char *file) { virLXCDomainObjPrivate *priv =3D vm->privateData; - struct lxcDomainAttachDeviceMknodData data; - - memset(&data, 0, sizeof(data)); + struct lxcDomainAttachDeviceMknodData data =3D { 0 }; =20 data.driver =3D driver; data.mode =3D mode; diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 3dc0b777e9..2f89923856 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -817,7 +817,7 @@ virNWFilterSnoopDHCPDecode(virNWFilterSnoopReq *req, struct iphdr *pip; struct udphdr *pup; virNWFilterSnoopDHCPHdr *pd; - virNWFilterSnoopIPLease ipl; + virNWFilterSnoopIPLease ipl =3D { 0 }; uint8_t mtype; uint32_t leasetime; uint32_t nwint; @@ -863,8 +863,6 @@ virNWFilterSnoopDHCPDecode(virNWFilterSnoopReq *req, if (virNWFilterSnoopDHCPGetOpt(pd, len, &mtype, &leasetime) < 0) return -2; =20 - memset(&ipl, 0, sizeof(ipl)); - memcpy(&nwint, &pd->d_yiaddr, sizeof(nwint)); virSocketAddrSetIPv4AddrNetOrder(&ipl.ipAddress, nwint); =20 diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 72e24e2f08..41f270bb7c 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -463,7 +463,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriver *techdri= ver, bool forceWithPendingReq) { int rc; - virNWFilterInst inst; + virNWFilterInst inst =3D { 0 }; bool instantiate =3D true; g_autofree char *buf =3D NULL; virNWFilterVarValue *lv; @@ -471,8 +471,6 @@ virNWFilterDoInstantiate(virNWFilterTechDriver *techdri= ver, bool reportIP =3D false; g_autoptr(GHashTable) missing_vars =3D virHashNew(virNWFilterVarValueH= ashFree); =20 - memset(&inst, 0, sizeof(inst)); - rc =3D virNWFilterDetermineMissingVarsRec(filter, binding->filterparams, missing_vars, diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index eda1308097..7fc412c17e 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -149,7 +149,7 @@ static void qemuAgentDispose(void *obj) static int qemuAgentOpenUnix(const char *socketpath) { - struct sockaddr_un addr; + struct sockaddr_un addr =3D { 0 }; int agentfd; =20 if ((agentfd =3D socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { @@ -165,7 +165,6 @@ qemuAgentOpenUnix(const char *socketpath) goto error; } =20 - memset(&addr, 0, sizeof(addr)); addr.sun_family =3D AF_UNIX; if (virStrcpyStatic(addr.sun_path, socketpath) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -803,11 +802,9 @@ qemuAgentGuestSyncSend(qemuAgent *agent, g_autofree char *txMsg =3D NULL; g_autoptr(virJSONValue) rxObj =3D NULL; unsigned long long id; - qemuAgentMessage sync_msg; + qemuAgentMessage sync_msg =3D { 0 }; int rc; =20 - memset(&sync_msg, 0, sizeof(sync_msg)); - if (virTimeMillisNow(&id) < 0) return -1; =20 @@ -1015,12 +1012,11 @@ qemuAgentCommandFull(qemuAgent *agent, bool report_unsupported) { int ret =3D -1; - qemuAgentMessage msg; + qemuAgentMessage msg =3D { 0 }; g_autofree char *cmdstr =3D NULL; int await_event =3D agent->await_event; =20 *reply =3D NULL; - memset(&msg, 0, sizeof(msg)); =20 if (!agent->running) { virReportError(VIR_ERR_AGENT_UNRESPONSIVE, "%s", diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 64af0b5ea9..77c5335bde 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4868,7 +4868,7 @@ qemuBuildSCSIHostdevDevProps(const virDomainDef *def, int qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) { - struct sockaddr_un addr; + struct sockaddr_un addr =3D { 0 }; socklen_t addrlen =3D sizeof(addr); int fd; =20 @@ -4878,7 +4878,6 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSource= Def *dev) goto error; } =20 - memset(&addr, 0, sizeof(addr)); addr.sun_family =3D AF_UNIX; if (virStrcpyStatic(addr.sun_path, dev->data.nix.path) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1f388306f4..f8039160f4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14933,8 +14933,8 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, qemuDomainObjPrivate *priv; virDomainDef *def =3D NULL; virDomainDef *persistentDef =3D NULL; - virDomainBlockIoTuneInfo info; - virDomainBlockIoTuneInfo conf_info; + virDomainBlockIoTuneInfo info =3D { 0 }; + virDomainBlockIoTuneInfo conf_info =3D { 0 }; int ret =3D -1; size_t i; virDomainDiskDef *conf_disk =3D NULL; @@ -14995,9 +14995,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, NULL) < 0) return -1; =20 - memset(&info, 0, sizeof(info)); - memset(&conf_info, 0, sizeof(conf_info)); - if (!(vm =3D qemuDomainObjFromDomain(dom))) return -1; =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c680c4b804..db34b6c179 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -227,7 +227,7 @@ qemuMonitorDispose(void *obj) static int qemuMonitorOpenUnix(const char *monitor) { - struct sockaddr_un addr; + struct sockaddr_un addr =3D { 0 }; VIR_AUTOCLOSE monfd =3D -1; int ret =3D -1; =20 @@ -237,7 +237,6 @@ qemuMonitorOpenUnix(const char *monitor) return -1; } =20 - memset(&addr, 0, sizeof(addr)); addr.sun_family =3D AF_UNIX; if (virStrcpyStatic(addr.sun_path, monitor) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -309,13 +308,12 @@ qemuMonitorIOWriteWithFD(qemuMonitor *mon, size_t len, int fd) { - struct msghdr msg; + struct msghdr msg =3D { 0 }; struct iovec iov[1]; int ret; char control[CMSG_SPACE(sizeof(int))]; struct cmsghdr *cmsg; =20 - memset(&msg, 0, sizeof(msg)); memset(control, 0, sizeof(control)); =20 iov[0].iov_base =3D (void *)data; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index d9e9a4481c..70536028ab 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -259,13 +259,11 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon, virJSONValue **reply) { int ret =3D -1; - qemuMonitorMessage msg; + qemuMonitorMessage msg =3D { 0 }; g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; =20 *reply =3D NULL; =20 - memset(&msg, 0, sizeof(msg)); - if (virJSONValueObjectHasKey(cmd, "execute")) { g_autofree char *id =3D qemuMonitorNextCommandID(mon); =20 @@ -2035,10 +2033,9 @@ qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitor *mon, char *balloonpath, int period) { - qemuMonitorJSONObjectProperty prop; + qemuMonitorJSONObjectProperty prop =3D { 0 }; =20 /* Set to the value in memballoon (could enable or disable) */ - memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_INT; prop.val.iv =3D period; if (qemuMonitorJSONSetObjectProperty(mon, balloonpath, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index db06991450..572b842349 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2226,14 +2226,13 @@ qemuRefreshRTC(virDomainObj *vm) { qemuDomainObjPrivate *priv =3D vm->privateData; time_t now, then; - struct tm thenbits; + struct tm thenbits =3D { 0 }; long localOffset; int rv; =20 if (vm->def->clock.offset !=3D VIR_DOMAIN_CLOCK_OFFSET_VARIABLE) return; =20 - memset(&thenbits, 0, sizeof(thenbits)); qemuDomainObjEnterMonitor(vm); now =3D time(NULL); rv =3D qemuMonitorGetRTCTime(priv->mon, &thenbits); diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 7144e9e7ca..2bb9e306a4 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -313,7 +313,7 @@ remoteRelayDomainEventLifecycle(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_lifecycle_msg data; + remote_domain_event_lifecycle_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -323,7 +323,6 @@ remoteRelayDomainEventLifecycle(virConnectPtr conn, event, detail, callback->callbackID, callback->legacy); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); data.event =3D event; data.detail =3D detail; @@ -352,7 +351,7 @@ remoteRelayDomainEventReboot(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_reboot_msg data; + remote_domain_event_reboot_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -362,7 +361,6 @@ remoteRelayDomainEventReboot(virConnectPtr conn, dom->name, dom->id, callback->callbackID, callback->legacy); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); =20 if (callback->legacy) { @@ -389,7 +387,7 @@ remoteRelayDomainEventRTCChange(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_rtc_change_msg data; + remote_domain_event_rtc_change_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -400,7 +398,6 @@ remoteRelayDomainEventRTCChange(virConnectPtr conn, callback->callbackID, callback->legacy); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); data.offset =3D offset; =20 @@ -428,7 +425,7 @@ remoteRelayDomainEventWatchdog(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_watchdog_msg data; + remote_domain_event_watchdog_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -438,7 +435,6 @@ remoteRelayDomainEventWatchdog(virConnectPtr conn, dom->name, dom->id, action, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); data.action =3D action; =20 @@ -468,7 +464,7 @@ remoteRelayDomainEventIOError(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_io_error_msg data; + remote_domain_event_io_error_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -479,7 +475,6 @@ remoteRelayDomainEventIOError(virConnectPtr conn, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.srcPath =3D g_strdup(srcPath); data.devAlias =3D g_strdup(devAlias); make_nonnull_domain(&data.dom, dom); @@ -512,7 +507,7 @@ remoteRelayDomainEventIOErrorReason(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_io_error_reason_msg data; + remote_domain_event_io_error_reason_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -523,7 +518,6 @@ remoteRelayDomainEventIOErrorReason(virConnectPtr conn, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.srcPath =3D g_strdup(srcPath); data.devAlias =3D g_strdup(devAlias); data.reason =3D g_strdup(reason); @@ -558,7 +552,7 @@ remoteRelayDomainEventGraphics(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_graphics_msg data; + remote_domain_event_graphics_msg data =3D { 0 }; size_t i; =20 if (callback->callbackID < 0 || @@ -576,7 +570,6 @@ remoteRelayDomainEventGraphics(virConnectPtr conn, VIR_DEBUG(" %s=3D%s", subject->identities[i].type, subject->ident= ities[i].name); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.phase =3D phase; data.local.family =3D local->family; data.remote.family =3D remote->family; @@ -625,7 +618,7 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_block_job_msg data; + remote_domain_event_block_job_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -635,7 +628,6 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn, dom->name, dom->id, path, type, status, callback->callbackID= ); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.path =3D g_strdup(path); data.type =3D type; data.status =3D status; @@ -664,7 +656,7 @@ remoteRelayDomainEventControlError(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_control_error_msg data; + remote_domain_event_control_error_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -674,7 +666,6 @@ remoteRelayDomainEventControlError(virConnectPtr conn, dom->name, dom->id, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); =20 if (callback->legacy) { @@ -704,7 +695,7 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_disk_change_msg data; + remote_domain_event_disk_change_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -715,7 +706,6 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); if (oldSrcPath) { data.oldSrcPath =3D g_new0(remote_nonnull_string, 1); *(data.oldSrcPath) =3D g_strdup(oldSrcPath); @@ -755,7 +745,7 @@ remoteRelayDomainEventTrayChange(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_tray_change_msg data; + remote_domain_event_tray_change_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -765,8 +755,6 @@ remoteRelayDomainEventTrayChange(virConnectPtr conn, dom->name, dom->id, devAlias, reason, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); - data.devAlias =3D g_strdup(devAlias); data.reason =3D reason; make_nonnull_domain(&data.dom, dom); @@ -794,7 +782,7 @@ remoteRelayDomainEventPMWakeup(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_pmwakeup_msg data; + remote_domain_event_pmwakeup_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -804,7 +792,6 @@ remoteRelayDomainEventPMWakeup(virConnectPtr conn, dom->name, dom->id, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); =20 if (callback->legacy) { @@ -830,7 +817,7 @@ remoteRelayDomainEventPMSuspend(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_pmsuspend_msg data; + remote_domain_event_pmsuspend_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -840,7 +827,6 @@ remoteRelayDomainEventPMSuspend(virConnectPtr conn, dom->name, dom->id, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); =20 if (callback->legacy) { @@ -866,7 +852,7 @@ remoteRelayDomainEventBalloonChange(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_balloon_change_msg data; + remote_domain_event_balloon_change_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -876,7 +862,6 @@ remoteRelayDomainEventBalloonChange(virConnectPtr conn, dom->name, dom->id, actual, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); data.actual =3D actual; =20 @@ -904,7 +889,7 @@ remoteRelayDomainEventPMSuspendDisk(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_pmsuspend_disk_msg data; + remote_domain_event_pmsuspend_disk_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -914,7 +899,6 @@ remoteRelayDomainEventPMSuspendDisk(virConnectPtr conn, dom->name, dom->id, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_domain(&data.dom, dom); =20 if (callback->legacy) { @@ -940,7 +924,7 @@ remoteRelayDomainEventDeviceRemoved(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_device_removed_msg data; + remote_domain_event_device_removed_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -950,8 +934,6 @@ remoteRelayDomainEventDeviceRemoved(virConnectPtr conn, dom->name, dom->id, devAlias, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); - data.devAlias =3D g_strdup(devAlias); =20 make_nonnull_domain(&data.dom, dom); @@ -984,7 +966,7 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_block_job_2_msg data; + remote_domain_event_block_job_2_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -994,7 +976,6 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn, dom->name, dom->id, dst, type, status, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; data.dst =3D g_strdup(dst); data.type =3D type; @@ -1017,7 +998,7 @@ remoteRelayDomainEventTunable(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_callback_tunable_msg data; + remote_domain_event_callback_tunable_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -1027,8 +1008,6 @@ remoteRelayDomainEventTunable(virConnectPtr conn, dom->name, dom->id, callback->callbackID, params, nparams); =20 /* build return data */ - memset(&data, 0, sizeof(data)); - if (virTypedParamsSerialize(params, nparams, REMOTE_DOMAIN_EVENT_TUNABLE_MAX, (struct _virTypedParameterRemote **) &data= .params.params_val, @@ -1057,7 +1036,7 @@ remoteRelayDomainEventAgentLifecycle(virConnectPtr co= nn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_callback_agent_lifecycle_msg data; + remote_domain_event_callback_agent_lifecycle_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -1068,7 +1047,6 @@ remoteRelayDomainEventAgentLifecycle(virConnectPtr co= nn, dom->name, dom->id, callback->callbackID, state, reason); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; make_nonnull_domain(&data.dom, dom); data.state =3D state; @@ -1090,7 +1068,7 @@ remoteRelayDomainEventDeviceAdded(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_callback_device_added_msg data; + remote_domain_event_callback_device_added_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -1100,8 +1078,6 @@ remoteRelayDomainEventDeviceAdded(virConnectPtr conn, dom->name, dom->id, devAlias, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); - data.devAlias =3D g_strdup(devAlias); make_nonnull_domain(&data.dom, dom); data.callbackID =3D callback->callbackID; @@ -1122,7 +1098,7 @@ remoteRelayDomainEventMigrationIteration(virConnectPt= r conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_callback_migration_iteration_msg data; + remote_domain_event_callback_migration_iteration_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -1133,7 +1109,6 @@ remoteRelayDomainEventMigrationIteration(virConnectPt= r conn, dom->name, dom->id, callback->callbackID, iteration); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; make_nonnull_domain(&data.dom, dom); =20 @@ -1156,7 +1131,7 @@ remoteRelayDomainEventJobCompleted(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_callback_job_completed_msg data; + remote_domain_event_callback_job_completed_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -1167,8 +1142,6 @@ remoteRelayDomainEventJobCompleted(virConnectPtr conn, dom->name, dom->id, callback->callbackID, params, nparams); =20 /* build return data */ - memset(&data, 0, sizeof(data)); - if (virTypedParamsSerialize(params, nparams, REMOTE_DOMAIN_JOB_STATS_MAX, (struct _virTypedParameterRemote **) &data= .params.params_val, @@ -1194,7 +1167,7 @@ remoteRelayDomainEventDeviceRemovalFailed(virConnectP= tr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_callback_device_removal_failed_msg data; + remote_domain_event_callback_device_removal_failed_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -1204,8 +1177,6 @@ remoteRelayDomainEventDeviceRemovalFailed(virConnectP= tr conn, dom->name, dom->id, devAlias, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); - data.devAlias =3D g_strdup(devAlias); =20 make_nonnull_domain(&data.dom, dom); @@ -1228,7 +1199,7 @@ remoteRelayDomainEventMetadataChange(virConnectPtr co= nn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_callback_metadata_change_msg data; + remote_domain_event_callback_metadata_change_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -1238,8 +1209,6 @@ remoteRelayDomainEventMetadataChange(virConnectPtr co= nn, dom->name, dom->id, type, NULLSTR(nsuri), callback->callback= ID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); - data.type =3D type; if (nsuri) { data.nsuri =3D g_new0(remote_nonnull_string, 1); @@ -1268,7 +1237,7 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr co= nn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_block_threshold_msg data; + remote_domain_event_block_threshold_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) @@ -1278,7 +1247,6 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr co= nn, dom->name, dom->id, dev, NULLSTR(path), threshold, excess, c= allback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; data.dev =3D g_strdup(dev); if (path) { @@ -1306,14 +1274,13 @@ remoteRelayDomainEventMemoryFailure(virConnectPtr c= onn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_memory_failure_msg data; + remote_domain_event_memory_failure_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) return -1; =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; data.recipient =3D recipient; data.action =3D action; @@ -1336,14 +1303,13 @@ remoteRelayDomainEventMemoryDeviceSizeChange(virCon= nectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_domain_event_memory_device_size_change_msg data; + remote_domain_event_memory_device_size_change_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainEventCheckACL(callback->client, conn, dom)) return -1; =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; data.alias =3D g_strdup(alias); data.size =3D size; @@ -1397,7 +1363,7 @@ remoteRelayNetworkEventLifecycle(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_network_event_lifecycle_msg data; + remote_network_event_lifecycle_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayNetworkEventCheckACL(callback->client, conn, net)) @@ -1407,7 +1373,6 @@ remoteRelayNetworkEventLifecycle(virConnectPtr conn, event, detail, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_network(&data.net, net); data.callbackID =3D callback->callbackID; data.event =3D event; @@ -1434,7 +1399,7 @@ remoteRelayStoragePoolEventLifecycle(virConnectPtr co= nn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_storage_pool_event_lifecycle_msg data; + remote_storage_pool_event_lifecycle_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayStoragePoolEventCheckACL(callback->client, conn, pool)) @@ -1444,7 +1409,6 @@ remoteRelayStoragePoolEventLifecycle(virConnectPtr co= nn, event, detail, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_storage_pool(&data.pool, pool); data.callbackID =3D callback->callbackID; data.event =3D event; @@ -1464,7 +1428,7 @@ remoteRelayStoragePoolEventRefresh(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_storage_pool_event_refresh_msg data; + remote_storage_pool_event_refresh_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayStoragePoolEventCheckACL(callback->client, conn, pool)) @@ -1474,7 +1438,6 @@ remoteRelayStoragePoolEventRefresh(virConnectPtr conn, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_storage_pool(&data.pool, pool); data.callbackID =3D callback->callbackID; =20 @@ -1501,7 +1464,7 @@ remoteRelayNodeDeviceEventLifecycle(virConnectPtr con= n, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_node_device_event_lifecycle_msg data; + remote_node_device_event_lifecycle_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayNodeDeviceEventCheckACL(callback->client, conn, dev)) @@ -1511,7 +1474,6 @@ remoteRelayNodeDeviceEventLifecycle(virConnectPtr con= n, event, detail, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_node_device(&data.dev, dev); data.callbackID =3D callback->callbackID; data.event =3D event; @@ -1531,7 +1493,7 @@ remoteRelayNodeDeviceEventUpdate(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_node_device_event_update_msg data; + remote_node_device_event_update_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayNodeDeviceEventCheckACL(callback->client, conn, dev)) @@ -1541,7 +1503,6 @@ remoteRelayNodeDeviceEventUpdate(virConnectPtr conn, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_node_device(&data.dev, dev); data.callbackID =3D callback->callbackID; =20 @@ -1568,7 +1529,7 @@ remoteRelaySecretEventLifecycle(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_secret_event_lifecycle_msg data; + remote_secret_event_lifecycle_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelaySecretEventCheckACL(callback->client, conn, secret)) @@ -1578,7 +1539,6 @@ remoteRelaySecretEventLifecycle(virConnectPtr conn, event, detail, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_secret(&data.secret, secret); data.callbackID =3D callback->callbackID; data.event =3D event; @@ -1598,7 +1558,7 @@ remoteRelaySecretEventValueChanged(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - remote_secret_event_value_changed_msg data; + remote_secret_event_value_changed_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelaySecretEventCheckACL(callback->client, conn, secret)) @@ -1608,7 +1568,6 @@ remoteRelaySecretEventValueChanged(virConnectPtr conn, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); make_nonnull_secret(&data.secret, secret); data.callbackID =3D callback->callbackID; =20 @@ -1637,7 +1596,7 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, void *opaque) { daemonClientEventCallback *callback =3D opaque; - qemu_domain_monitor_event_msg data; + qemu_domain_monitor_event_msg data =3D { 0 }; =20 if (callback->callbackID < 0 || !remoteRelayDomainQemuMonitorEventCheckACL(callback->client, conn, @@ -1648,7 +1607,6 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, event, details, callback->callbackID); =20 /* build return data */ - memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; data.event =3D g_strdup(event); data.seconds =3D seconds; @@ -2677,14 +2635,13 @@ remoteDispatchNodeGetSecurityModel(virNetServer *se= rver G_GNUC_UNUSED, struct virNetMessageError *rerr, remote_node_get_security_model_ret *ret) { - virSecurityModel secmodel; + virSecurityModel secmodel =3D { 0 }; int rv =3D -1; virConnectPtr conn =3D remoteGetHypervisorConn(client); =20 if (!conn) goto cleanup; =20 - memset(&secmodel, 0, sizeof(secmodel)); if (virNodeGetSecurityModel(conn, &secmodel) < 0) goto cleanup; =20 diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index f52af790c1..1a89ff822c 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -226,12 +226,11 @@ daemonStreamEvent(virStreamPtr st, int events, void *= opaque) (events & (VIR_STREAM_EVENT_ERROR | VIR_STREAM_EVENT_HANGUP))) { int ret; virNetMessage *msg; - virNetMessageError rerr; + virNetMessageError rerr =3D { 0 }; virErrorPtr origErr; =20 virErrorPreserveLast(&origErr); =20 - memset(&rerr, 0, sizeof(rerr)); stream->closed =3D true; virStreamEventRemoveCallback(stream->st); virStreamAbort(stream->st); @@ -565,13 +564,11 @@ daemonStreamHandleWriteData(virNetServerClient *clien= t, /* Blocking, so indicate we have more todo later */ return 1; } else if (ret < 0) { - virNetMessageError rerr; + virNetMessageError rerr =3D { 0 }; virErrorPtr err; =20 virErrorPreserveLast(&err); =20 - memset(&rerr, 0, sizeof(rerr)); - VIR_INFO("Stream send failed"); stream->closed =3D true; virStreamEventRemoveCallback(stream->st); @@ -613,8 +610,8 @@ daemonStreamHandleFinish(virNetServerClient *client, ret =3D virStreamFinish(stream->st); =20 if (ret < 0) { - virNetMessageError rerr; - memset(&rerr, 0, sizeof(rerr)); + virNetMessageError rerr =3D { 0 }; + return virNetServerProgramSendReplyError(stream->prog, client, msg, @@ -663,8 +660,8 @@ daemonStreamHandleAbort(virNetServerClient *client, } =20 if (raise_error) { - virNetMessageError rerr; - memset(&rerr, 0, sizeof(rerr)); + virNetMessageError rerr =3D { 0 }; + return virNetServerProgramSendReplyError(stream->prog, client, msg, @@ -709,9 +706,7 @@ daemonStreamHandleHole(virNetServerClient *client, ret =3D virStreamSendHole(stream->st, data.length, data.flags); =20 if (ret < 0) { - virNetMessageError rerr; - - memset(&rerr, 0, sizeof(rerr)); + virNetMessageError rerr =3D { 0 }; =20 VIR_INFO("Stream send hole failed"); stream->closed =3D true; @@ -825,7 +820,7 @@ daemonStreamHandleRead(virNetServerClient *client, daemonClientStream *stream) { virNetMessage *msg =3D NULL; - virNetMessageError rerr; + virNetMessageError rerr =3D { 0 }; char *buffer; size_t bufferLen =3D VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX; int ret =3D -1; @@ -848,8 +843,6 @@ daemonStreamHandleRead(virNetServerClient *client, if (!stream->tx) return 0; =20 - memset(&rerr, 0, sizeof(rerr)); - buffer =3D g_new0(char, bufferLen); =20 if (!(msg =3D virNetMessageNew(false))) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 7ccf550dff..8e78af0ea0 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1184,10 +1184,9 @@ doRemoteOpen(virConnectPtr conn, =20 /* Now try and find out what URI the daemon used */ if (conn->uri =3D=3D NULL) { - remote_connect_get_uri_ret uriret; + remote_connect_get_uri_ret uriret =3D { 0 }; =20 VIR_DEBUG("Trying to query remote URI"); - memset(&uriret, 0, sizeof(uriret)); if (call(conn, priv, 0, REMOTE_PROC_CONNECT_GET_URI, (xdrproc_t) xdr_void, (char *) NULL, @@ -3725,9 +3724,9 @@ static int remoteAuthSASL(virConnectPtr conn, struct private_data *priv, virConnectAuthPtr auth, const char *wantmech) { - remote_auth_sasl_init_ret iret; + remote_auth_sasl_init_ret iret =3D { 0 }; remote_auth_sasl_start_args sargs =3D {0}; - remote_auth_sasl_start_ret sret; + remote_auth_sasl_start_ret sret =3D { 0 }; const char *clientout; char *serverin =3D NULL; size_t clientoutlen, serverinlen; @@ -3739,9 +3738,7 @@ remoteAuthSASL(virConnectPtr conn, struct private_dat= a *priv, const char *mechlist; virNetSASLContext *saslCtxt; virNetSASLSession *sasl =3D NULL; - struct remoteAuthInteractState state; - - memset(&state, 0, sizeof(state)); + struct remoteAuthInteractState state =3D { 0 }; =20 VIR_DEBUG("Client initialize SASL authentication"); =20 @@ -3787,7 +3784,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_dat= a *priv, goto cleanup; =20 /* First call is to inquire about supported mechanisms in the server */ - memset(&iret, 0, sizeof(iret)); if (call(conn, priv, 0, REMOTE_PROC_AUTH_SASL_INIT, (xdrproc_t) xdr_void, (char *)NULL, (xdrproc_t) xdr_remote_auth_sasl_init_ret, (char *) &iret) != =3D 0) @@ -3841,7 +3837,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_dat= a *priv, mech, clientoutlen, clientout); =20 /* Now send the initial auth data to the server */ - memset(&sret, 0, sizeof(sret)); if (call(conn, priv, 0, REMOTE_PROC_AUTH_SASL_START, (xdrproc_t) xdr_remote_auth_sasl_start_args, (char *) &sargs, (xdrproc_t) xdr_remote_auth_sasl_start_ret, (char *) &sret) != =3D 0) diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c index abc8e6798a..31eee72fc8 100644 --- a/src/rpc/virnetclientprogram.c +++ b/src/rpc/virnetclientprogram.c @@ -116,11 +116,9 @@ static int virNetClientProgramDispatchError(virNetClientProgram *prog G_GNUC_UNUSED, virNetMessage *msg) { - virNetMessageError err; + virNetMessageError err =3D { 0 }; int ret =3D -1; =20 - memset(&err, 0, sizeof(err)); - if (virNetMessageDecodePayload(msg, (xdrproc_t)xdr_virNetMessageError,= &err) < 0) goto cleanup; =20 diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c index 21e9332134..98034d737d 100644 --- a/src/rpc/virnetclientstream.c +++ b/src/rpc/virnetclientstream.c @@ -261,7 +261,7 @@ void virNetClientStreamSetClosed(virNetClientStream *st, int virNetClientStreamSetError(virNetClientStream *st, virNetMessage *msg) { - virNetMessageError err; + virNetMessageError err =3D { 0 }; int ret =3D -1; =20 virObjectLock(st); @@ -270,7 +270,6 @@ int virNetClientStreamSetError(virNetClientStream *st, VIR_DEBUG("Overwriting existing stream error %s", NULLSTR(st->err.= message)); =20 virResetError(&st->err); - memset(&err, 0, sizeof(err)); =20 if (virNetMessageDecodePayload(msg, (xdrproc_t)xdr_virNetMessageError,= &err) < 0) goto cleanup; @@ -444,13 +443,12 @@ virNetClientStreamHandleHole(virNetClient *client, virNetClientStream *st) { virNetMessage *msg; - virNetStreamHole data; + virNetStreamHole data =3D { 0 }; int ret =3D -1; =20 VIR_DEBUG("client=3D%p st=3D%p", client, st); =20 msg =3D st->rx; - memset(&data, 0, sizeof(data)); =20 /* We should not be called unless there's VIR_NET_STREAM_HOLE * message at the head of the list. But doesn't hurt to check */ @@ -634,7 +632,7 @@ virNetClientStreamSendHole(virNetClientStream *st, unsigned int flags) { virNetMessage *msg =3D NULL; - virNetStreamHole data; + virNetStreamHole data =3D { 0 }; int ret =3D -1; =20 VIR_DEBUG("st=3D%p length=3D%llu", st, length); @@ -645,7 +643,6 @@ virNetClientStreamSendHole(virNetClientStream *st, return -1; } =20 - memset(&data, 0, sizeof(data)); data.length =3D length; data.flags =3D flags; =20 diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index d37984d207..9795418126 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -692,7 +692,7 @@ virNetDaemonAddSignalHandler(virNetDaemon *dmn, void *opaque) { g_autofree virNetDaemonSignal *sigdata =3D NULL; - struct sigaction sig_action; + struct sigaction sig_action =3D { 0 }; VIR_LOCK_GUARD lock =3D virObjectLockGuard(dmn); =20 if (virNetDaemonSignalSetup(dmn) < 0) @@ -706,7 +706,6 @@ virNetDaemonAddSignalHandler(virNetDaemon *dmn, sigdata->func =3D func; sigdata->opaque =3D opaque; =20 - memset(&sig_action, 0, sizeof(sig_action)); sig_action.sa_sigaction =3D virNetDaemonSignalHandler; sig_action.sa_flags =3D SA_SIGINFO; sigemptyset(&sig_action.sa_mask); diff --git a/src/rpc/virnetsaslcontext.c b/src/rpc/virnetsaslcontext.c index 7151225cc3..8692703117 100644 --- a/src/rpc/virnetsaslcontext.c +++ b/src/rpc/virnetsaslcontext.c @@ -331,7 +331,7 @@ int virNetSASLSessionSecProps(virNetSASLSession *sasl, int maxSSF, bool allowAnonymous) { - sasl_security_properties_t secprops; + sasl_security_properties_t secprops =3D { 0 }; int err; int ret =3D -1; =20 @@ -339,7 +339,6 @@ int virNetSASLSessionSecProps(virNetSASLSession *sasl, minSSF, maxSSF, allowAnonymous, sasl->maxbufsize); =20 virObjectLock(sasl); - memset(&secprops, 0, sizeof(secprops)); =20 secprops.min_ssf =3D minSSF; secprops.max_ssf =3D maxSSF; diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c index 2cce188a09..b1236bf49b 100644 --- a/src/rpc/virnetserverprogram.c +++ b/src/rpc/virnetserverprogram.c @@ -229,12 +229,11 @@ int virNetServerProgramUnknownError(virNetServerClien= t *client, virNetMessage *msg, struct virNetMessageHeader *req) { - virNetMessageError rerr; + virNetMessageError rerr =3D { 0 }; =20 virReportError(VIR_ERR_RPC, _("Cannot find program %1$d version %2$d"), req->prog, = req->vers); =20 - memset(&rerr, 0, sizeof(rerr)); return virNetServerProgramSendError(req->prog, req->vers, client, @@ -273,9 +272,7 @@ int virNetServerProgramDispatch(virNetServerProgram *pr= og, virNetMessage *msg) { int ret =3D -1; - virNetMessageError rerr; - - memset(&rerr, 0, sizeof(rerr)); + virNetMessageError rerr =3D { 0 }; =20 VIR_DEBUG("prog=3D%d ver=3D%d type=3D%d status=3D%d serial=3D%u proc= =3D%d", msg->header.prog, msg->header.vers, msg->header.type, @@ -369,12 +366,10 @@ virNetServerProgramDispatchCall(virNetServerProgram *= prog, g_autofree char *ret =3D NULL; int rv =3D -1; virNetServerProgramProc *dispatcher =3D NULL; - virNetMessageError rerr; + virNetMessageError rerr =3D { 0 }; size_t i; g_autoptr(virIdentity) identity =3D NULL; =20 - memset(&rerr, 0, sizeof(rerr)); - if (msg->header.status !=3D VIR_NET_OK) { virReportError(VIR_ERR_RPC, _("Unexpected message status %1$u"), @@ -533,11 +528,10 @@ int virNetServerProgramSendStreamHole(virNetServerPro= gram *prog, long long length, unsigned int flags) { - virNetStreamHole data; + virNetStreamHole data =3D { 0 }; =20 VIR_DEBUG("client=3D%p msg=3D%p length=3D%lld", client, msg, length); =20 - memset(&data, 0, sizeof(data)); data.length =3D length; data.flags =3D flags; =20 diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 910fb8dd67..b58f7a6b8f 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -143,11 +143,10 @@ virNetSocketCheckProtocolByLookup(const char *address, int family, bool *hasFamily) { - struct addrinfo hints; + struct addrinfo hints =3D { 0 }; struct addrinfo *ai =3D NULL; int gaierr; =20 - memset(&hints, 0, sizeof(hints)); hints.ai_family =3D family; hints.ai_flags =3D AI_PASSIVE | AI_ADDRCONFIG; hints.ai_socktype =3D SOCK_STREAM; @@ -313,7 +312,7 @@ int virNetSocketNewListenTCP(const char *nodename, virNetSocket **socks =3D NULL; size_t nsocks =3D 0; struct addrinfo *ai =3D NULL; - struct addrinfo hints; + struct addrinfo hints =3D { 0 }; int fd =3D -1; size_t i; int socketErrno =3D 0; @@ -326,7 +325,6 @@ int virNetSocketNewListenTCP(const char *nodename, *retsocks =3D NULL; *nretsocks =3D 0; =20 - memset(&hints, 0, sizeof(hints)); hints.ai_family =3D family; hints.ai_flags =3D AI_PASSIVE; hints.ai_socktype =3D SOCK_STREAM; @@ -353,9 +351,7 @@ int virNetSocketNewListenTCP(const char *nodename, =20 runp =3D ai; while (runp) { - virSocketAddr addr; - - memset(&addr, 0, sizeof(addr)); + virSocketAddr addr =3D { 0 }; =20 if ((fd =3D socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol)) < 0) { @@ -477,14 +473,12 @@ int virNetSocketNewListenUNIX(const char *path, gid_t grp, virNetSocket **retsock) { - virSocketAddr addr; + virSocketAddr addr =3D { 0 }; mode_t oldmask; int fd; =20 *retsock =3D NULL; =20 - memset(&addr, 0, sizeof(addr)); - addr.len =3D sizeof(addr.data.un); =20 if ((fd =3D socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { @@ -553,11 +547,9 @@ int virNetSocketNewListenFD(int fd, bool unlinkUNIX, virNetSocket **retsock) { - virSocketAddr addr; + virSocketAddr addr =3D { 0 }; *retsock =3D NULL; =20 - memset(&addr, 0, sizeof(addr)); - addr.len =3D sizeof(addr.data); if (getsockname(fd, &addr.data.sa, &addr.len) < 0) { virReportSystemError(errno, "%s", _("Unable to get local socket na= me")); @@ -577,20 +569,16 @@ int virNetSocketNewConnectTCP(const char *nodename, virNetSocket **retsock) { struct addrinfo *ai =3D NULL; - struct addrinfo hints; + struct addrinfo hints =3D { 0 }; int fd =3D -1; - virSocketAddr localAddr; - virSocketAddr remoteAddr; + virSocketAddr localAddr =3D { 0 }; + virSocketAddr remoteAddr =3D { 0 }; struct addrinfo *runp; int savedErrno =3D ENOENT; int e; =20 *retsock =3D NULL; =20 - memset(&localAddr, 0, sizeof(localAddr)); - memset(&remoteAddr, 0, sizeof(remoteAddr)); - - memset(&hints, 0, sizeof(hints)); hints.ai_family =3D family; hints.ai_flags =3D AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED; hints.ai_socktype =3D SOCK_STREAM; @@ -666,17 +654,14 @@ int virNetSocketNewConnectUNIX(const char *path, VIR_AUTOCLOSE lockfd =3D -1; int fd =3D -1; int retries =3D 500; - virSocketAddr localAddr; - virSocketAddr remoteAddr; + virSocketAddr localAddr =3D { 0 }; + virSocketAddr remoteAddr =3D { 0 }; g_autofree char *rundir =3D NULL; int ret =3D -1; bool daemonLaunched =3D false; =20 VIR_DEBUG("path=3D%s spawnDaemonPath=3D%s", path, NULLSTR(spawnDaemonP= ath)); =20 - memset(&localAddr, 0, sizeof(localAddr)); - memset(&remoteAddr, 0, sizeof(remoteAddr)); - remoteAddr.len =3D sizeof(remoteAddr.data.un); =20 if (spawnDaemonPath) { @@ -1168,8 +1153,8 @@ int virNetSocketNewConnectSockFD(int sockfd, =20 virNetSocket *virNetSocketNewPostExecRestart(virJSONValue *object) { - virSocketAddr localAddr; - virSocketAddr remoteAddr; + virSocketAddr localAddr =3D { 0 }; + virSocketAddr remoteAddr =3D { 0 }; int fd, thepid, errfd; bool isClient; bool unlinkUNIX; @@ -1201,9 +1186,6 @@ virNetSocket *virNetSocketNewPostExecRestart(virJSONV= alue *object) if (virJSONValueObjectGetBoolean(object, "unlinkUNIX", &unlinkUNIX) < = 0) unlinkUNIX =3D !isClient; =20 - memset(&localAddr, 0, sizeof(localAddr)); - memset(&remoteAddr, 0, sizeof(remoteAddr)); - remoteAddr.len =3D sizeof(remoteAddr.data.stor); if (getsockname(fd, &remoteAddr.data.sa, &remoteAddr.len) < 0) { virReportSystemError(errno, "%s", _("Unable to get peer socket nam= e")); @@ -2059,17 +2041,14 @@ int virNetSocketListen(virNetSocket *sock, int back= log) int virNetSocketAccept(virNetSocket *sock, virNetSocket **clientsock) { int fd =3D -1; - virSocketAddr localAddr; - virSocketAddr remoteAddr; + virSocketAddr localAddr =3D { 0 }; + virSocketAddr remoteAddr =3D { 0 }; int ret =3D -1; =20 virObjectLock(sock); =20 *clientsock =3D NULL; =20 - memset(&localAddr, 0, sizeof(localAddr)); - memset(&remoteAddr, 0, sizeof(remoteAddr)); - remoteAddr.len =3D sizeof(remoteAddr.data.stor); if ((fd =3D accept(sock->fd, &remoteAddr.data.sa, &remoteAddr.len)) < = 0) { if (errno =3D=3D ECONNABORTED || diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index 98be120a11..16d420467e 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -559,7 +559,7 @@ static int virNetSSHAuthenticatePrivkey(virNetSSHSession *sess, virNetSSHAuthMethod *priv) { - virConnectCredential retr_passphrase; + virConnectCredential retr_passphrase =3D { 0 }; size_t i; char *errmsg; int ret; @@ -594,7 +594,6 @@ virNetSSHAuthenticatePrivkey(virNetSSHSession *sess, return -1; } =20 - memset(&retr_passphrase, 0, sizeof(virConnectCredential)); retr_passphrase.type =3D -1; =20 for (i =3D 0; i < sess->cred->ncredtype; i++) { diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 60dc68cf4b..9462ac6790 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -186,11 +186,9 @@ virStorageBackendLogicalParseVolExtents(virStorageVolD= ef *vol, */ for (i =3D 0; i < nextents; i++) { g_autofree char *offset_str =3D NULL; - virStorageVolSourceExtent extent; + virStorageVolSourceExtent extent =3D { 0 }; size_t j =3D (i * 2) + 1; =20 - memset(&extent, 0, sizeof(extent)); - offset_str =3D g_match_info_fetch(info, j + 1); =20 if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) { @@ -503,13 +501,12 @@ static char * virStorageBackendLogicalFindPoolSources(const char *srcSpec G_GNUC_UNUSED, unsigned int flags) { - virStoragePoolSourceList sourceList; + virStoragePoolSourceList sourceList =3D { 0 }; size_t i; char *retval =3D NULL; =20 virCheckFlags(0, NULL); =20 - memset(&sourceList, 0, sizeof(sourceList)); sourceList.type =3D VIR_STORAGE_POOL_LOGICAL; =20 if (virStorageBackendLogicalGetPoolSources(&sourceList) < 0) @@ -549,13 +546,12 @@ static bool virStorageBackendLogicalMatchPoolSource(virStoragePoolObj *pool) { virStoragePoolDef *def =3D virStoragePoolObjGetDef(pool); - virStoragePoolSourceList sourceList; + virStoragePoolSourceList sourceList =3D { 0 }; virStoragePoolSource *thisSource =3D NULL; size_t i, j; int matchcount =3D 0; bool ret =3D false; =20 - memset(&sourceList, 0, sizeof(sourceList)); sourceList.type =3D VIR_STORAGE_POOL_LOGICAL; =20 if (virStorageBackendLogicalGetPoolSources(&sourceList) < 0) diff --git a/src/util/virarptable.c b/src/util/virarptable.c index 7f9fefc160..299dddd664 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -111,13 +111,12 @@ virArpTableGet(void) =20 if (tb[NDA_DST]) { g_autofree char *ipstr =3D NULL; - virSocketAddr virAddr; + virSocketAddr virAddr =3D { 0 }; =20 VIR_REALLOC_N(table->t, num + 1); table->n =3D num + 1; =20 addr =3D RTA_DATA(tb[NDA_DST]); - memset(&virAddr, 0, sizeof(virAddr)); virAddr.len =3D sizeof(virAddr.data.inet4); virAddr.data.inet4.sin_family =3D AF_INET; virAddr.data.inet4.sin_addr =3D *(struct in_addr *)addr; diff --git a/src/util/virauth.c b/src/util/virauth.c index bd676858ce..e7a5f7f010 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -135,7 +135,7 @@ virAuthGetUsernamePath(const char *path, const char *hostname) { unsigned int ncred; - virConnectCredential cred; + virConnectCredential cred =3D { 0 }; g_autofree char *prompt =3D NULL; char *ret =3D NULL; =20 @@ -150,8 +150,6 @@ virAuthGetUsernamePath(const char *path, return NULL; } =20 - memset(&cred, 0, sizeof(virConnectCredential)); - if (defaultUsername !=3D NULL) { prompt =3D g_strdup_printf(_("Enter username for %1$s [%2$s]"), ho= stname, defaultUsername); diff --git a/src/util/virbpf.c b/src/util/virbpf.c index 34abf6f9b4..78fa102b4d 100644 --- a/src/util/virbpf.c +++ b/src/util/virbpf.c @@ -35,9 +35,7 @@ virBPFCreateMap(unsigned int mapType, unsigned int valSize, unsigned int maxEntries) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.map_type =3D mapType; attr.key_size =3D keySize; @@ -57,12 +55,10 @@ virBPFLoadProg(struct bpf_insn *insns, { g_autofree char *logbuf =3D NULL; int progfd =3D -1; - union bpf_attr attr; + union bpf_attr attr =3D { 0 }; =20 logbuf =3D g_new0(char, LOG_BUF_SIZE); =20 - memset(&attr, 0, sizeof(attr)); - attr.prog_type =3D progType; attr.insn_cnt =3D insnCnt; attr.insns =3D (uintptr_t)insns; @@ -85,9 +81,7 @@ virBPFAttachProg(int progfd, int targetfd, int attachType) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.target_fd =3D targetfd; attr.attach_bpf_fd =3D progfd; @@ -102,9 +96,7 @@ virBPFDetachProg(int progfd, int targetfd, int attachType) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.target_fd =3D targetfd; attr.attach_bpf_fd =3D progfd; @@ -121,11 +113,9 @@ virBPFQueryProg(int targetfd, unsigned int *progcnt, void *progids) { - union bpf_attr attr; + union bpf_attr attr =3D { 0 }; int rc; =20 - memset(&attr, 0, sizeof(attr)); - attr.query.target_fd =3D targetfd; attr.query.attach_type =3D attachType; attr.query.prog_cnt =3D maxprogids; @@ -143,9 +133,7 @@ virBPFQueryProg(int targetfd, int virBPFGetProg(unsigned int id) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.prog_id =3D id; =20 @@ -158,11 +146,9 @@ virBPFGetProgInfo(int progfd, struct bpf_prog_info *info, unsigned int **mapIDs) { - union bpf_attr attr; + union bpf_attr attr =3D { 0 }; int rc; =20 - memset(&attr, 0, sizeof(attr)); - attr.info.bpf_fd =3D progfd; attr.info.info_len =3D sizeof(struct bpf_prog_info); attr.info.info =3D (uintptr_t)info; @@ -200,9 +186,7 @@ virBPFGetProgInfo(int progfd, int virBPFGetMap(unsigned int id) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.map_id =3D id; =20 @@ -214,9 +198,7 @@ int virBPFGetMapInfo(int mapfd, struct bpf_map_info *info) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.info.bpf_fd =3D mapfd; attr.info.info_len =3D sizeof(struct bpf_map_info); @@ -231,9 +213,7 @@ virBPFLookupElem(int mapfd, void *key, void *val) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.map_fd =3D mapfd; attr.key =3D (uintptr_t)key; @@ -248,9 +228,7 @@ virBPFGetNextElem(int mapfd, void *key, void *nextKey) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.map_fd =3D mapfd; attr.key =3D (uintptr_t)key; @@ -265,9 +243,7 @@ virBPFUpdateElem(int mapfd, void *key, void *val) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.map_fd =3D mapfd; attr.key =3D (uintptr_t)key; @@ -281,9 +257,7 @@ int virBPFDeleteElem(int mapfd, void *key) { - union bpf_attr attr; - - memset(&attr, 0, sizeof(attr)); + union bpf_attr attr =3D { 0 }; =20 attr.map_fd =3D mapfd; attr.key =3D (uintptr_t)key; diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index 33cf3e202b..70ce0f0c23 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -128,12 +128,10 @@ static int virDMOpen(void) { VIR_AUTOCLOSE controlFD =3D -1; - struct dm_ioctl dm; + struct dm_ioctl dm =3D { 0 }; g_autofree char *tmp =3D NULL; int ret; =20 - memset(&dm, 0, sizeof(dm)); - if ((controlFD =3D open(CONTROL_PATH, O_RDWR)) < 0) { /* We can't talk to devmapper. Produce a warning and let * the caller decide what to do next. */ @@ -223,12 +221,10 @@ virDevMapperGetTargetsImpl(int controlFD, { g_autofree char *sanitizedPath =3D NULL; g_autofree char *buf =3D NULL; - struct dm_ioctl dm; + struct dm_ioctl dm =3D { 0 }; struct dm_target_deps *deps =3D NULL; size_t i; =20 - memset(&dm, 0, sizeof(dm)); - if (ttl =3D=3D 0) { errno =3D ELOOP; return -1; diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 0e39889ac9..26a1f00316 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -1192,7 +1192,7 @@ int virFDStreamConnectUNIX(virStreamPtr st, const char *path, bool abstract) { - struct sockaddr_un sa; + struct sockaddr_un sa =3D { 0 }; virTimeBackOffVar timeout; VIR_AUTOCLOSE fd =3D -1; int ret; @@ -1203,7 +1203,6 @@ int virFDStreamConnectUNIX(virStreamPtr st, return -1; } =20 - memset(&sa, 0, sizeof(sa)); sa.sun_family =3D AF_UNIX; if (abstract) { if (virStrcpy(sa.sun_path+1, path, sizeof(sa.sun_path)-1) < 0) diff --git a/src/util/virfile.c b/src/util/virfile.c index 2984e2ead2..fe456596ae 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -876,14 +876,13 @@ int virFileLoopDeviceAssociate(const char *file, { int lofd =3D -1; int fsfd =3D -1; - struct loop_info64 lo; + struct loop_info64 lo =3D { 0 }; g_autofree char *loname =3D NULL; int ret =3D -1; =20 if ((lofd =3D virFileLoopDeviceOpen(&loname)) < 0) return -1; =20 - memset(&lo, 0, sizeof(lo)); lo.lo_flags =3D LO_FLAGS_AUTOCLEAR; =20 /* Set backing file name for LOOP_GET_STATUS64 queries */ diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c index 430f23a235..d26249a3e9 100644 --- a/src/util/virinitctl.c +++ b/src/util/virinitctl.c @@ -124,14 +124,12 @@ int virInitctlSetRunLevel(const char *fifo, virInitctlRunLevel level) { - struct virInitctlRequest req; + struct virInitctlRequest req =3D { 0 }; int fd =3D -1; int ret =3D -1; const int open_flags =3D O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY; size_t i =3D 0; =20 - memset(&req, 0, sizeof(req)); - req.magic =3D VIR_INITCTL_MAGIC; req.sleeptime =3D 0; req.cmd =3D VIR_INITCTL_CMD_RUNLVL; diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index 4790bd4b55..a70c87cbdb 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -394,7 +394,7 @@ virISCSIScanTargetsInternal(const char *portal, "^\\s*(\\S+)\\s+(\\S+)\\s*$" }; int vars[] =3D { 2 }; - struct virISCSITargetList list; + struct virISCSITargetList list =3D { 0 }; size_t i; g_autoptr(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, "--mode", "discover= y", @@ -414,8 +414,6 @@ virISCSIScanTargetsInternal(const char *portal, NULL); } =20 - memset(&list, 0, sizeof(list)); - if (virCommandRunRegex(cmd, 1, regexes, diff --git a/src/util/virlog.c b/src/util/virlog.c index 6bbd69fe43..2d262d94f0 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -897,12 +897,12 @@ virLogOutputToJournald(virLogSource *source, { int buffd =3D -1; int journalfd =3D (intptr_t) data; - struct msghdr mh; - struct sockaddr_un sa; + struct msghdr mh =3D { 0 }; + struct sockaddr_un sa =3D { 0 }; union { struct cmsghdr cmsghdr; uint8_t buf[CMSG_SPACE(sizeof(int))]; - } control; + } control =3D { 0 }; struct cmsghdr *cmsg; /* We use /dev/shm instead of /tmp here, since we want this to * be a tmpfs, and one that is available from early boot on @@ -950,12 +950,10 @@ virLogOutputToJournald(virLogSource *source, } } =20 - memset(&sa, 0, sizeof(sa)); sa.sun_family =3D AF_UNIX; if (virStrcpyStatic(sa.sun_path, "/run/systemd/journal/socket") < 0) return; =20 - memset(&mh, 0, sizeof(mh)); mh.msg_name =3D &sa; mh.msg_namelen =3D offsetof(struct sockaddr_un, sun_path) + strlen(sa.= sun_path); mh.msg_iov =3D iov; @@ -983,7 +981,6 @@ virLogOutputToJournald(virLogSource *source, mh.msg_iov =3D NULL; mh.msg_iovlen =3D 0; =20 - memset(&control, 0, sizeof(control)); mh.msg_control =3D &control; mh.msg_controllen =3D sizeof(control); =20 diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 38a4f480eb..46d90fbd76 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -812,9 +812,7 @@ virNetDevGetRcvAllMulti(const char *ifname, #if defined(WITH_IF_INDEXTONAME) char *virNetDevGetName(int ifindex) { - char name[IFNAMSIZ]; - - memset(&name, 0, sizeof(name)); + char name[IFNAMSIZ] =3D { 0 }; =20 if (!if_indextoname(ifindex, name)) { virReportSystemError(errno, @@ -847,7 +845,7 @@ char *virNetDevGetName(int ifindex) #if defined(SIOCGIFINDEX) && defined(WITH_STRUCT_IFREQ) int virNetDevGetIndex(const char *ifname, int *ifindex) { - struct ifreq ifreq; + struct ifreq ifreq =3D { 0 }; VIR_AUTOCLOSE fd =3D socket(VIR_NETDEV_FAMILY, SOCK_DGRAM, 0); =20 if (fd < 0) { @@ -856,8 +854,6 @@ int virNetDevGetIndex(const char *ifname, int *ifindex) return -1; } =20 - memset(&ifreq, 0, sizeof(ifreq)); - if (virStrcpyStatic(ifreq.ifr_name, ifname) < 0) { virReportSystemError(ERANGE, _("invalid interface name %1$s"), diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index b870e26e5f..5fd88f3195 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -57,11 +57,9 @@ static int virNetDevBridgeCmd(const char *brname, void *arg, size_t argsize) { - struct ifdrv ifd; + struct ifdrv ifd =3D { 0 }; VIR_AUTOCLOSE s =3D -1; =20 - memset(&ifd, 0, sizeof(ifd)); - if ((s =3D socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) { virReportSystemError(errno, "%s", _("Cannot open network interface control sock= et")); @@ -621,9 +619,8 @@ int virNetDevBridgeAddPort(const char *brname, int virNetDevBridgeAddPort(const char *brname, const char *ifname) { - struct ifbreq req; + struct ifbreq req =3D { 0 }; =20 - memset(&req, 0, sizeof(req)); if (virStrcpyStatic(req.ifbr_ifsname, ifname) < 0) { virReportSystemError(ERANGE, _("Network interface name '%1$s' is too long"= ), @@ -687,9 +684,8 @@ int virNetDevBridgeRemovePort(const char *brname, int virNetDevBridgeRemovePort(const char *brname, const char *ifname) { - struct ifbreq req; + struct ifbreq req =3D { 0 }; =20 - memset(&req, 0, sizeof(req)); if (virStrcpyStatic(req.ifbr_ifsname, ifname) < 0) { virReportSystemError(ERANGE, _("Network interface name '%1$s' is too long"= ), diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index d1e717641c..3b02fe0cec 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -84,7 +84,7 @@ virNetDevCreateNetlinkAddressMessage(int messageType, virSocketAddr *peer) { struct nl_msg *nlmsg =3D NULL; - struct ifaddrmsg ifa; + struct ifaddrmsg ifa =3D { 0 }; unsigned int ifindex; void *addrData =3D NULL; void *peerData =3D NULL; @@ -110,8 +110,6 @@ virNetDevCreateNetlinkAddressMessage(int messageType, nlmsg =3D virNetlinkMsgNew(messageType, NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); =20 - memset(&ifa, 0, sizeof(ifa)); - ifa.ifa_prefixlen =3D prefix; ifa.ifa_family =3D VIR_SOCKET_ADDR_FAMILY(addr); ifa.ifa_index =3D ifindex; @@ -277,7 +275,7 @@ virNetDevIPRouteAdd(const char *ifname, { unsigned int recvbuflen; unsigned int ifindex; - struct rtmsg rtmsg; + struct rtmsg rtmsg =3D { 0 }; void *gatewayData =3D NULL; void *addrData =3D NULL; size_t addrDataLen; @@ -323,8 +321,6 @@ virNetDevIPRouteAdd(const char *ifname, nlmsg =3D virNetlinkMsgNew(RTM_NEWROUTE, NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); =20 - memset(&rtmsg, 0, sizeof(rtmsg)); - rtmsg.rtm_family =3D VIR_SOCKET_ADDR_FAMILY(gateway); rtmsg.rtm_table =3D RT_TABLE_MAIN; rtmsg.rtm_scope =3D RT_SCOPE_UNIVERSE; diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 3e25f18770..3bfd36fc23 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -270,7 +270,7 @@ int virNetDevTapCreate(char **ifname, int virNetDevTapDelete(const char *ifname, const char *tunpath) { - struct ifreq try; + struct ifreq try =3D { 0 }; int fd; int ret =3D -1; =20 @@ -284,7 +284,6 @@ int virNetDevTapDelete(const char *ifname, return -1; } =20 - memset(&try, 0, sizeof(struct ifreq)); try.ifr_flags =3D IFF_TAP|IFF_NO_PI; =20 if (virStrcpyStatic(try.ifr_name, ifname) < 0) { diff --git a/src/util/virperf.c b/src/util/virperf.c index 03341e73e3..91f2ca632a 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -203,7 +203,7 @@ virPerfEventEnable(virPerf *perf, virPerfEventType type, pid_t pid) { - struct perf_event_attr attr; + struct perf_event_attr attr =3D { 0 }; struct virPerfEvent *event =3D &(perf->events[type]); struct virPerfEventAttr *event_attr =3D &attrs[type]; =20 @@ -233,7 +233,6 @@ virPerfEventEnable(virPerf *perf, } } =20 - memset(&attr, 0, sizeof(attr)); attr.size =3D sizeof(attr); attr.inherit =3D 1; attr.disabled =3D 1; diff --git a/src/util/virprocess.c b/src/util/virprocess.c index a26683f333..f8daa786c9 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1539,13 +1539,12 @@ virProcessExitWithStatus(int status) if (WIFEXITED(status)) { value =3D WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { - struct sigaction act; + struct sigaction act =3D { 0 }; sigset_t sigs; =20 if (sigemptyset(&sigs) =3D=3D 0 && sigaddset(&sigs, WTERMSIG(status)) =3D=3D 0) sigprocmask(SIG_UNBLOCK, &sigs, NULL); - memset(&act, 0, sizeof(act)); act.sa_handler =3D SIG_DFL; sigfillset(&act.sa_mask); sigaction(WTERMSIG(status), &act, NULL); diff --git a/src/util/virsocket.c b/src/util/virsocket.c index a6f185114d..cd6f7ecd1b 100644 --- a/src/util/virsocket.c +++ b/src/util/virsocket.c @@ -389,12 +389,11 @@ virSocketSendFD(int sock, int fd) { char byte =3D 0; struct iovec iov; - struct msghdr msg; + struct msghdr msg =3D { 0 }; struct cmsghdr *cmsg; char buf[CMSG_SPACE(sizeof(fd))]; =20 /* send at least one char */ - memset(&msg, 0, sizeof(msg)); iov.iov_base =3D &byte; iov.iov_len =3D 1; msg.msg_iov =3D &iov; @@ -428,7 +427,7 @@ virSocketRecvFD(int sock, int fdflags) { char byte =3D 0; struct iovec iov; - struct msghdr msg; + struct msghdr msg =3D { 0 }; int fd =3D -1; ssize_t len; struct cmsghdr *cmsg; @@ -441,7 +440,6 @@ virSocketRecvFD(int sock, int fdflags) } =20 /* send at least one char */ - memset(&msg, 0, sizeof(msg)); iov.iov_base =3D &byte; iov.iov_len =3D 1; msg.msg_iov =3D &iov; diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 43511bdd69..fbda858cfe 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -92,7 +92,7 @@ virSocketAddrParseInternal(struct addrinfo **res, int ai_flags, bool reportError) { - struct addrinfo hints; + struct addrinfo hints =3D { 0 }; int err; =20 if (val =3D=3D NULL) { @@ -101,7 +101,6 @@ virSocketAddrParseInternal(struct addrinfo **res, return -1; } =20 - memset(&hints, 0, sizeof(hints)); hints.ai_family =3D family; hints.ai_flags =3D ai_flags; if ((err =3D getaddrinfo(val, NULL, &hints, res)) !=3D 0) { @@ -240,12 +239,10 @@ virSocketAddrParseIPv6(virSocketAddr *addr, const cha= r *val) int virSocketAddrResolveService(const char *service) { struct addrinfo *res, *tmp; - struct addrinfo hints; + struct addrinfo hints =3D { 0 }; int err; int port =3D -1; =20 - memset(&hints, 0, sizeof(hints)); - if ((err =3D getaddrinfo(NULL, service, &hints, &res)) !=3D 0) { virReportError(VIR_ERR_SYSTEM_ERROR, _("Cannot parse socket service '%1$s': %2$s"), diff --git a/src/util/viruri.c b/src/util/viruri.c index a824a983df..64995da342 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -201,12 +201,10 @@ virURIParse(const char *uri) char * virURIFormat(virURI *uri) { - xmlURI xmluri; + xmlURI xmluri =3D { 0 }; g_autofree char *tmpserver =3D NULL; char *ret; =20 - memset(&xmluri, 0, sizeof(xmluri)); - xmluri.scheme =3D uri->scheme; xmluri.server =3D uri->server; xmluri.port =3D uri->port; diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 41b19a9c62..2285beea79 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -396,7 +396,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, struct _vboxDriver *data =3D pool->conn->privateData; PRUnichar *hddFormatUtf16 =3D NULL; PRUnichar *hddNameUtf16 =3D NULL; - virStoragePoolDef poolDef; + virStoragePoolDef poolDef =3D { 0 }; nsresult rc; vboxIID hddIID; unsigned char uuid[VIR_UUID_BUFLEN]; @@ -424,7 +424,6 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, * so just assign it for now, change the behaviour * when vbox supports pools. */ - memset(&poolDef, 0, sizeof(poolDef)); poolDef.type =3D VIR_STORAGE_POOL_DIR; =20 if ((def =3D virStorageVolDefParse(&poolDef, xml, NULL, parseFlags)) = =3D=3D NULL) @@ -720,8 +719,8 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr = vol, unsigned int flags) char *hddFormatUtf8 =3D NULL; PRUint64 hddLogicalSize =3D 0; PRUint64 hddActualSize =3D 0; - virStoragePoolDef pool; - virStorageVolDef def; + virStoragePoolDef pool =3D { 0 }; + virStorageVolDef def =3D { 0 }; vboxIID hddIID; PRUint32 hddstate; nsresult rc; @@ -732,9 +731,6 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr = vol, unsigned int flags) =20 virCheckFlags(0, NULL); =20 - memset(&pool, 0, sizeof(pool)); - memset(&def, 0, sizeof(def)); - if (virUUIDParse(vol->key, uuid) < 0) { virReportError(VIR_ERR_INVALID_ARG, _("Could not parse UUID from '%1$s'"), vol->key); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 5e0f1b6b3e..fe4f253e9e 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1044,11 +1044,9 @@ virVMXVerifyDiskAddress(virDomainXMLOption *xmlopt, virDomainDiskDef *disk, virDomainDef *vmdef) { - virDomainDiskDef def; + virDomainDiskDef def =3D { 0 }; virDomainDeviceDriveAddress *drive; =20 - memset(&def, 0, sizeof(def)); - if (disk->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported disk address type '%1$s'"), diff --git a/tests/nsstest.c b/tests/nsstest.c index 615b063118..4b7895db7e 100644 --- a/tests/nsstest.c +++ b/tests/nsstest.c @@ -39,14 +39,12 @@ testGetHostByName(const void *opaque) { const struct testNSSData *data =3D opaque; const bool existent =3D data->hostname && data->ipAddr && data->ipAddr= [0]; - struct hostent resolved; + struct hostent resolved =3D { 0 }; char buf[BUF_SIZE] =3D { 0 }; char **addrList; int rv, tmp_errno =3D 0, tmp_herrno =3D 0; size_t i =3D 0; =20 - memset(&resolved, 0, sizeof(resolved)); - rv =3D NSS_NAME(gethostbyname2)(data->hostname, data->af, &resolved, @@ -116,12 +114,10 @@ testGetHostByName(const void *opaque) addrList =3D resolved.h_addr_list; i =3D 0; while (*addrList) { - virSocketAddr sa; + virSocketAddr sa =3D { 0 }; g_autofree char *ipAddr =3D NULL; void *address =3D *addrList; =20 - memset(&sa, 0, sizeof(sa)); - if (resolved.h_addrtype =3D=3D AF_INET) { virSocketAddrSetIPv4AddrNetOrder(&sa, *((uint32_t *) address)); } else { diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index bd112cef83..b78b1b7947 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -348,12 +348,10 @@ static int testCompareXMLToArgvFiles(const char *xml, g_autofree char *actualargv =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autoptr(GHashTable) vars =3D virHashNew(virNWFilterVarValueHashFree); - virNWFilterInst inst; + virNWFilterInst inst =3D { 0 }; int ret =3D -1; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 - memset(&inst, 0, sizeof(inst)); - virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL); =20 if (testSetDefaultParameters(vars) < 0) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 4672b0a8ff..a1740d3f45 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -895,7 +895,7 @@ testQemuMonitorJSONGetObjectProperty(const void *opaque) { const testGenericData *data =3D opaque; virDomainXMLOption *xmlopt =3D data->xmlopt; - qemuMonitorJSONObjectProperty prop; + qemuMonitorJSONObjectProperty prop =3D { 0 }; g_autoptr(qemuMonitorTest) test =3D NULL; =20 if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) @@ -906,7 +906,6 @@ testQemuMonitorJSONGetObjectProperty(const void *opaque) return -1; =20 /* Present with path and property */ - memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN; if (qemuMonitorJSONGetObjectProperty(qemuMonitorTestGetMonitor(test), "/machine/i440fx", @@ -935,7 +934,7 @@ testQemuMonitorJSONSetObjectProperty(const void *opaque) { const testGenericData *data =3D opaque; virDomainXMLOption *xmlopt =3D data->xmlopt; - qemuMonitorJSONObjectProperty prop; + qemuMonitorJSONObjectProperty prop =3D { 0 }; g_autoptr(qemuMonitorTest) test =3D NULL; =20 if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) @@ -949,7 +948,6 @@ testQemuMonitorJSONSetObjectProperty(const void *opaque) return -1; =20 /* Let's attempt the setting */ - memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_BOOLEAN; prop.val.b =3D true; if (qemuMonitorJSONSetObjectProperty(qemuMonitorTestGetMonitor(test), diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 8b8b02a790..16a4096c98 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -874,9 +874,7 @@ qemuMonitorTestNew(virDomainXMLOption *xmlopt, GHashTable *schema) { g_autoptr(qemuMonitorTest) test =3D NULL; - virDomainChrSourceDef src; - - memset(&src, 0, sizeof(src)); + virDomainChrSourceDef src =3D { 0 }; =20 if (!(test =3D qemuMonitorCommonTestNew(xmlopt, vm, &src))) goto error; @@ -1185,9 +1183,7 @@ qemuMonitorTest * qemuMonitorTestNewAgent(virDomainXMLOption *xmlopt) { g_autoptr(qemuMonitorTest) test =3D NULL; - virDomainChrSourceDef src; - - memset(&src, 0, sizeof(src)); + virDomainChrSourceDef src =3D { 0 }; =20 if (!(test =3D qemuMonitorCommonTestNew(xmlopt, NULL, &src))) goto error; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 534eb9e699..c44b9bc494 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -546,7 +546,7 @@ testCompareXMLToArgv(const void *data) unsigned int parseFlags =3D info->parseFlags; int ret =3D -1; virDomainObj *vm =3D NULL; - virDomainChrSourceDef monitor_chr; + virDomainChrSourceDef monitor_chr =3D { 0 }; g_autoptr(virConnect) conn =3D NULL; virError *err =3D NULL; g_autofree char *log =3D NULL; @@ -558,8 +558,6 @@ testCompareXMLToArgv(const void *data) virArch arch =3D VIR_ARCH_NONE; g_autoptr(virIdentity) sysident =3D virIdentityGetSystem(); =20 - memset(&monitor_chr, 0, sizeof(monitor_chr)); - if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0) goto cleanup; =20 diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index 196f4c29b9..0990013878 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -30,7 +30,7 @@ linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile) { g_autofree char *actualData =3D NULL; - virNodeInfo nodeinfo; + virNodeInfo nodeinfo =3D { 0 }; g_autoptr(FILE) cpuinfo =3D NULL; =20 cpuinfo =3D fopen(cpuinfofile, "r"); @@ -40,7 +40,6 @@ linuxTestCompareFiles(const char *cpuinfofile, return -1; } =20 - memset(&nodeinfo, 0, sizeof(nodeinfo)); if (virHostCPUGetInfoPopulateLinux(cpuinfo, arch, &nodeinfo.cpus, &nodeinfo.mhz, &nodeinfo.nodes, &nodeinfo.sockets, diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c index 14790c0ece..e426bc7791 100644 --- a/tests/virnetmessagetest.c +++ b/tests/virnetmessagetest.c @@ -179,7 +179,7 @@ static int testMessageHeaderDecode(const void *args G_G= NUC_UNUSED) =20 static int testMessagePayloadEncode(const void *args G_GNUC_UNUSED) { - virNetMessageError err; + virNetMessageError err =3D { 0 }; virNetMessage *msg =3D virNetMessageNew(true); int ret =3D -1; static const char expect[] =3D { @@ -218,8 +218,6 @@ static int testMessagePayloadEncode(const void *args G_= GNUC_UNUSED) if (!msg) return -1; =20 - memset(&err, 0, sizeof(err)); - err.code =3D VIR_ERR_INTERNAL_ERROR; err.domain =3D VIR_FROM_RPC; err.level =3D VIR_ERR_ERROR; @@ -287,7 +285,7 @@ static int testMessagePayloadEncode(const void *args G_= GNUC_UNUSED) =20 static int testMessagePayloadDecode(const void *args G_GNUC_UNUSED) { - virNetMessageError err; + virNetMessageError err =3D { 0 }; virNetMessage *msg =3D virNetMessageNew(true); static char input_buffer[] =3D { 0x00, 0x00, 0x00, 0x74, /* Length */ @@ -323,8 +321,6 @@ static int testMessagePayloadDecode(const void *args G_= GNUC_UNUSED) }; int ret =3D -1; =20 - memset(&err, 0, sizeof(err)); - if (!msg) return -1; =20 diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index ec7763224b..ec14ac804b 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -484,13 +484,12 @@ aiforaf(const char *name, int af, struct addrinfo *pa= i, struct addrinfo **aip) struct sockaddr sa; struct sockaddr_in sin; struct sockaddr_in6 sin6; - } sa; + } sa =3D { 0 }; socklen_t salen; void *address =3D *addrList; char host[NI_MAXHOST]; char port[NI_MAXSERV]; =20 - memset(&sa, 0, sizeof(sa)); if (resolved.h_addrtype =3D=3D AF_INET) { sa.sin.sin_family =3D AF_INET; memcpy(&sa.sin.sin_addr.s_addr, diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index c74fc19347..89fdc7a050 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1210,7 +1210,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) { virDomainInfo info; g_autoptr(virshDomain) dom =3D NULL; - virSecurityModel secmodel; + virSecurityModel secmodel =3D { 0 }; int persistent =3D 0; bool ret =3D true; int autostart; @@ -1288,7 +1288,6 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) has_managed_save ? _("yes") : _("no")); =20 /* Security model and label information */ - memset(&secmodel, 0, sizeof(secmodel)); if (virNodeGetSecurityModel(priv->conn, &secmodel) =3D=3D -1) { if (last_error->code !=3D VIR_ERR_NO_SUPPORT) { return false; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index fb54562eb6..7d76055eda 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6182,7 +6182,7 @@ virshDomainJobStatsToDomainJobInfo(virTypedParameterP= tr params, static bool cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) { - virDomainJobInfo info; + virDomainJobInfo info =3D { 0 }; g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; const char *unit; @@ -6209,8 +6209,6 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "keep-completed")) flags |=3D VIR_DOMAIN_JOB_STATS_KEEP_COMPLETED; =20 - memset(&info, 0, sizeof(info)); - rc =3D virDomainGetJobStats(dom, &info.type, ¶ms, &nparams, flags); if (rc =3D=3D 0) { if (virshDomainJobStatsToDomainJobInfo(params, nparams, &info) < 0) diff --git a/tools/vsh-table.c b/tools/vsh-table.c index 005cc564dd..da7dc84ee8 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -204,9 +204,7 @@ vshTableSafeEncode(const char *s, size_t *width) size_t sz =3D s ? strlen(s) : 0; char *buf; char *ret; - mbstate_t st; - - memset(&st, 0, sizeof(st)); + mbstate_t st =3D { 0 }; =20 buf =3D g_new0(char, (sz * HEX_ENCODE_LENGTH) + 1); =20 --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1691059005; cv=none; d=zohomail.com; s=zohoarc; b=KfmKQvq3VHuWS8U1dNDQeXJDwod3PC66R9V1X14VjUFUOpiF1ntWIq9NmmbFjiZHKQznuJv5PJ1Lhso5UEsEICson+TBLIKBFNPZVgRPU3/+U7YA0bf5o0p3/4ZB9EAf9UOllym7pNEU4p7YhC9db5H77Zdsjiu1PPsYahq/n10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059005; 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=0T4X4zGhGA0aFrWz5DgMSHLRbBXfoVcSiqJL2vKytdQ=; b=AAoyht1x+XIhD/GbGW2524Z8It7d9ZNKGsQJU548PJbNK+HgJeZ0AQX/yUOdSoz8O0wmt5y1jIfZkA7+Oh583NygV3Ak6Kl8oVevUT45wcxIola2FFr3mtiyvbDsJxYUFkn2RcvHR4GpYsvHP830AB/yNDzQB91/aydlXWoAJWw= 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 1691059005813697.8341049456044; Thu, 3 Aug 2023 03:36:45 -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-605-7aRBWB6QN2qjqplNDBTCNw-1; Thu, 03 Aug 2023 06:36:42 -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 249E388D2AD; Thu, 3 Aug 2023 10:36:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F6FA200BA76; Thu, 3 Aug 2023 10:36:40 +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 139B91947229; Thu, 3 Aug 2023 10:36:37 +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 5FAB019451E9 for ; Thu, 3 Aug 2023 10:36:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 425E9F77BD; Thu, 3 Aug 2023 10:36:30 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD7CFF7FA6 for ; Thu, 3 Aug 2023 10:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059004; 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=0T4X4zGhGA0aFrWz5DgMSHLRbBXfoVcSiqJL2vKytdQ=; b=LpmFexqkmOOQEvoNvy2yPpSWsWYIuNH+pzu7FOWqf5KGDgYmbspKCR8zma6ITWrxm3WCOs YluJ5ZBUclcHrog/g0y2qgcjM5vRqppibz/GgmGhbN8FVobbgCQPfMJ6QSyZJgVATda9Xn 0LY9jW1IzurWlO70/81Q/pyUWhNG8aw= X-MC-Unique: 7aRBWB6QN2qjqplNDBTCNw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 12/13] lib: Finish using struct zero initializer manually Date: Thu, 3 Aug 2023 12:36:19 +0200 Message-ID: <19e606d61604640feb21c3ec306ddf565e7a0fed.1691058853.git.mprivozn@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.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: 1691059010819100015 Content-Type: text/plain; charset="utf-8"; x-default="true" There are some cases left after previous commit which were not picked up by coccinelle. Mostly, becuase the spatch was not generic enough. We are left with cases like: two variables declared on one line, a variable declared in #ifdef-s (there are notoriously difficult for coccinelle), arrays, macro definitions, etc. Finish what coccinelle started, by hand. Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/libxl/libxl_capabilities.c | 4 +--- src/qemu/qemu_monitor.c | 4 +--- src/rpc/virnettlscontext.c | 3 +-- src/util/virnetlink.c | 4 +--- src/util/virutil.c | 4 ++-- src/vmx/vmx.c | 4 +--- tests/libxlmock.c | 4 +--- tests/qemumonitorjsontest.c | 5 ++--- tests/sockettest.c | 6 ++---- tools/nss/libvirt_nss.c | 7 +++---- tools/virsh-domain.c | 11 ++++------- 11 files changed, 19 insertions(+), 37 deletions(-) diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 5ee6fe3f67..177e8b988e 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -328,11 +328,9 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCaps *caps) char *saveptr =3D NULL; size_t i; =20 - struct guest_arch guest_archs[32]; + struct guest_arch guest_archs[32] =3D { 0 }; int nr_guest_archs =3D 0; =20 - memset(guest_archs, 0, sizeof(guest_archs)); - if ((ver_info =3D libxl_get_version_info(ctx)) =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to get version info from libxenlight")); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index db34b6c179..02da1d6dfc 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -311,11 +311,9 @@ qemuMonitorIOWriteWithFD(qemuMonitor *mon, struct msghdr msg =3D { 0 }; struct iovec iov[1]; int ret; - char control[CMSG_SPACE(sizeof(int))]; + char control[CMSG_SPACE(sizeof(int))] =3D { 0 }; struct cmsghdr *cmsg; =20 - memset(control, 0, sizeof(control)); - iov[0].iov_base =3D (void *)data; iov[0].iov_len =3D len; =20 diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index f72597ee80..1939fe5d6e 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -545,12 +545,11 @@ static int virNetTLSContextSanityCheckCredentials(boo= l isServer, const char *certFile) { gnutls_x509_crt_t cert =3D NULL; - gnutls_x509_crt_t cacerts[MAX_CERTS]; + gnutls_x509_crt_t cacerts[MAX_CERTS] =3D { 0 }; size_t ncacerts =3D 0; size_t i; int ret =3D -1; =20 - memset(cacerts, 0, sizeof(cacerts)); if ((access(certFile, R_OK) =3D=3D 0) && !(cert =3D virNetTLSContextLoadCertFromFile(certFile, isServer))) goto cleanup; diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index d964c439b4..2d052cd03e 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -250,7 +250,7 @@ virNetlinkSendRequest(struct nl_msg *nl_msg, uint32_t s= rc_pid, int fd; int n; virNetlinkHandle *nlhandle =3D NULL; - struct pollfd fds[1]; + struct pollfd fds[1] =3D { 0 }; struct nlmsghdr *nlmsg =3D nlmsg_hdr(nl_msg); =20 if (protocol >=3D MAX_LINKS) { @@ -286,8 +286,6 @@ virNetlinkSendRequest(struct nl_msg *nl_msg, uint32_t s= rc_pid, goto error; } =20 - memset(fds, 0, sizeof(fds)); - fds[0].fd =3D fd; fds[0].events =3D POLLIN; =20 diff --git a/src/util/virutil.c b/src/util/virutil.c index 40ca205595..b5b65fb415 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -428,7 +428,8 @@ virGetHostnameImpl(bool quiet) { int r; char hostname[HOST_NAME_MAX+1], *result =3D NULL; - struct addrinfo hints, *info; + struct addrinfo hints =3D { 0 }; + struct addrinfo *info; =20 r =3D gethostname(hostname, sizeof(hostname)); if (r =3D=3D -1) { @@ -453,7 +454,6 @@ virGetHostnameImpl(bool quiet) * canonicalize the hostname by running it through getaddrinfo */ =20 - memset(&hints, 0, sizeof(hints)); hints.ai_flags =3D AI_CANONNAME|AI_CANONIDN; hints.ai_family =3D AF_UNSPEC; r =3D getaddrinfo(hostname, NULL, &hints, &info); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index fe4f253e9e..5c6925be22 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3229,7 +3229,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOp= tion *xmlopt, virDomainDef char *vmx =3D NULL; size_t i; int sched_cpu_affinity_length; - unsigned char zero[VIR_UUID_BUFLEN]; + unsigned char zero[VIR_UUID_BUFLEN] =3D { 0 }; g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; char *preliminaryDisplayName =3D NULL; char *displayName =3D NULL; @@ -3247,8 +3247,6 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOp= tion *xmlopt, virDomainDef return NULL; } =20 - memset(zero, 0, VIR_UUID_BUFLEN); - if (def->virtType !=3D VIR_DOMAIN_VIRT_VMWARE) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting virt type to be '%1$s' but found '%2$s= '"), diff --git a/tests/libxlmock.c b/tests/libxlmock.c index 205d34df19..f564a0ef72 100644 --- a/tests/libxlmock.c +++ b/tests/libxlmock.c @@ -60,9 +60,7 @@ VIR_MOCK_IMPL_RET_ARGS(libxl_get_version_info, const libxl_version_info*, libxl_ctx *, ctx) { - static libxl_version_info info; - - memset(&info, 0, sizeof(info)); + static libxl_version_info info =3D { 0 }; =20 /* silence gcc warning about unused function */ if (0) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index a1740d3f45..2e7b661db4 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1591,15 +1591,14 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationStats= (const void *opaque) { const testGenericData *data =3D opaque; virDomainXMLOption *xmlopt =3D data->xmlopt; - qemuMonitorMigrationStats stats, expectedStats; + qemuMonitorMigrationStats stats; + qemuMonitorMigrationStats expectedStats =3D { 0 }; g_autofree char *error =3D NULL; g_autoptr(qemuMonitorTest) test =3D NULL; =20 if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; =20 - memset(&expectedStats, 0, sizeof(expectedStats)); - expectedStats.status =3D QEMU_MONITOR_MIGRATION_STATUS_ACTIVE; expectedStats.total_time =3D 47; expectedStats.ram_total =3D 1611038720; diff --git a/tests/sockettest.c b/tests/sockettest.c index 6b9063e11d..5cb8a9fb72 100644 --- a/tests/sockettest.c +++ b/tests/sockettest.c @@ -269,10 +269,9 @@ mymain(void) =20 #define DO_TEST_PARSE_AND_FORMAT(addrstr, family, pass) \ do { \ - virSocketAddr addr; \ + virSocketAddr addr =3D { 0 }; \ struct testParseData data =3D { &addr, addrstr, family, pass }; \ struct testFormatData data2 =3D { &addr, addrstr, pass }; \ - memset(&addr, 0, sizeof(addr)); \ if (virTestRun("Test parse " addrstr " family " #family, \ testParseHelper, &data) < 0) \ ret =3D -1; \ @@ -283,10 +282,9 @@ mymain(void) =20 #define DO_TEST_PARSE_AND_CHECK_FORMAT(addrstr, addrformated, family, pass= ) \ do { \ - virSocketAddr addr; \ + virSocketAddr addr =3D { 0 }; \ struct testParseData data =3D { &addr, addrstr, family, true}; \ struct testFormatData data2 =3D { &addr, addrformated, pass }; \ - memset(&addr, 0, sizeof(addr)); \ if (virTestRun("Test parse " addrstr " family " #family, \ testParseHelper, &data) < 0) \ ret =3D -1; \ diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index ec14ac804b..5c4796e8bc 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -538,15 +538,14 @@ _nss_compat_getaddrinfo(void *retval, void *mdata __attribute__((unused)), va_list ap) { - struct addrinfo sentinel, *cur, *ai; + struct addrinfo sentinel =3D { 0 }; + struct addrinfo *cur =3D & sentinel; + struct addrinfo *ai; const char *name; =20 name =3D va_arg(ap, char *); ai =3D va_arg(ap, struct addrinfo *); =20 - memset(&sentinel, 0, sizeof(sentinel)); - cur =3D &sentinel; - if ((ai->ai_family =3D=3D AF_UNSPEC) || (ai->ai_family =3D=3D AF_INET6= )) aiforaf(name, AF_INET6, ai, &cur); if ((ai->ai_family =3D=3D AF_UNSPEC) || (ai->ai_family =3D=3D AF_INET)) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7d76055eda..f8758f18a3 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -942,7 +942,8 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) *inboundStr =3D NULL, *outboundStr =3D NULL, *alias =3D NUL= L; const char *sourceModeStr =3D NULL; int sourceMode =3D -1; - virNetDevBandwidthRate inbound, outbound; + virNetDevBandwidthRate inbound =3D { 0 }; + virNetDevBandwidthRate outbound =3D { 0 }; virDomainNetType typ; int ret; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; @@ -990,7 +991,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) } =20 if (inboundStr) { - memset(&inbound, 0, sizeof(inbound)); if (virshParseRateStr(ctl, inboundStr, &inbound) < 0) return false; if (!inbound.average && !inbound.floor) { @@ -999,7 +999,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) } } if (outboundStr) { - memset(&outbound, 0, sizeof(outbound)); if (virshParseRateStr(ctl, outboundStr, &outbound) < 0) return false; if (outbound.average =3D=3D 0) { @@ -3286,7 +3285,8 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd) bool current =3D vshCommandOptBool(cmd, "current"); bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); - virNetDevBandwidthRate inbound, outbound; + virNetDevBandwidthRate inbound =3D { 0 }; + virNetDevBandwidthRate outbound =3D { 0 }; size_t i; =20 VSH_EXCLUSIVE_OPTIONS_VAR(current, live); @@ -3307,9 +3307,6 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0) goto cleanup; =20 - memset(&inbound, 0, sizeof(inbound)); - memset(&outbound, 0, sizeof(outbound)); - if (inboundStr) { if (virshParseRateStr(ctl, inboundStr, &inbound) < 0) goto cleanup; --=20 2.41.0 From nobody Sun May 19 15:29:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1691059016; cv=none; d=zohomail.com; s=zohoarc; b=g4ilTvAegy4rMplTR+y0s400nwqsqkhfKxRgeGDsqp1dIAn4lr+vwh+9VtHHM2GkjiK+CxGgqnMMIv/TYkSjWpHd44F39on8mqLNj/qzcieObs3wG76noU9eKILMYyador7ND+LM6KfJGLjOJA8sz8oiOE1VtvAQVfXgr9GO4AU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1691059016; 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=J9hoECHcqKFuaAYAk2eWU6l8bhfmMKfHyK2h/793oGs=; b=G8wI8sCquFNT7B+BDMilW7hIHeTYQ9/I7y6f59f5szxnIG6yidzNnY84m7pyG+6bwnRPhjCQsiEnMLsY8xBoUKX1i1MvWuAwH6JGoHMVR2Wfi16u3mgOQe2irsYOe+/D2ncCa4KMyxgp2WS2Gz0cVpawW4ZdVuDF5OAY5PMTNW8= 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 169105901657352.791188797692485; Thu, 3 Aug 2023 03:36:56 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-691-1yk1J2oNODeYwOt8eucyXQ-1; Thu, 03 Aug 2023 06:36:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E9282815E21; Thu, 3 Aug 2023 10:36:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77D51112132E; Thu, 3 Aug 2023 10:36: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 5DBE71947217; Thu, 3 Aug 2023 10:36:37 +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 EE6EB1947F00 for ; Thu, 3 Aug 2023 10:36:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D2150F7FA6; Thu, 3 Aug 2023 10:36:30 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 792E0F77BD for ; Thu, 3 Aug 2023 10:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691059015; 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=J9hoECHcqKFuaAYAk2eWU6l8bhfmMKfHyK2h/793oGs=; b=ehgCbdiuUgJ2OAo0s6HPJm+dJJ8x+zB5V53esmCkFenBYq7bqPKDuwlzKz9HKzHDltgLGT jBm+YW0v++WLImyFgO4hqudLtYUlpf2x6Qcxz20GvIcHEMA4g+pgnIhN/WIJSnlGe5JpKI tzMWEsmXeRIX34MSOut4ABY9/YS7wiw= X-MC-Unique: 1yk1J2oNODeYwOt8eucyXQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 13/13] lib: Prefer sizeof(variable) instead of sizeof(type) in memset Date: Thu, 3 Aug 2023 12:36:20 +0200 Message-ID: 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.3 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: 1691059018051100001 Content-Type: text/plain; charset="utf-8"; x-default="true" If one of previous commits taught us something, it's that: sizeof(variable) and sizeof(type) are not the same. Especially because for live enough code the type might change (e.g. as we use autoptr more). And since we don't get any warnings when an incorrect length is passed to memset() it is easy to mess up. But with sizeof(variable) instead, it's not as easy. Therefore, switch to using memset(variable, 0, sizeof(*variable)), or its alternatives, depending on level of pointers. Signed-off-by: Michal Privoznik Reviewed-by: Claudio Fontana --- src/qemu/qemu_monitor_json.c | 4 ++-- src/qemu/qemu_process.c | 2 +- src/remote/remote_driver.c | 2 +- src/storage/storage_driver.c | 2 +- src/test/test_driver.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 70536028ab..34c4b543e8 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7112,7 +7112,7 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon, =20 #define VIR_IOTHREAD_SET_PROP_UL(propName, propVal) \ if (iothreadInfo->set_##propVal) { \ - memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \ + memset(&prop, 0, sizeof(prop)); \ prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_ULONG; \ prop.val.ul =3D iothreadInfo->propVal; \ if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) <= 0) \ @@ -7145,7 +7145,7 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon, =20 #define VIR_IOTHREAD_SET_PROP_INT(propName, propVal) \ if (iothreadInfo->set_##propVal) { \ - memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \ + memset(&prop, 0, sizeof(prop)); \ prop.type =3D QEMU_MONITOR_OBJECT_PROPERTY_INT; \ prop.val.iv =3D iothreadInfo->propVal; \ if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) <= 0) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 572b842349..0644f80161 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5068,7 +5068,7 @@ qemuProcessGraphicsSetupListen(virQEMUDriver *driver, * *_auto_unix_socket set we should use unix socket as * default instead of tcp listen. */ if (useSocket) { - memset(glisten, 0, sizeof(virDomainGraphicsListenDef)); + memset(glisten, 0, sizeof(*glisten)); glisten->socket =3D g_strdup_printf("%s/%s.sock", priv= ->libDir, type); glisten->fromConfig =3D true; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 8e78af0ea0..faad7292ed 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2138,7 +2138,7 @@ remoteDomainGetVcpus(virDomainPtr domain, goto cleanup; } =20 - memset(info, 0, sizeof(virVcpuInfo) * maxinfo); + memset(info, 0, sizeof(*info) * maxinfo); memset(cpumaps, 0, maxinfo * maplen); =20 for (i =3D 0; i < ret.info.info_len; ++i) { diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index c19abdd2f3..5a9dcbd193 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1279,7 +1279,7 @@ storagePoolGetInfo(virStoragePoolPtr pool, if (virStorageBackendForType(def->type) =3D=3D NULL) goto cleanup; =20 - memset(info, 0, sizeof(virStoragePoolInfo)); + memset(info, 0, sizeof(*info)); if (virStoragePoolObjIsActive(obj)) info->state =3D VIR_STORAGE_POOL_RUNNING; else diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 3767908d9d..4b8e02c684 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4826,7 +4826,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom, =20 if (errors) { /* sanitize input */ - memset(errors, 0, sizeof(virDomainDiskError) * nerrors); + memset(errors, 0, sizeof(*errors) * nerrors); =20 for (i =3D 0; i < nerrors; i++) { errors[i].disk =3D g_strdup(vm->def->disks[i]->dst); @@ -6878,7 +6878,7 @@ testStoragePoolGetInfo(virStoragePoolPtr pool, return -1; def =3D virStoragePoolObjGetDef(obj); =20 - memset(info, 0, sizeof(virStoragePoolInfo)); + memset(info, 0, sizeof(*info)); if (virStoragePoolObjIsActive(obj)) info->state =3D VIR_STORAGE_POOL_RUNNING; else --=20 2.41.0