From nobody Fri May 3 17:22:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588673448; cv=none; d=zohomail.com; s=zohoarc; b=PG68buTvUO2hCQxrG+Hvw4ILcbVvNgNpda5spJwfNavP9B77bFSQUzdTlHAGjkKflzdbYvWyzRFtN20iUy9VKVXAoCQLS4D5eC7Dipt5JBJfCAmGAFnuEhm8UxJtHPu+mkweizlczc1iAmB9JKYHhAiaBOtiVKtnwJzsD4KzamE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588673448; 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=9EpKVddsHXli1Cfx/tN8dxXReoj3V4k/lKM6u77n0vw=; b=WRnwwVH2mIoWPLhK3spzoCyig/klGq2ECG1HTA8NiPR7ZrnuGlnvM65joduak+NE+LnibJxcM3NgI4BG0KMrce3V7AdRVsQIqoczXRNfPg6TP9DIGBKykUvohddRu9U0b6WXxT1LpofogdItfS2E1wBUCBXO5wr97c1/ziYRhuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1588673448653478.50431848644484; Tue, 5 May 2020 03:10:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-138-KUs-7lCPNG6AT5irX0plnQ-1; Tue, 05 May 2020 06:10:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEE31800D24; Tue, 5 May 2020 10:10:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86530619C4; Tue, 5 May 2020 10:10:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EB7551809542; Tue, 5 May 2020 10:10:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 045AAHNc001461 for ; Tue, 5 May 2020 06:10:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9A87B101E7F9; Tue, 5 May 2020 10:10:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 171201010404 for ; Tue, 5 May 2020 10:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588673447; 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=9EpKVddsHXli1Cfx/tN8dxXReoj3V4k/lKM6u77n0vw=; b=QGk0SwExeiMO72ymmkCVav682HLiQmZgjqxJvBXOd4hoUG8JHr2m+Lirgg0JcubEv5STQg YsYFCYbJaI54GErld3q3s6qNZcSxqtWYI6Z5W3XgYE4BaqT9XUw35Z6RjdgPmnVb+XqJrQ AkJmE3GLC7yFE+bO37jEAdMM9Bv1lF4= X-MC-Unique: KUs-7lCPNG6AT5irX0plnQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] virnetserver: Check for virNetServerClientInitKeepAlive() retval Date: Tue, 5 May 2020 12:10:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since it's introduction in v0.9.7-147-gf4324e3292 the virNetServerClientInitKeepAlive() function returned nothing than a negative one. Fortunately, this did not pose any problem because we ignored the retval happily. Well, it's time to check for the retval because the function might fail regularly. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetserver.c | 5 +++-- src/rpc/virnetserverclient.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 242052754f..07c8b85b76 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -306,8 +306,9 @@ int virNetServerAddClient(virNetServerPtr srv, virNetServerDispatchNewMessage, srv); =20 - virNetServerClientInitKeepAlive(client, srv->keepaliveInterval, - srv->keepaliveCount); + if (virNetServerClientInitKeepAlive(client, srv->keepaliveInterval, + srv->keepaliveCount) < 0) + goto error; =20 virObjectUnlock(srv); return 0; diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 657108239f..756adcbb4f 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -1599,7 +1599,7 @@ virNetServerClientInitKeepAlive(virNetServerClientPtr= client, virObjectRef(client); =20 client->keepalive =3D ka; - + ret =3D 0; cleanup: virObjectUnlock(client); =20 --=20 2.26.2 From nobody Fri May 3 17:22:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588673471; cv=none; d=zohomail.com; s=zohoarc; b=IdNLnpPRMgGHhvF8BZULWBt+XiEu3d+0ylyM0rEzGWFVNeAocuDOfXFrA2BoQ+nw//RCzVQlqh8ujFJnKPyS1EdilMb9i2aQKsPm09xTn1p4g3IHtgNU81DbNXtbtgdJDCV+dC2u+WU74wiPwca4+ziA/2Rf/wbm3fjXAYFAjWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588673471; 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=3uhY4JpjkdD4b/x1Tj8FQqVxHqV2quemU+IuLtPPK1U=; b=TPO8Cn1MhLKQHCcj01RkF0wgw9apvjYvku6jvrXvxgAxXpTDx/nvGF61iEkF3HJtSMG6NVAqSEJrsJLlAnzcjdYC7R331HWKRVz2KegCGOvpENd43L3MmdHi29ZTZj5On5rzesgCzcczI7c5jB28D3K3baYQ+cOYAEvb+FpO5t0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 158867347136037.127093619933476; Tue, 5 May 2020 03:11:11 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-WJZXRihROM2RBy83RF3S7A-1; Tue, 05 May 2020 06:11:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 343EE100CCF0; Tue, 5 May 2020 10:11:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1A4B5D9D3; Tue, 5 May 2020 10:10:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A43C11809557; Tue, 5 May 2020 10:10:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 045AAJSK001473 for ; Tue, 5 May 2020 06:10:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C5CE101E58A; Tue, 5 May 2020 10:10:19 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD974101E7F9 for ; Tue, 5 May 2020 10:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588673470; 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=3uhY4JpjkdD4b/x1Tj8FQqVxHqV2quemU+IuLtPPK1U=; b=PBnBN8rFPWhPcLodLuU3J6uZm8WKrP/N6IMHcyhCKJbLDk87O4S/NvIilc8eq3TVOQvhEG IDg50IiJ5gPXQTo7AUl7vAoHjIEsUlKA5oewxqqUEZsdgBM+FYNVuHncXpT3RF3JAqGMhH zsRzVtPHKeBZxIoV9KIzbRl7fvK5aRU= X-MC-Unique: WJZXRihROM2RBy83RF3S7A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] rpc: Make some functions void Date: Tue, 5 May 2020 12:10:06 +0200 Message-Id: <2b839af8b1e9f5a551db9dddc148e2829c83fa8c.1588672891.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are few functions that currently return an integer but in fact they always return the same integer (zero). Make them void. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetlibsshsession.c | 4 +--- src/rpc/virnetlibsshsession.h | 4 ++-- src/rpc/virnetsocket.c | 6 ++---- src/rpc/virnetsshsession.c | 4 +--- src/rpc/virnetsshsession.h | 4 ++-- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 9c20a80b88..0a566eaa54 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -1082,11 +1082,10 @@ virNetLibsshSessionAuthAddKeyboardAuth(virNetLibssh= SessionPtr sess, =20 } =20 -int +void virNetLibsshSessionSetChannelCommand(virNetLibsshSessionPtr sess, const char *command) { - int ret =3D 0; virObjectLock(sess); =20 VIR_FREE(sess->channelCommand); @@ -1094,7 +1093,6 @@ virNetLibsshSessionSetChannelCommand(virNetLibsshSess= ionPtr sess, sess->channelCommand =3D g_strdup(command); =20 virObjectUnlock(sess); - return ret; } =20 int diff --git a/src/rpc/virnetlibsshsession.h b/src/rpc/virnetlibsshsession.h index 231c2591b2..e982bcd2ef 100644 --- a/src/rpc/virnetlibsshsession.h +++ b/src/rpc/virnetlibsshsession.h @@ -35,8 +35,8 @@ typedef enum { VIR_NET_LIBSSH_HOSTKEY_VERIFY_IGNORE } virNetLibsshHostkeyVerify; =20 -int virNetLibsshSessionSetChannelCommand(virNetLibsshSessionPtr sess, - const char *command); +void virNetLibsshSessionSetChannelCommand(virNetLibsshSessionPtr sess, + const char *command); =20 int virNetLibsshSessionAuthSetCallback(virNetLibsshSessionPtr sess, virConnectAuthPtr auth); diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 6c790cb577..3ea863f625 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -969,8 +969,7 @@ virNetSocketNewConnectLibSSH2(const char *host, VIR_NET_SSH_HOSTKEY_FILE_CR= EATE) !=3D 0) goto error; =20 - if (virNetSSHSessionSetChannelCommand(sess, command) !=3D 0) - goto error; + virNetSSHSessionSetChannelCommand(sess, command); =20 if (!(authMethodList =3D virStringSplit(authMethods, ",", 0))) goto error; @@ -1101,8 +1100,7 @@ virNetSocketNewConnectLibssh(const char *host, verify) !=3D 0) goto error; =20 - if (virNetLibsshSessionSetChannelCommand(sess, command) !=3D 0) - goto error; + virNetLibsshSessionSetChannelCommand(sess, command); =20 if (!(authMethodList =3D virStringSplit(authMethods, ",", 0))) goto error; diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index fabdc3ef22..b4dea15452 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -1132,11 +1132,10 @@ virNetSSHSessionAuthAddKeyboardAuth(virNetSSHSessio= nPtr sess, =20 } =20 -int +void virNetSSHSessionSetChannelCommand(virNetSSHSessionPtr sess, const char *command) { - int ret =3D 0; virObjectLock(sess); =20 VIR_FREE(sess->channelCommand); @@ -1144,7 +1143,6 @@ virNetSSHSessionSetChannelCommand(virNetSSHSessionPtr= sess, sess->channelCommand =3D g_strdup(command); =20 virObjectUnlock(sess); - return ret; } =20 int diff --git a/src/rpc/virnetsshsession.h b/src/rpc/virnetsshsession.h index 0101489302..4d639da453 100644 --- a/src/rpc/virnetsshsession.h +++ b/src/rpc/virnetsshsession.h @@ -40,8 +40,8 @@ typedef enum { VIR_NET_SSH_HOSTKEY_FILE_CREATE =3D 1 << 1, } virNetSSHHostKeyFileFlags; =20 -int virNetSSHSessionSetChannelCommand(virNetSSHSessionPtr sess, - const char *command); +void virNetSSHSessionSetChannelCommand(virNetSSHSessionPtr sess, + const char *command); =20 void virNetSSHSessionAuthReset(virNetSSHSessionPtr sess); =20 --=20 2.26.2 From nobody Fri May 3 17:22:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588673477; cv=none; d=zohomail.com; s=zohoarc; b=fvdKUTHaUyvTiX9HFm6NGPC+Y9c9EHh0R9+WKaRa4Q1aLC/F9wSVnDL1drKgPGe3qpu5FPyFfokCag+7lVi1pJJuHeX875eo6m18bksnsV6za8iejoUtY9puCv7veWYIBu6vQ3nHFb32bs12wnns+KmTRgkk8hx4UBaKChrw7jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588673477; 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=2iZoI9reXhU18qqvkCOwelRQ6uCD4+g7iCZ6l89xsa4=; b=SC3sLoGrMqJyz6Ib24Pjke3DbmWzevrPG4c4ZBikyYYAHTRAzaHokS9Uh+065xnTs8GbSnUgcJ8uTpbhaqXhUciQZOEQtm35a1ydd6TdXKT9UatO4k3uYXjYFmcvvxnb3KvopHxU0jYuSgOTq2dvm+9YDZcSchxlKAj0phXK3lc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1588673477141639.0735442254697; Tue, 5 May 2020 03:11:17 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-239-0pVjTBhyMgaILclbeFeDfQ-1; Tue, 05 May 2020 06:11:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 56D43100A8FB; Tue, 5 May 2020 10:11:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AEA05D9D5; Tue, 5 May 2020 10:11:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CD4711809563; Tue, 5 May 2020 10:11:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 045AAL0x001485 for ; Tue, 5 May 2020 06:10:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3EA7A1057FCB; Tue, 5 May 2020 10:10:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADE7C10246E7 for ; Tue, 5 May 2020 10:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588673475; 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=2iZoI9reXhU18qqvkCOwelRQ6uCD4+g7iCZ6l89xsa4=; b=PTUckLgdHVzxhnDTWg5AJBQFhIMu5bovsvtUxzRJxkO/ET6bw1zSGE1czi2l+xHUvPyLXF CXcYacBshVK9477hhj9DgIu0/Xie1OItbzmvjuEj40VEmeRMYxex7BePGrucf5c08kDNoF hHXef+rdSMfpZHVMIHYv/2SanzCLL2E= X-MC-Unique: 0pVjTBhyMgaILclbeFeDfQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] lib: Drop needless ret variables Date: Tue, 5 May 2020 12:10:07 +0200 Message-Id: <0b8513901a1ff97a2b9b6cd9d1c217e4c1cdcdb2.1588672891.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are few places where a return variable is introduced (ret or retval), but then is never changed and is then passed to return. Well, we can return the value that the variable is initialized to directly. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/locking/lock_daemon.c | 3 +-- src/logging/log_daemon.c | 3 +-- src/storage/storage_backend_mpath.c | 3 +-- tools/virt-host-validate-bhyve.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 4eff63014a..b0cd89375b 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -720,7 +720,6 @@ virLockDaemonPreExecRestart(const char *state_file, { virJSONValuePtr child; char *state =3D NULL; - int ret =3D -1; virJSONValuePtr object =3D virJSONValueNewObject(); char *magic; virHashKeyValuePairPtr pairs =3D NULL, tmp; @@ -800,7 +799,7 @@ virLockDaemonPreExecRestart(const char *state_file, VIR_FREE(pairs); VIR_FREE(state); virJSONValueFree(object); - return ret; + return -1; } =20 =20 diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index f37054706e..7017db2dcc 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -524,7 +524,6 @@ virLogDaemonPreExecRestart(const char *state_file, { virJSONValuePtr child; char *state =3D NULL; - int ret =3D -1; virJSONValuePtr object =3D virJSONValueNewObject(); char *magic; virHashKeyValuePairPtr pairs =3D NULL; @@ -581,7 +580,7 @@ virLogDaemonPreExecRestart(const char *state_file, VIR_FREE(pairs); VIR_FREE(state); virJSONValueFree(object); - return ret; + return -1; } =20 =20 diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index 7cb084b2d6..fffc0f86b7 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -243,7 +243,6 @@ virStorageBackendMpathCheckPool(virStoragePoolObjPtr po= ol G_GNUC_UNUSED, static int virStorageBackendMpathRefreshPool(virStoragePoolObjPtr pool) { - int retval =3D 0; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 VIR_DEBUG("pool=3D%p", pool); @@ -254,7 +253,7 @@ virStorageBackendMpathRefreshPool(virStoragePoolObjPtr = pool) =20 virStorageBackendGetMaps(pool); =20 - return retval; + return 0; } =20 =20 diff --git a/tools/virt-host-validate-bhyve.c b/tools/virt-host-validate-bh= yve.c index 2f0ec1e36c..3e8cc59a38 100644 --- a/tools/virt-host-validate-bhyve.c +++ b/tools/virt-host-validate-bhyve.c @@ -47,7 +47,6 @@ =20 int virHostValidateBhyve(void) { - int ret =3D 0; int fileid =3D 0; struct kld_file_stat stat; bool vmm_loaded =3D false, if_tap_loaded =3D false; @@ -73,5 +72,5 @@ int virHostValidateBhyve(void) MODULE_STATUS_WARN(if_bridge, "bridged networking will not work"); MODULE_STATUS_WARN(nmdm, "nmdm console will not work"); =20 - return ret; + return 0; } --=20 2.26.2 From nobody Fri May 3 17:22:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588673460; cv=none; d=zohomail.com; s=zohoarc; b=jplILU+WwSvKJtXfUQmRTKlu6IPk1Hnv/yDnHrf5EbdgzapDv1ro2BsItScarvLhMe68drZmiHWAwnV802R6fNC//WHpgQehxsmuKWPmsjrvj71QBkMZsPUKHG9PEPgqfMHQOlFdab28GdghMOozgW4TNQIN2Po3MwOAUxvBZPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588673460; 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=mPbgk0X+xSrCHWqOtt2l2USPV+sK9hUw96gyu9YBPTo=; b=EGXsipy3VVQIvinYmTLcwgpTT1rBX/vxGirChZqM73hFd/UECW2kjJ/OcaZ1yfUaX+QcOc5L4zNOszHxzHekUbDZSPWPtZcDOGf9qW3AdlTMZSrHbzaaYWZdVnRqho3pX1CfHm9s/8zvQC7AeBdzBf1pbr5xpmKt80ctTqQt2iU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1588673460239627.0434683514593; Tue, 5 May 2020 03:11:00 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-312-4OWmlxsLP5WOymoJjhJYAg-1; Tue, 05 May 2020 06:10:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 165A7100CCD2; Tue, 5 May 2020 10:10:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2E6B5D98F; Tue, 5 May 2020 10:10:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A632A4CAA7; Tue, 5 May 2020 10:10:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 045AAQij001509 for ; Tue, 5 May 2020 06:10:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E723101E58A; Tue, 5 May 2020 10:10:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEACF10016DA for ; Tue, 5 May 2020 10:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588673458; 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=mPbgk0X+xSrCHWqOtt2l2USPV+sK9hUw96gyu9YBPTo=; b=Qxow6x+bNTLy3yzp387Z0cPQVz/qkH9T7Hscl2qubBpMLRQB3Flt5LaEhzjUTfw8KTGKRz b/ceD80EV+4AEpPk6TV6gtVqc2NBbSLE0J8O1ZAVrf0PS8CHnsDMWjy7V2KGdQ/xNRab26 012RNv4hPWe7XRSSRJd3yKtKD0JRJmI= X-MC-Unique: 4OWmlxsLP5WOymoJjhJYAg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] src: Fix boolean assignment Date: Tue, 5 May 2020 12:10:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In a few places we use 0 and false, or 1 and true interchangeably even though the variable or return type in question is boolean. Fix those places. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/conf/nwfilter_conf.c | 6 +++--- src/conf/virstorageobj.c | 2 +- src/lxc/lxc_driver.c | 2 +- src/nwfilter/nwfilter_dhcpsnoop.c | 2 +- src/qemu/qemu_agent.c | 10 +++++----- src/qemu/qemu_monitor.c | 4 ++-- src/remote/remote_daemon.c | 2 +- src/remote/remote_daemon_config.c | 8 ++++---- src/remote/remote_driver.c | 2 +- src/rpc/virnetserver.c | 2 +- src/util/virnetlink.c | 2 +- src/util/virtime.c | 4 ++-- src/util/viruri.c | 2 +- src/vmx/vmx.c | 4 ++-- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 680f4184c3..732c05ac89 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -1848,7 +1848,7 @@ virNWFilterRuleDetailsParse(xmlNodePtr node, =20 att_datatypes =3D att[idx].datatype; =20 - while (datatype <=3D DATATYPE_LAST && found =3D=3D 0 && rc =3D= =3D 0) { + while (datatype <=3D DATATYPE_LAST && !found && rc =3D=3D 0) { if ((att_datatypes & datatype)) { =20 att_datatypes ^=3D datatype; @@ -2881,14 +2881,14 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf, matchShown =3D MATCH_NO; } else if (matchShown =3D=3D MATCH_YES) { virBufferAddLit(buf, "/>\n"); - typeShown =3D 0; + typeShown =3D false; matchShown =3D MATCH_NONE; continue; } } else { if (matchShown =3D=3D MATCH_NO) { virBufferAddLit(buf, "/>\n"); - typeShown =3D 0; + typeShown =3D false; matchShown =3D MATCH_NONE; continue; } diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 5cbd30f93c..13b75b648d 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -332,7 +332,7 @@ bool virStoragePoolObjIsAutostart(virStoragePoolObjPtr obj) { if (!obj->configFile) - return 0; + return false; =20 return obj->autostart; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 61dd35360a..3111562568 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1512,7 +1512,7 @@ static int lxcStateInitialize(bool privileged, if (!(lxc_driver->config =3D cfg =3D virLXCDriverConfigNew())) goto cleanup; =20 - cfg->log_libvirtd =3D 0; /* by default log to container logfile */ + cfg->log_libvirtd =3D false; /* by default log to container logfile */ cfg->have_netns =3D lxcCheckNetNsSupport(); =20 /* Call function to load lxc driver configuration information */ diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 953d8936a4..f530341872 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -326,7 +326,7 @@ virNWFilterSnoopIsActive(char *threadKey) void *entry; =20 if (threadKey =3D=3D NULL) - return 0; + return false; =20 virNWFilterSnoopActiveLock(); =20 diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index d7fcc869c6..6fa48c06e3 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -267,7 +267,7 @@ qemuAgentIOProcessLine(qemuAgentPtr agent, /* receiving garbage on first sync is regular situation */ if (msg && msg->sync && msg->first) { VIR_DEBUG("Received garbage on sync"); - msg->finished =3D 1; + msg->finished =3D true; return 0; } =20 @@ -306,7 +306,7 @@ qemuAgentIOProcessLine(qemuAgentPtr agent, } } msg->rxObject =3D obj; - msg->finished =3D 1; + msg->finished =3D true; obj =3D NULL; } else { /* we are out of sync */ @@ -627,7 +627,7 @@ qemuAgentIO(GSocket *socket G_GNUC_UNUSED, /* If IO process resulted in an error & we have a message, * then wakeup that waiter */ if (agent->msg && !agent->msg->finished) { - agent->msg->finished =3D 1; + agent->msg->finished =3D true; virCondSignal(&agent->notify); } } @@ -751,7 +751,7 @@ qemuAgentNotifyCloseLocked(qemuAgentPtr agent) /* If there is somebody waiting for a message * wake him up. No message will arrive anyway. */ if (agent->msg && !agent->msg->finished) { - agent->msg->finished =3D 1; + agent->msg->finished =3D true; virCondSignal(&agent->notify); } } @@ -1209,7 +1209,7 @@ void qemuAgentNotifyEvent(qemuAgentPtr agent, agent->await_event =3D QEMU_AGENT_EVENT_NONE; /* somebody waiting for this event, wake him up. */ if (agent->msg && !agent->msg->finished) { - agent->msg->finished =3D 1; + agent->msg->finished =3D true; virCondSignal(&agent->notify); } } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a62fed845e..339facfad3 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -617,7 +617,7 @@ qemuMonitorIO(GSocket *socket G_GNUC_UNUSED, /* If IO process resulted in an error & we have a message, * then wakeup that waiter */ if (mon->msg && !mon->msg->finished) { - mon->msg->finished =3D 1; + mon->msg->finished =3D true; virCondSignal(&mon->notify); } } @@ -880,7 +880,7 @@ qemuMonitorClose(qemuMonitorPtr mon) else virResetLastError(); } - mon->msg->finished =3D 1; + mon->msg->finished =3D true; virCondSignal(&mon->notify); } =20 diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index 7eec599177..1aa9bfc0d2 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -781,7 +781,7 @@ int main(int argc, char **argv) { # endif /* ! LIBVIRTD */ #endif /* ! WITH_IP */ struct daemonConfig *config; - bool privileged =3D geteuid() =3D=3D 0 ? true : false; + bool privileged =3D geteuid() =3D=3D 0; bool implicit_conf =3D false; char *run_dir =3D NULL; mode_t old_umask; diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_c= onfig.c index 0ecc49f179..a09f287656 100644 --- a/src/remote/remote_daemon_config.c +++ b/src/remote/remote_daemon_config.c @@ -99,11 +99,11 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED) =20 #ifdef WITH_IP # ifdef LIBVIRTD - data->listen_tls =3D 1; /* Only honoured if --listen is set */ + data->listen_tls =3D true; /* Only honoured if --listen is set */ # else /* ! LIBVIRTD */ - data->listen_tls =3D 0; /* Always honoured, --listen doesn't exist. */ + data->listen_tls =3D false; /* Always honoured, --listen doesn't exist= . */ # endif /* ! LIBVIRTD */ - data->listen_tcp =3D 0; + data->listen_tcp =3D false; =20 data->tls_port =3D g_strdup(LIBVIRTD_TLS_PORT); data->tcp_port =3D g_strdup(LIBVIRTD_TCP_PORT); @@ -146,7 +146,7 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED) data->max_client_requests =3D 5; =20 data->audit_level =3D 1; - data->audit_logging =3D 0; + data->audit_logging =3D false; =20 data->keepalive_interval =3D 5; data->keepalive_count =3D 5; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 7bae0c2514..0aeab9db27 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1133,7 +1133,7 @@ doRemoteOpen(virConnectPtr conn, goto failed; =20 priv->tls =3D virNetTLSContextNewClientPath(pkipath, - geteuid() !=3D 0 ? true = : false, + geteuid() !=3D 0, tls_priority, sanity, verify); if (!priv->tls) diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 07c8b85b76..e0a23867f6 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -1231,7 +1231,7 @@ virNetServerUpdateTlsFiles(virNetServerPtr srv) { int ret =3D -1; virNetTLSContextPtr ctxt =3D NULL; - bool privileged =3D geteuid() =3D=3D 0 ? true : false; + bool privileged =3D geteuid() =3D=3D 0; =20 ctxt =3D virNetServerGetTLSContext(srv); if (!ctxt) { diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index 3117dcbe65..d23ed95b78 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -1340,7 +1340,7 @@ int virNetlinkEventServiceStart(unsigned int protocol= G_GNUC_UNUSED, bool virNetlinkEventServiceIsRunning(unsigned int protocol G_GNUC_UNUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _(unsupported)); - return 0; + return false; } =20 int virNetlinkEventServiceLocalPid(unsigned int protocol G_GNUC_UNUSED) diff --git a/src/util/virtime.c b/src/util/virtime.c index bc8f06cd48..88f6f0a551 100644 --- a/src/util/virtime.c +++ b/src/util/virtime.c @@ -386,7 +386,7 @@ virTimeBackOffWait(virTimeBackOffVar *var) VIR_DEBUG("t=3D%llu, limit=3D%llu", t, var->limit_t); =20 if (t > var->limit_t) - return 0; /* ends the while loop */ + return false; /* ends the while loop */ =20 /* Compute next wait time. Cap at VIR_TIME_BACKOFF_CAP * to avoid long useless sleeps. */ @@ -406,5 +406,5 @@ virTimeBackOffWait(virTimeBackOffVar *var) VIR_DEBUG("sleeping for %llu ms", next); =20 g_usleep(next * 1000); - return 1; + return true; } diff --git a/src/util/viruri.c b/src/util/viruri.c index 58d9016a61..5fa0a6f0c8 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -48,7 +48,7 @@ virURIParamAppend(virURIPtr uri, =20 uri->params[uri->paramsCount].name =3D pname; uri->params[uri->paramsCount].value =3D pvalue; - uri->params[uri->paramsCount].ignore =3D 0; + uri->params[uri->paramsCount].ignore =3D false; uri->paramsCount++; =20 return 0; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index b1fd1181eb..f2248cef53 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -840,9 +840,9 @@ virVMXGetConfigBoolean(virConfPtr conf, const char *nam= e, bool *boolean_, return rc; =20 if (STRCASEEQ(string, "true")) { - *boolean_ =3D 1; + *boolean_ =3D true; } else if (STRCASEEQ(string, "false")) { - *boolean_ =3D 0; + *boolean_ =3D false; } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Config entry '%s' must represent a boolean value= " --=20 2.26.2