From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576151; cv=none; d=zoho.com; s=zohoarc; b=dX9Xc9YBzEcwsYbPhpR2Nbb+84DzoUF7ocp/j0K8IozPEH3GX2/R6LHxrZhOzVOc4Krh1Jh6aEvXn8IoLZR35O+w++FMBdizebxKbEDOY8MIGSRfDwvyldpyNjAPmJf1BulhMmrNrml6I7JHDCkjW+5Ol7kouxN7uKrhC4H1Prs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576151; 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=8ICjfFVHtJGnyLEhaSADv9+rwZoem8qt1RG6CJ0hVrw=; b=KARHsjH2EQxVlyGnnw9EKWZdFSyCdAsokOIXBIvbc6x5EJ8FMTijEc6aVI9inVJXCP94uxBx1hFQGaDrvYVXlv1pvx6DBeTxprAYTwHIKjAs+b4um7TSY7nRdINV17eRpduCrErS2/JZ/owQIYiUC5RB/wwJS007B8wFtR2NA0A= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576151353413.5461262586539; Sun, 20 Oct 2019 05:55:51 -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-147-cz6yk_RlNma2qQti53FKbw-1; Sun, 20 Oct 2019 08:55:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8F685E4; Sun, 20 Oct 2019 12:55:41 +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 A74931EC; Sun, 20 Oct 2019 12:55: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 E654D18089C8; Sun, 20 Oct 2019 12:55:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtWaK023306 for ; Sun, 20 Oct 2019 08:55:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 633E0196AE; Sun, 20 Oct 2019 12:55:32 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DF48194B9 for ; Sun, 20 Oct 2019 12:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576150; 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=8ICjfFVHtJGnyLEhaSADv9+rwZoem8qt1RG6CJ0hVrw=; b=S4mQJqir9RImyGUw6M+aQxhM3GD+x36WcPuTr24Inm0UzHzf101+xtsq61p3uG+HVa8mNg ExOpBhS69bsxj0TBLxgQ4ia77T95EDUbE3cIUCEAriM/bTFL0LYnc/T/B4/i58iuVBjyz/ Y6acd+5IBTjMbdMN69kldrOGZPYm1Rs= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:19 +0200 Message-Id: <91f9e142d60e88fedf9debaea30f7c893862ca48.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/34] scripts: introduce a macro file for coccinelle X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: cz6yk_RlNma2qQti53FKbw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- scripts/cocci-macro-file.h | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 scripts/cocci-macro-file.h diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h new file mode 100644 index 0000000000..a76ba533b4 --- /dev/null +++ b/scripts/cocci-macro-file.h @@ -0,0 +1,39 @@ +/* + * cocci-macro-file.h: simplified macro definitions for Coccinelle + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * To be used with: + * $ spatch --macro-file scripts/cocci-macro-file.h + */ + +#pragma once + +#define ATTRIBUTE_NONNULL(x) +#define ATTRIBUTE_PACKED + +#define G_GNUC_WARN_UNUSED_RESULT +#define G_GNUC_UNUSED +#define G_GNUC_NULL_TERMINATED +#define G_GNUC_NORETURN +#define G_GNUC_NO_INLINE +#define G_GNUC_FALLTHROUGH +#define G_GNUC_PRINTF(a, b) + +#define g_autoptr(x) x##_autoptr +#define g_autofree +#define g_auto + +#define BAD_CAST --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576175; cv=none; d=zoho.com; s=zohoarc; b=TC3/P0qRwgwXXX1WxK6WDiblsGNTOvHWXhJOBHO7qvaIulopMK7JGVPpxvhqfrsz07KG9/ypUTU+4qZNSoiYB4wcyFGepuLej/3SeK9AoWc4HFevdLax+69BRy3LZYiUW3AXWM7TKUq8frloEVrb0nguigGWm5jYK/e0pkfgHCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576175; 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=BH/+0tiF1ZuwP6eHlx/jQKaR4ktlbCNTz0r1iZGtgeo=; b=izlDvsa3OGbQskIMijw6ifcFQKIUXeGFTAmsH0sbeud6M/WjNeY1nqLTec69vLgnsexLvm5AkpLGGZ0b9bWtz3hjqARgg3VFttktRMIYwfB3kxGGvJrD6ZBPqJxYiiBIF7IodYSPYI5rzpzNF0/fs0IZq8D+QNCRWqD3hvyxxXI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 157157617536661.82116147779311; Sun, 20 Oct 2019 05:56:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-RKYoIWqUOHGf3ujZs6xGYw-1; Sun, 20 Oct 2019 08:56:12 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0B181800DFD; Sun, 20 Oct 2019 12:56:07 +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 9C6C2194B9; Sun, 20 Oct 2019 12:56:07 +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 60D62180B761; Sun, 20 Oct 2019 12:56:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtXEe023314 for ; Sun, 20 Oct 2019 08:55:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 74AD8196AE; Sun, 20 Oct 2019 12:55:33 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id D108D194B9 for ; Sun, 20 Oct 2019 12:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576174; 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=BH/+0tiF1ZuwP6eHlx/jQKaR4ktlbCNTz0r1iZGtgeo=; b=NcGel4JMBKtM1dhcoZZVbGROMRocRRjz6jaVDA1xOH2kOBvwHYw3TQe/uhFn2YjQ6rak1O asYbUmsHiEcWHQzBUmw/BtBoUVEcYPRxr7LuogUIlCCASX+R+LLqidKPF0aIegY82VWDoE B/uim2Awv3xq+ZiC9+MFnJV6Rp2c59I= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:20 +0200 Message-Id: <5dbc5f6c7009cd13d50529243805c2c9df140050.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/34] util: fix check for iscsi initiator copy X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: RKYoIWqUOHGf3ujZs6xGYw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" virStorageSourceInitiatorCopy propagates the return value from VIR_STRDUP, which returns 1 on a successful copy. Only error out on < 0, not non-zero values. Fixes: 9ea3fdc6e90a96e3d7d7aeb9867e8f0a3992b7c6 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e04cc413a4..acf26721e7 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2331,7 +2331,7 @@ virStorageSourceCopy(const virStorageSource *src, !(def->pr =3D virStoragePRDefCopy(src->pr))) return NULL; =20 - if (virStorageSourceInitiatorCopy(&def->initiator, &src->initiator)) + if (virStorageSourceInitiatorCopy(&def->initiator, &src->initiator) < = 0) return NULL; =20 if (backingChain && src->backingStore) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576175; cv=none; d=zoho.com; s=zohoarc; b=bDbvjWdUCg6wJs0pvNaOAMzU9++vV5KVoDD+8qNfQjmh8oZoIRaj4sWRW5fRoEr2uLRJXT4DOFOg92os9Rs+9L8Zdj5iv9AHGcDnLiyn1lT3rMR9sKeBbou8hhUJ14s55uMFAsCIosDmAps0nCR47+ylIb5pWsyX2dRRRYTp6vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576175; 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=u0z+/zFnLUzH2lhTJSnYXEnZ1seVaz7fzSXp0FgdzjA=; b=PbtoiMBk1NZ5Dtcd4f5Ivsf36p6dGG+isRuMRB3fAgkwWL6CXVF2BYAAs5WRkFoKHD43wpEUxSc27sVyIAkhVpuF/lIlzriT+EM0Cy+00h+kXkzUFBR8vqNz3Y8GDUboE1cFLLWUXYCxe1BnDNhp33NAZGyOXQT78D9H9BEktH4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576175460363.72102285912797; Sun, 20 Oct 2019 05:56:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-HboyD2x3OmehqTqDaInIYg-1; Sun, 20 Oct 2019 08:56:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFD011005509; Sun, 20 Oct 2019 12:56:07 +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 977095D6A3; Sun, 20 Oct 2019 12:56:07 +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 5E30E4EDA5; Sun, 20 Oct 2019 12:56:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtYmu023324 for ; Sun, 20 Oct 2019 08:55:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 92D4C196AE; Sun, 20 Oct 2019 12:55:34 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE74A1EC for ; Sun, 20 Oct 2019 12:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576174; 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=u0z+/zFnLUzH2lhTJSnYXEnZ1seVaz7fzSXp0FgdzjA=; b=b3gqoqLIKR2rJh0IcMO8QCFN5fCmJMNPXUHV3n0FoUksEO50bX2ynXP7XBw7MkZN/ZZwWH l88wtEf7oEgqTpxj5Q8p0VvvssXDyeKtt9gH9nAPI/WfkQr521y278mIoJgA+jGzx88HvK s/tImlT0fzCjadqYglXiHlrdheHJ9dg= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:21 +0200 Message-Id: <149311d38a9e454ba69e02dd58b62f9e82c84ba1.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/34] conf: use g_strdup in virDomainDiskSet 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.15 X-MC-Unique: HboyD2x3OmehqTqDaInIYg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use a temporary variable to allow copying from the currently set source. Always return 0 since none of the callers distinguishes between 0 and 1 propagated from VIR_STRDUP. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 88e93f6fb8..cd9b6ca993 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2139,15 +2139,10 @@ virDomainDiskGetSource(virDomainDiskDef const *def) int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src) { - int ret; - char *tmp =3D def->src->path; - - ret =3D VIR_STRDUP(def->src->path, src); - if (ret < 0) - def->src->path =3D tmp; - else - VIR_FREE(tmp); - return ret; + char *tmp =3D g_strdup(src); + g_free(def->src->path); + def->src->path =3D tmp; + return 0; } =20 =20 @@ -2174,15 +2169,10 @@ virDomainDiskGetDriver(const virDomainDiskDef *def) int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name) { - int ret; - char *tmp =3D def->driverName; - - ret =3D VIR_STRDUP(def->driverName, name); - if (ret < 0) - def->driverName =3D tmp; - else - VIR_FREE(tmp); - return ret; + char *tmp =3D g_strdup(name); + g_free(def->driverName); + def->driverName =3D tmp; + return 0; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576154; cv=none; d=zoho.com; s=zohoarc; b=MCyFld5NsdWGpfohMz5dI5za+zVlIkNKZhACjTGkIwKDnxCwqX2oSFU3s0SU55JSKayyKrNUwTi4pV3pkNOghzHNA6wsyHfHP5O9nfJP4RqhKwiV5Re59xE7hxN/6KTm9CWiRWIg++kmruJMNyh0q+Zt1Ce7ltGy3OeI7KCbcRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576154; 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=ct6AJxA87UbYKlntPqdWL9H2pAfVQmXq1cyw0Hi+st4=; b=b1pqTuU7OhfV5huClM9p9nFI3vi3B5SOTuGQa8oQxe5iwlbdtx7+yadleHplGdpyTqjSwbbjuv6b0ZrUHmQCbqnXvE62UobM8p/hlXkU3FZ3Q+Oh/TTiO30T1X5MDvpcEpmsV0moJVXyVJKqGhyj3hbZdrCBs9VAwVoy7zYehm0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576154719623.9904406796759; Sun, 20 Oct 2019 05:55:54 -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-179-VTYujfh8OSKg-S-UzpRwAA-1; Sun, 20 Oct 2019 08:55:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53F081800DFC; Sun, 20 Oct 2019 12:55:45 +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 A495A5D70E; Sun, 20 Oct 2019 12:55:44 +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 48D714E58C; Sun, 20 Oct 2019 12:55:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtakf023332 for ; Sun, 20 Oct 2019 08:55:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 08E651EC; Sun, 20 Oct 2019 12:55:36 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 076D7196AE for ; Sun, 20 Oct 2019 12:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576153; 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=ct6AJxA87UbYKlntPqdWL9H2pAfVQmXq1cyw0Hi+st4=; b=Vp+5PybGVJtWKOsepv5kODgRRWHaL1EdGEQOZ/BBSEkn9+xvMvnR1fNMgBrOfQwkyIJqUc lhuLl2jeyS+3qEbKaxA1Eo0KCHnp0yaZg6/NF9jkaEeOd7P9inke99oR7bEwE9Ypv+Gygb yGlusyfS1lpFuxsePmGdduG9ICimwS8= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/34] Use g_strdup instead of ignoring VIR_STRDUP's value 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.15 X-MC-Unique: VTYujfh8OSKg-S-UzpRwAA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all the occurrences of ignore_value(VIR_STRDUP(a, b)); with a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/conf/node_device_util.c | 2 +- src/esx/esx_driver.c | 2 +- src/esx/esx_storage_backend_iscsi.c | 2 +- src/hyperv/hyperv_driver.c | 4 ++-- src/libxl/libxl_domain.c | 15 +++++---------- src/libxl/libxl_driver.c | 2 +- src/lxc/lxc_driver.c | 4 ++-- src/network/bridge_driver.c | 2 +- src/node_device/node_device_udev.c | 20 ++++++++++---------- src/nwfilter/nwfilter_dhcpsnoop.c | 2 +- src/openvz/openvz_conf.c | 2 +- src/openvz/openvz_driver.c | 4 ++-- src/qemu/qemu_alias.c | 2 +- src/qemu/qemu_block.c | 2 +- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_driver.c | 8 ++++---- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_monitor_json.c | 2 +- src/rpc/virnetsaslcontext.c | 2 +- src/security/security_apparmor.c | 2 +- src/security/security_nop.c | 2 +- src/security/security_selinux.c | 2 +- src/storage/storage_backend_scsi.c | 2 +- src/storage/storage_backend_sheepdog.c | 2 +- src/storage/storage_driver.c | 4 ++-- src/storage/storage_util.c | 4 ++-- src/test/test_driver.c | 18 +++++++++--------- src/util/virbitmap.c | 2 +- src/util/virhash.c | 2 +- src/util/virlockspace.c | 2 +- src/util/virnetdev.c | 2 +- src/util/virscsi.c | 4 ++-- src/util/virscsihost.c | 2 +- src/util/virstoragefile.c | 2 +- src/util/virstring.c | 2 +- src/util/virtpm.c | 8 ++++---- src/util/virtypedparam.c | 2 +- src/util/virutil.c | 2 +- src/util/virvhba.c | 8 ++++---- src/util/virxml.c | 4 ++-- src/vbox/vbox_common.c | 2 +- src/vbox/vbox_storage.c | 2 +- src/vmware/vmware_conf.c | 2 +- src/vmware/vmware_driver.c | 2 +- src/vmx/vmx.c | 2 +- src/vz/vz_driver.c | 2 +- tests/qemuxml2argvmock.c | 6 +++--- tests/qemuxml2argvtest.c | 4 ++-- tests/testutils.c | 2 +- tests/viriscsitest.c | 12 ++++++------ tests/virstringtest.c | 6 +++--- tests/vmx2xmltest.c | 2 +- tests/xml2vmxtest.c | 2 +- 53 files changed, 101 insertions(+), 106 deletions(-) diff --git a/src/conf/node_device_util.c b/src/conf/node_device_util.c index 859ff9ebbb..3b1e8e487f 100644 --- a/src/conf/node_device_util.c +++ b/src/conf/node_device_util.c @@ -54,7 +54,7 @@ virNodeDeviceGetParentName(virConnectPtr conn, return NULL; } =20 - ignore_value(VIR_STRDUP(parent, virNodeDeviceGetParent(device))); + parent =3D g_strdup(virNodeDeviceGetParent(device)); virObjectUnref(device); =20 return parent; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index cdf925d62c..6c80e97220 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1856,7 +1856,7 @@ esxDomainGetOSType(virDomainPtr domain G_GNUC_UNUSED) { char *osType; =20 - ignore_value(VIR_STRDUP(osType, "hvm")); + osType =3D g_strdup("hvm"); return osType; } =20 diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index e9a30876bf..a7e1f1b340 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -766,7 +766,7 @@ esxStorageVolGetPath(virStorageVolPtr volume) { char *path; =20 - ignore_value(VIR_STRDUP(path, volume->name)); + path =3D g_strdup(volume->name); return path; } =20 diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4e99721d37..d69542b500 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -221,7 +221,7 @@ hypervConnectGetHostname(virConnectPtr conn) goto cleanup; } =20 - ignore_value(VIR_STRDUP(hostname, computerSystem->data.common->DNSHost= Name)); + hostname =3D g_strdup(computerSystem->data.common->DNSHostName); =20 cleanup: hypervFreeObject(priv, (hypervObject *)computerSystem); @@ -602,7 +602,7 @@ hypervDomainGetOSType(virDomainPtr domain G_GNUC_UNUSED) { char *osType; =20 - ignore_value(VIR_STRDUP(osType, "hvm")); + osType =3D g_strdup("hvm"); return osType; } =20 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 1e4d900ac5..25228af7a6 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1132,10 +1132,8 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev= , void *for_callback) &console); if (!ret) { VIR_FREE(chr->source->data.file.path); - if (console && console[0] !=3D '\0') { - ignore_value(VIR_STRDUP(chr->source->data.file.path, - console)); - } + if (console && console[0] !=3D '\0') + chr->source->data.file.path =3D g_strdup(console); } VIR_FREE(console); } @@ -1153,10 +1151,8 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev= , void *for_callback) &console); if (!ret) { VIR_FREE(chr->source->data.file.path); - if (console && console[0] !=3D '\0') { - ignore_value(VIR_STRDUP(chr->source->data.file.path, - console)); - } + if (console && console[0] !=3D '\0') + chr->source->data.file.path =3D g_strdup(console); } VIR_FREE(console); } @@ -1242,8 +1238,7 @@ libxlDomainCreateChannelPTY(virDomainDefPtr def, libx= l_ctx *ctx) if (!ret && channelinfo.u.pty.path && *channelinfo.u.pty.path !=3D '\0') { VIR_FREE(chr->source->data.file.path); - ignore_value(VIR_STRDUP(chr->source->data.file.path, - channelinfo.u.pty.path)); + chr->source->data.file.path =3D g_strdup(channelinfo.u.pty= .path); } } =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 64b21f2073..14bd62b383 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4607,7 +4607,7 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *np= arams) goto cleanup; } =20 - ignore_value(VIR_STRDUP(ret, name)); + ret =3D g_strdup(name); =20 cleanup: virDomainObjEndAPI(&vm); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 204a3ed522..7c2e6cf561 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1792,7 +1792,7 @@ static char *lxcDomainGetSchedulerType(virDomainPtr d= om, if (!virDomainObjIsActive(vm)) { if (nparams) *nparams =3D 3; - ignore_value(VIR_STRDUP(ret, "posix")); + ret =3D g_strdup("posix"); goto cleanup; } =20 @@ -1809,7 +1809,7 @@ static char *lxcDomainGetSchedulerType(virDomainPtr d= om, *nparams =3D 1; } =20 - ignore_value(VIR_STRDUP(ret, "posix")); + ret =3D g_strdup("posix"); =20 cleanup: virDomainObjEndAPI(&vm); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 6862818698..9dce161937 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4190,7 +4190,7 @@ networkGetBridgeName(virNetworkPtr net) goto cleanup; } =20 - ignore_value(VIR_STRDUP(bridge, def->bridge)); + bridge =3D g_strdup(def->bridge); =20 cleanup: virNetworkObjEndAPI(&obj); diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index f6729308d7..c9449ace9e 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -665,34 +665,34 @@ udevGetSCSIType(virNodeDeviceDefPtr def G_GNUC_UNUSED, =20 switch (type) { case TYPE_DISK: - ignore_value(VIR_STRDUP(*typestring, "disk")); + *typestring =3D g_strdup("disk"); break; case TYPE_TAPE: - ignore_value(VIR_STRDUP(*typestring, "tape")); + *typestring =3D g_strdup("tape"); break; case TYPE_PROCESSOR: - ignore_value(VIR_STRDUP(*typestring, "processor")); + *typestring =3D g_strdup("processor"); break; case TYPE_WORM: - ignore_value(VIR_STRDUP(*typestring, "worm")); + *typestring =3D g_strdup("worm"); break; case TYPE_ROM: - ignore_value(VIR_STRDUP(*typestring, "cdrom")); + *typestring =3D g_strdup("cdrom"); break; case TYPE_SCANNER: - ignore_value(VIR_STRDUP(*typestring, "scanner")); + *typestring =3D g_strdup("scanner"); break; case TYPE_MOD: - ignore_value(VIR_STRDUP(*typestring, "mod")); + *typestring =3D g_strdup("mod"); break; case TYPE_MEDIUM_CHANGER: - ignore_value(VIR_STRDUP(*typestring, "changer")); + *typestring =3D g_strdup("changer"); break; case TYPE_ENCLOSURE: - ignore_value(VIR_STRDUP(*typestring, "enclosure")); + *typestring =3D g_strdup("enclosure"); break; case TYPE_RAID: - ignore_value(VIR_STRDUP(*typestring, "raid")); + *typestring =3D g_strdup("raid"); break; case TYPE_NO_LUN: default: diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 90f3933959..2c7a1a1522 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1395,7 +1395,7 @@ virNWFilterDHCPSnoopThread(void *req0) fds[i].fd =3D pcap_fileno(pcapConf[i].handle); } tmp =3D virNetDevGetIndex(req->binding->portdevname, &ifindex); - ignore_value(VIR_STRDUP(threadkey, req->threadkey)); + threadkey =3D g_strdup(req->threadkey); worker =3D virThreadPoolNew(1, 1, 0, virNWFilterDHCPDecodeWorker, req); diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index be5f89ea45..e5ef426329 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -878,7 +878,7 @@ openvzLocateConfDir(void) =20 while (conf_dir_list[i]) { if (virFileExists(conf_dir_list[i])) { - ignore_value(VIR_STRDUP(ret, conf_dir_list[i])); + ret =3D g_strdup(conf_dir_list[i]); goto cleanup; } i++; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 408b393e30..d1153edd00 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -373,7 +373,7 @@ static char *openvzDomainGetOSType(virDomainPtr dom) if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) return NULL; =20 - ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)= )); + ret =3D g_strdup(virDomainOSTypeToString(vm->def->os.type)); =20 virDomainObjEndAPI(&vm); return ret; @@ -716,7 +716,7 @@ openvzGenerateContainerVethName(int veid) =20 /* try to get line "^NETIF=3D..." from config */ if (openvzReadVPSConfigParam(veid, "NETIF", &temp) <=3D 0) { - ignore_value(VIR_STRDUP(name, "eth0")); + name =3D g_strdup("eth0"); } else { char *saveptr =3D NULL; char *s; diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index d294963d35..5af3725bf5 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -758,7 +758,7 @@ qemuDomainGetMasterKeyAlias(void) { char *alias; =20 - ignore_value(VIR_STRDUP(alias, "masterKey0")); + alias =3D g_strdup("masterKey0"); =20 return alias; } diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4dc4f2922d..515bcd3d59 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1934,7 +1934,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr sr= c) char *ret =3D NULL; =20 if (virStorageSourceIsLocalStorage(src)) { - ignore_value(VIR_STRDUP(ret, src->path)); + ret =3D g_strdup(src->path); return ret; } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a97bf65e7f..3ef84cc9a6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10197,7 +10197,7 @@ qemuDomainStorageAlias(const char *device, int dept= h) device =3D qemuAliasDiskDriveSkipPrefix(device); =20 if (!depth) - ignore_value(VIR_STRDUP(alias, device)); + alias =3D g_strdup(device); else ignore_value(virAsprintf(&alias, "%s.%d", device, depth)); return alias; @@ -14719,7 +14719,7 @@ qemuDomainDiskBackingStoreGetName(virDomainDiskDefP= tr disk, if (idx) ignore_value(virAsprintf(&ret, "%s[%d]", disk->dst, idx)); else - ignore_value(VIR_STRDUP(ret, disk->dst)); + ret =3D g_strdup(disk->dst); =20 return ret; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bf436f7dc3..421a21818e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2281,7 +2281,7 @@ static char *qemuDomainGetOSType(virDomainPtr dom) { if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - ignore_value(VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type= ))); + type =3D g_strdup(virDomainOSTypeToString(vm->def->os.type)); =20 cleanup: virDomainObjEndAPI(&vm); @@ -4062,7 +4062,7 @@ qemuDomainScreenshot(virDomainPtr dom, goto endjob; } =20 - ignore_value(VIR_STRDUP(ret, "image/x-portable-pixmap")); + ret =3D g_strdup("image/x-portable-pixmap"); =20 endjob: VIR_FORCE_CLOSE(tmp_fd); @@ -9236,7 +9236,7 @@ static char *qemuDomainGetSchedulerType(virDomainPtr = dom, if (!virDomainObjIsActive(vm)) { if (nparams) *nparams =3D 9; - ignore_value(VIR_STRDUP(ret, "posix")); + ret =3D g_strdup("posix"); goto cleanup; } =20 @@ -9253,7 +9253,7 @@ static char *qemuDomainGetSchedulerType(virDomainPtr = dom, *nparams =3D 1; } =20 - ignore_value(VIR_STRDUP(ret, "posix")); + ret =3D g_strdup("posix"); =20 cleanup: virDomainObjEndAPI(&vm); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c65491f9d6..fed95a285a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1841,7 +1841,7 @@ qemuMigrationDstGetURI(const char *migrateFrom, if (STREQ(migrateFrom, "stdio")) ignore_value(virAsprintf(&uri, "fd:%d", migrateFd)); else - ignore_value(VIR_STRDUP(uri, migrateFrom)); + uri =3D g_strdup(migrateFrom); =20 return uri; } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 02308dffe6..4b765da0b1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6719,7 +6719,7 @@ qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon) goto cleanup; } =20 - ignore_value(VIR_STRDUP(ret, arch)); + ret =3D g_strdup(arch); =20 cleanup: virJSONValueFree(cmd); diff --git a/src/rpc/virnetsaslcontext.c b/src/rpc/virnetsaslcontext.c index f579162aa2..01ff41b778 100644 --- a/src/rpc/virnetsaslcontext.c +++ b/src/rpc/virnetsaslcontext.c @@ -415,7 +415,7 @@ char *virNetSASLSessionListMechanisms(virNetSASLSession= Ptr sasl) _("no SASL mechanisms are available")); goto cleanup; } - ignore_value(VIR_STRDUP(ret, mechlist)); + ret =3D g_strdup(mechlist); =20 cleanup: virObjectUnlock(sasl); diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index 75203cc43a..dd8f7d3808 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -1158,7 +1158,7 @@ AppArmorGetMountOptions(virSecurityManagerPtr mgr G_G= NUC_UNUSED, { char *opts; =20 - ignore_value(VIR_STRDUP(opts, "")); + opts =3D g_strdup(""); return opts; } =20 diff --git a/src/security/security_nop.c b/src/security/security_nop.c index 5e7eed8e7c..c1856eb421 100644 --- a/src/security/security_nop.c +++ b/src/security/security_nop.c @@ -196,7 +196,7 @@ virSecurityDomainGetMountOptionsNop(virSecurityManagerP= tr mgr G_GNUC_UNUSED, { char *opts; =20 - ignore_value(VIR_STRDUP(opts, "")); + opts =3D g_strdup(""); return opts; } =20 diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 0812def922..4988659044 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -552,7 +552,7 @@ virSecuritySELinuxContextAddRange(security_context_t sr= c, goto cleanup; } =20 - ignore_value(VIR_STRDUP(ret, str)); + ret =3D g_strdup(str); =20 cleanup: if (srccon) context_free(srccon); diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index fd243776f8..98d9d92ac5 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -184,7 +184,7 @@ getAdapterName(virStorageAdapterPtr adapter) unique_id))) return NULL; } else { - ignore_value(VIR_STRDUP(name, scsi_host->name)); + name =3D g_strdup(scsi_host->name); } } else if (adapter->type =3D=3D VIR_STORAGE_ADAPTER_TYPE_FC_HOST) { virStorageAdapterFCHostPtr fchost =3D &adapter->data.fchost; diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index f03c5c7e05..443c224222 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -343,7 +343,7 @@ virStorageBackendSheepdogRefreshVol(virStoragePoolObjPt= r pool, return -1; =20 VIR_FREE(vol->target.path); - ignore_value(VIR_STRDUP(vol->target.path, vol->name)); + vol->target.path =3D g_strdup(vol->name); =20 return 0; } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index da09d7de13..ac215c7036 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -1657,7 +1657,7 @@ storageVolLookupByPathCallback(virStoragePoolObjPtr o= bj, case VIR_STORAGE_POOL_SHEEPDOG: case VIR_STORAGE_POOL_ZFS: case VIR_STORAGE_POOL_LAST: - ignore_value(VIR_STRDUP(stable_path, data->path)); + stable_path =3D g_strdup(data->path); break; } =20 @@ -2760,7 +2760,7 @@ storageVolGetPath(virStorageVolPtr vol) voldef) < 0) goto cleanup; =20 - ignore_value(VIR_STRDUP(ret, voldef->target.path)); + ret =3D g_strdup(voldef->target.path); =20 cleanup: virStoragePoolObjEndAPI(&obj); diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 410d412ef1..a4c8a5e971 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1986,7 +1986,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, * the original non-stable dev path */ =20 - ignore_value(VIR_STRDUP(stablepath, devpath)); + stablepath =3D g_strdup(devpath); =20 return stablepath; } @@ -3641,7 +3641,7 @@ virStorageBackendSCSISerial(const char *dev, if (rc =3D=3D -2) return NULL; =20 - ignore_value(VIR_STRDUP(serial, dev)); + serial =3D g_strdup(dev); return serial; } =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ab7e5fc02a..bd095604c7 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -725,7 +725,7 @@ static char *testBuildFilename(const char *relativeTo, if (!filename || filename[0] =3D=3D '\0') return NULL; if (filename[0] =3D=3D '/') { - ignore_value(VIR_STRDUP(ret, filename)); + ret =3D g_strdup(filename); return ret; } =20 @@ -742,7 +742,7 @@ static char *testBuildFilename(const char *relativeTo, strcat(absFile, filename); return absFile; } else { - ignore_value(VIR_STRDUP(ret, filename)); + ret =3D g_strdup(filename); return ret; } } @@ -1585,7 +1585,7 @@ testConnectGetSysinfo(virConnectPtr conn G_GNUC_UNUSE= D, =20 virCheckFlags(0, NULL); =20 - ignore_value(VIR_STRDUP(ret, sysinfo)); + ret =3D g_strdup(sysinfo); return ret; } =20 @@ -2561,7 +2561,7 @@ testDomainGetOSType(virDomainPtr dom G_GNUC_UNUSED) { char *ret; =20 - ignore_value(VIR_STRDUP(ret, "linux")); + ret =3D g_strdup("linux"); return ret; } =20 @@ -4889,7 +4889,7 @@ static char *testDomainGetSchedulerType(virDomainPtr = domain G_GNUC_UNUSED, if (nparams) *nparams =3D 1; =20 - ignore_value(VIR_STRDUP(type, "fair")); + type =3D g_strdup("fair"); =20 return type; } @@ -5611,7 +5611,7 @@ testNetworkGetBridgeName(virNetworkPtr net) goto cleanup; } =20 - ignore_value(VIR_STRDUP(bridge, def->bridge)); + bridge =3D g_strdup(def->bridge); =20 cleanup: virNetworkObjEndAPI(&obj); @@ -6367,7 +6367,7 @@ testConnectFindStoragePoolSources(virConnectPtr conn = G_GNUC_UNUSED, switch (pool_type) { =20 case VIR_STORAGE_POOL_LOGICAL: - ignore_value(VIR_STRDUP(ret, defaultPoolSourcesLogicalXML)); + ret =3D g_strdup(defaultPoolSourcesLogicalXML); return ret; =20 case VIR_STORAGE_POOL_NETFS: @@ -7241,7 +7241,7 @@ testStorageVolGetPath(virStorageVolPtr vol) if (!(privvol =3D testStorageVolDefFindByName(obj, vol->name))) goto cleanup; =20 - ignore_value(VIR_STRDUP(ret, privvol->target.path)); + ret =3D g_strdup(privvol->target.path); =20 cleanup: virStoragePoolObjEndAPI(&obj); @@ -7362,7 +7362,7 @@ testNodeDeviceGetParent(virNodeDevicePtr dev) def =3D virNodeDeviceObjGetDef(obj); =20 if (def->parent) { - ignore_value(VIR_STRDUP(ret, def->parent)); + ret =3D g_strdup(def->parent); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no parent for this device")); diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 5ac489004d..a9d8e6c3d5 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -418,7 +418,7 @@ virBitmapFormat(virBitmapPtr bitmap) =20 if (!bitmap || (cur =3D virBitmapNextSetBit(bitmap, -1)) < 0) { char *ret; - ignore_value(VIR_STRDUP(ret, "")); + ret =3D g_strdup(""); return ret; } =20 diff --git a/src/util/virhash.c b/src/util/virhash.c index a7fc620567..447b7cfabf 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -94,7 +94,7 @@ static bool virHashStrEqual(const void *namea, const void= *nameb) static void *virHashStrCopy(const void *name) { char *ret; - ignore_value(VIR_STRDUP(ret, name)); + ret =3D g_strdup(name); return ret; } =20 diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index c8e520c672..d383746183 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -69,7 +69,7 @@ static char *virLockSpaceGetResourcePath(virLockSpacePtr = lockspace, if (lockspace->dir) ignore_value(virAsprintf(&ret, "%s/%s", lockspace->dir, resname)); else - ignore_value(VIR_STRDUP(ret, resname)); + ret =3D g_strdup(resname); return ret; } =20 diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index d8ae5fbc5f..5391f0030b 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -836,7 +836,7 @@ char *virNetDevGetName(int ifindex) goto cleanup; } =20 - ignore_value(VIR_STRDUP(ifname, name)); + ifname =3D g_strdup(name); =20 cleanup: return ifname; diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 17e8aa1daa..af8692eb5b 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -127,7 +127,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix, =20 while (virDirRead(dir, &entry, path) > 0) { /* Assume a single directory entry */ - ignore_value(VIR_STRDUP(sg, entry->d_name)); + sg =3D g_strdup(entry->d_name); break; } =20 @@ -165,7 +165,7 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix, goto cleanup; =20 while (virDirRead(dir, &entry, path) > 0) { - ignore_value(VIR_STRDUP(name, entry->d_name)); + name =3D g_strdup(entry->d_name); break; } =20 diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c index a5e8583b2b..10524f49fa 100644 --- a/src/util/virscsihost.c +++ b/src/util/virscsihost.c @@ -157,7 +157,7 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, continue; } =20 - ignore_value(VIR_STRDUP(ret, entry->d_name)); + ret =3D g_strdup(entry->d_name); break; } =20 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index acf26721e7..098d2684cc 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4014,7 +4014,7 @@ virStorageFileCanonicalizeFormatPath(char **component= s, =20 /* if the output string is empty just return an empty string */ if (!(ret =3D virBufferContentAndReset(&buf))) - ignore_value(VIR_STRDUP(ret, "")); + ret =3D g_strdup(""); =20 return ret; } diff --git a/src/util/virstring.c b/src/util/virstring.c index 6453a23ada..fcae16c8fe 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -160,7 +160,7 @@ char *virStringListJoin(const char **strings, return NULL; ret =3D virBufferContentAndReset(&buf); if (!ret) - ignore_value(VIR_STRDUP(ret, "")); + ret =3D g_strdup(""); return ret; } =20 diff --git a/src/util/virtpm.c b/src/util/virtpm.c index c7702c8c25..9244697902 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -75,7 +75,7 @@ virTPMCreateCancelPath(const char *devpath) VIR_FREE(path); } if (!path) - ignore_value(VIR_STRDUP(path, "/dev/null")); + path =3D g_strdup("/dev/null"); } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("TPM device path %s is invalid"), devpath); @@ -116,7 +116,7 @@ virTPMGetSwtpm(void) return NULL; =20 virMutexLock(&swtpm_tools_lock); - ignore_value(VIR_STRDUP(s, swtpm_path)); + s =3D g_strdup(swtpm_path); virMutexUnlock(&swtpm_tools_lock); =20 return s; @@ -131,7 +131,7 @@ virTPMGetSwtpmSetup(void) return NULL; =20 virMutexLock(&swtpm_tools_lock); - ignore_value(VIR_STRDUP(s, swtpm_setup)); + s =3D g_strdup(swtpm_setup); virMutexUnlock(&swtpm_tools_lock); =20 return s; @@ -146,7 +146,7 @@ virTPMGetSwtpmIoctl(void) return NULL; =20 virMutexLock(&swtpm_tools_lock); - ignore_value(VIR_STRDUP(s, swtpm_ioctl)); + s =3D g_strdup(swtpm_ioctl); virMutexUnlock(&swtpm_tools_lock); =20 return s; diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 2cd7e81bdd..c2dadfd410 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -194,7 +194,7 @@ virTypedParameterToString(virTypedParameterPtr param) ignore_value(virAsprintf(&value, "%d", param->value.b)); break; case VIR_TYPED_PARAM_STRING: - ignore_value(VIR_STRDUP(value, param->value.s)); + value =3D g_strdup(param->value.s); break; default: virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/util/virutil.c b/src/util/virutil.c index cf3a397516..637d19e46c 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -714,7 +714,7 @@ static char *virGetGroupEnt(gid_t gid) return NULL; } =20 - ignore_value(VIR_STRDUP(ret, gr->gr_name)); + ret =3D g_strdup(gr->gr_name); VIR_FREE(strbuf); return ret; } diff --git a/src/util/virvhba.c b/src/util/virvhba.c index ac80d9bd79..dbbd8d0f52 100644 --- a/src/util/virvhba.c +++ b/src/util/virvhba.c @@ -148,7 +148,7 @@ virVHBAGetConfig(const char *sysfs_prefix, else p =3D buf; =20 - ignore_value(VIR_STRDUP(result, p)); + result =3D g_strdup(p); =20 cleanup: VIR_FREE(sysfs_path); @@ -222,7 +222,7 @@ virVHBAFindVportHost(const char *sysfs_prefix) if ((strlen(max_vports) >=3D strlen(vports)) || ((strlen(max_vports) =3D=3D strlen(vports)) && strcmp(max_vports, vports) > 0)) { - ignore_value(VIR_STRDUP(ret, entry->d_name)); + ret =3D g_strdup(entry->d_name); goto cleanup; } =20 @@ -403,7 +403,7 @@ virVHBAGetHostByWWN(const char *sysfs_prefix, if (rc =3D=3D 0) continue; =20 - ignore_value(VIR_STRDUP(ret, entry->d_name)); + ret =3D g_strdup(entry->d_name); break; } =20 @@ -454,7 +454,7 @@ virVHBAGetHostByFabricWWN(const char *sysfs_prefix, if (rc =3D=3D 0) continue; =20 - ignore_value(VIR_STRDUP(ret, entry->d_name)); + ret =3D g_strdup(entry->d_name); break; } =20 diff --git a/src/util/virxml.c b/src/util/virxml.c index 46c79e2d94..209c83b6cc 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -91,7 +91,7 @@ virXPathString(const char *xpath, xmlXPathFreeObject(obj); return NULL; } - ignore_value(VIR_STRDUP(ret, (char *) obj->stringval)); + ret =3D g_strdup((char *)obj->stringval); xmlXPathFreeObject(obj); return ret; } @@ -995,7 +995,7 @@ virXMLNodeToString(xmlDocPtr doc, goto cleanup; } =20 - ignore_value(VIR_STRDUP(ret, (const char *)xmlBufferContent(xmlbuf))); + ret =3D g_strdup((const char *)xmlBufferContent(xmlbuf)); =20 cleanup: xmlBufferFree(xmlbuf); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 56c3c8d896..02c0a894e7 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -2701,7 +2701,7 @@ static char *vboxDomainGetOSType(virDomainPtr dom G_G= NUC_UNUSED) { */ char *osType; =20 - ignore_value(VIR_STRDUP(osType, "hvm")); + osType =3D g_strdup("hvm"); return osType; } =20 diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index ba5b876ffb..6929a9a2f3 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -843,7 +843,7 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) if (!hddLocationUtf8) goto cleanup; =20 - ignore_value(VIR_STRDUP(ret, hddLocationUtf8)); + ret =3D g_strdup(hddLocationUtf8); =20 VIR_DEBUG("Storage Volume Name: %s", vol->name); VIR_DEBUG("Storage Volume Path: %s", hddLocationUtf8); diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 701062e440..207af8fe81 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -541,6 +541,6 @@ vmwareCopyVMXFileName(const char *datastorePath, void *= opaque G_GNUC_UNUSED) { char *path; =20 - ignore_value(VIR_STRDUP(path, datastorePath)); + path =3D g_strdup(datastorePath); return path; } diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 7243453307..912827a921 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -844,7 +844,7 @@ vmwareDomainGetOSType(virDomainPtr dom) if (!(vm =3D vmwareDomObjFromDomain(driver, dom->uuid))) return NULL; =20 - ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)= )); + ret =3D g_strdup(virDomainOSTypeToString(vm->def->os.type)); =20 virDomainObjEndAPI(&vm); return ret; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index fa7aa79484..7d20351a83 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3595,7 +3595,7 @@ virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDef= Ptr def, =20 fileName =3D ctx->formatFileName(src, ctx->opaque); } else if (def->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) { - ignore_value(VIR_STRDUP(fileName, "emptyBackingString")); + fileName =3D g_strdup("emptyBackingString"); } =20 if (fileName =3D=3D NULL) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 21425346ac..76b23788b8 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -677,7 +677,7 @@ vzDomainGetOSType(virDomainPtr domain) if (virDomainGetOSTypeEnsureACL(domain->conn, dom->def) < 0) goto cleanup; =20 - ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(dom->def->os.type= ))); + ret =3D g_strdup(virDomainOSTypeToString(dom->def->os.type)); =20 cleanup: virDomainObjEndAPI(&dom); diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index cc9a3ccbff..2b9e5e7a49 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -101,7 +101,7 @@ virTPMCreateCancelPath(const char *devpath) char *path; (void)devpath; =20 - ignore_value(VIR_STRDUP(path, "/sys/class/misc/tpm0/device/cancel")); + path =3D g_strdup("/sys/class/misc/tpm0/device/cancel"); =20 return path; } @@ -125,7 +125,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix G_GNUC_= UNUSED, { char *ret; =20 - ignore_value(VIR_STRDUP(ret, "sg0")); + ret =3D g_strdup("sg0"); return ret; } =20 @@ -199,7 +199,7 @@ virHostGetDRMRenderNode(void) { char *dst =3D NULL; =20 - ignore_value(VIR_STRDUP(dst, "/dev/dri/foo")); + dst =3D g_strdup("/dev/dri/foo"); return dst; } =20 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 90edd7a844..7bbc44451d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1215,7 +1215,7 @@ mymain(void) =20 driver.config->vncSASL =3D 1; VIR_FREE(driver.config->vncSASLdir); - ignore_value(VIR_STRDUP(driver.config->vncSASLdir, "/root/.sasl2")); + driver.config->vncSASLdir =3D g_strdup("/root/.sasl2"); DO_TEST("graphics-vnc-sasl", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VG= A); driver.config->vncTLS =3D 1; driver.config->vncTLSx509verify =3D 1; @@ -1247,7 +1247,7 @@ mymain(void) DO_TEST("graphics-spice-no-args", QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_CIRRUS_VGA); driver.config->spiceSASL =3D 1; - ignore_value(VIR_STRDUP(driver.config->spiceSASLdir, "/root/.sasl2")); + driver.config->spiceSASLdir =3D g_strdup("/root/.sasl2"); DO_TEST("graphics-spice-sasl", QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_QXL); diff --git a/tests/testutils.c b/tests/testutils.c index 15fe561c6b..1c89d503d9 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -767,7 +767,7 @@ virTestLogContentAndReset(void) return NULL; ret =3D virBufferContentAndReset(&testLog.buf); if (!ret) - ignore_value(VIR_STRDUP(ret, "")); + ret =3D g_strdup(""); return ret; } =20 diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c index 4722591b86..76f0aa2946 100644 --- a/tests/viriscsitest.c +++ b/tests/viriscsitest.c @@ -87,9 +87,9 @@ static void testIscsiadmCb(const char *const*args, args[2] && STREQ(args[2], "session") && args[3] =3D=3D NULL) { if (data->output_version) - ignore_value(VIR_STRDUP(*output, iscsiadmSessionOutputNonFlash= )); + *output =3D g_strdup(iscsiadmSessionOutputNonFlash); else - ignore_value(VIR_STRDUP(*output, iscsiadmSessionOutput)); + *output =3D g_strdup(iscsiadmSessionOutput); } else if (args[0] && STREQ(args[0], ISCSIADM) && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "discovery") && @@ -100,7 +100,7 @@ static void testIscsiadmCb(const char *const*args, args[7] && STREQ(args[7], "--op") && args[8] && STREQ(args[8], "nonpersistent") && args[9] =3D=3D NULL) { - ignore_value(VIR_STRDUP(*output, iscsiadmSendtargetsOutput)); + *output =3D g_strdup(iscsiadmSendtargetsOutput); } else if (args[0] && STREQ(args[0], ISCSIADM) && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "node") && @@ -125,9 +125,9 @@ static void testIscsiadmCb(const char *const*args, args[2] && STREQ(args[2], "iface") && args[3] =3D=3D NULL) { if (data->iface_created) - ignore_value(VIR_STRDUP(*output, iscsiadmIfaceIfaceOutput)); + *output =3D g_strdup(iscsiadmIfaceIfaceOutput); else - ignore_value(VIR_STRDUP(*output, iscsiadmIfaceDefaultOutput)); + *output =3D g_strdup(iscsiadmIfaceDefaultOutput); } else if (args[0] && STREQ(args[0], ISCSIADM) && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "iface") && @@ -171,7 +171,7 @@ static void testIscsiadmCb(const char *const*args, args[8] && STREQ(args[8], "libvirt-iface-03020100") && args[9] =3D=3D NULL && data->iface_created) { - ignore_value(VIR_STRDUP(*output, iscsiadmSendtargetsOutput)); + *output =3D g_strdup(iscsiadmSendtargetsOutput); } else if (args[0] && STREQ(args[0], ISCSIADM) && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "node") && diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 43c76ccda0..5d010f7f59 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -697,9 +697,9 @@ testVirStringListFreeCount(const void *opaque G_GNUC_UN= USED) if (VIR_ALLOC_N(list, 4) < 0) return -1; =20 - ignore_value(VIR_STRDUP(list[0], "test1")); - ignore_value(VIR_STRDUP(list[2], "test2")); - ignore_value(VIR_STRDUP(list[3], "test3")); + list[0] =3D g_strdup("test1"); + list[2] =3D g_strdup("test2"); + list[3] =3D g_strdup("test3"); =20 virStringListFreeCount(list, 4); =20 diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index b2c56a15fe..4c5d41aee5 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -157,7 +157,7 @@ testParseVMXFileName(const char *fileName, void *opaque= G_GNUC_UNUSED) goto cleanup; } else if (STRPREFIX(fileName, "/")) { /* Found absolute path referencing a file outside a datastore */ - ignore_value(VIR_STRDUP(src, fileName)); + src =3D g_strdup(fileName); } else if (strchr(fileName, '/') !=3D NULL) { /* Found relative path, this is not supported */ src =3D NULL; diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 2078f5c7cf..0cfdb1facf 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -175,7 +175,7 @@ testFormatVMXFileName(const char *src, void *opaque G_G= NUC_UNUSED) goto cleanup; } else if (STRPREFIX(src, "/")) { /* Found absolute path */ - ignore_value(VIR_STRDUP(absolutePath, src)); + absolutePath =3D g_strdup(src); } else { /* Found relative path, this is not supported */ goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576185; cv=none; d=zoho.com; s=zohoarc; b=YwppyFM1oRS6fyHE69PEFXLT31amJJZK2TXAD/l7+uoD73o8ms/kYEY7XdeAEEGR64iTyrpm5WY2jM66NggIDQBgyvB5oDjClEqdO6L+nBKJaC7PdaCGfCKZRlDiueQIGccnrOzqFG6Mgk4mf+54YJo+7IzQMN8BD3GAdGF61UI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576185; 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=RDfAoPHyeTv2RQAhR/nh+gompswauDo7m1FB2H04qbc=; b=RCaQTKTBVzRXPbKeA6NryLzm2tFq8W23fBGT6qRvRTE3vWOJ6q+83D/2S5b+N4pFnRor+080O78C5pohTbMZXNEoV4iMyRwB+F5H0GfjAtNZjiuOAeBXPALWBTNX0/zq3VrFJyOLgEP/TsMNTREGbnI/B+IVSvjHlSGMnX7eoEQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576185213184.90723586787863; Sun, 20 Oct 2019 05:56:25 -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-203-wC8oQseTO-SWElXymBHzOw-1; Sun, 20 Oct 2019 08:56:19 -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 3B471800D5A; Sun, 20 Oct 2019 12:56:11 +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 13B2F60C05; Sun, 20 Oct 2019 12:56:11 +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 C4CFF1803B49; Sun, 20 Oct 2019 12:56:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtbl9023340 for ; Sun, 20 Oct 2019 08:55:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E2CF196AE; Sun, 20 Oct 2019 12:55:37 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68480194B9 for ; Sun, 20 Oct 2019 12:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576184; 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=RDfAoPHyeTv2RQAhR/nh+gompswauDo7m1FB2H04qbc=; b=AotBpMLe7ZR7eOsA5gRnfeWk64GclQ6mUrwjspK/wdd5XKMr9ZtbbNCpZuvtp+bmrOeD4u o2P0xPjaDYNrPqNASy51hRPX/4gqIjGavc/miC1wLgzP2+/OfU9u053lKt6mSL4Jk/VQUL Oh05PVJ/DzVmxPBQ+ZtUtU6CKAs95O4= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:23 +0200 Message-Id: <7781078636a4284fc72d152c210c97a29e5366a9.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/34] Use g_strdup instead of ignoring VIR_STRDUP_QUIET's value 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-MC-Unique: wC8oQseTO-SWElXymBHzOw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all the occurrences of ignore_value(VIR_STRDUP_QUIET(a, b)); with a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/locking/lock_driver_sanlock.c | 2 +- src/qemu/qemu_process.c | 14 +++++++------- src/util/virerror.c | 11 +++++------ src/util/virfile.c | 4 ++-- src/util/virstoragefile.c | 2 +- src/util/virutil.c | 8 ++++---- tests/networkxml2firewalltest.c | 4 ++-- tests/virfilemock.c | 2 +- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sa= nlock.c index 9cedf39578..1d1691f6ba 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -101,7 +101,7 @@ virLockManagerSanlockError(int err, { if (err <=3D -200) { #if HAVE_SANLOCK_STRERROR - ignore_value(VIR_STRDUP_QUIET(*message, sanlock_strerror(err))); + *message =3D g_strdup(sanlock_strerror(err)); #else ignore_value(virAsprintfQuiet(message, _("sanlock error %d"), err)= ); #endif diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9eaea4edfd..843e852591 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -959,7 +959,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon G_GNUC_UNU= SED, /* We have a SYNC API waiting for this event, dispatch it back */ job->newstate =3D status; VIR_FREE(job->errmsg); - ignore_value(VIR_STRDUP_QUIET(job->errmsg, error)); + job->errmsg =3D g_strdup(error); virDomainObjBroadcast(vm); } else { /* there is no waiting SYNC API, dispatch the update to a thread */ @@ -1749,11 +1749,11 @@ qemuProcessHandleDumpCompleted(qemuMonitorPtr mon G= _GNUC_UNUSED, } priv->job.dumpCompleted =3D true; priv->job.current->stats.dump =3D *stats; - ignore_value(VIR_STRDUP_QUIET(priv->job.error, error)); + priv->job.error =3D g_strdup(error); =20 /* Force error if extracting the DUMP_COMPLETED status failed */ if (!error && status < 0) { - ignore_value(VIR_STRDUP_QUIET(priv->job.error, virGetLastErrorMess= age())); + priv->job.error =3D g_strdup(virGetLastErrorMessage()); priv->job.current->stats.dump.status =3D QEMU_MONITOR_DUMP_STATUS_= FAILED; } =20 @@ -3407,20 +3407,20 @@ qemuProcessUpdateState(virQEMUDriverPtr driver, vir= DomainObjPtr vm) oldReason =3D=3D VIR_DOMAIN_PAUSED_STARTING_UP))) { newState =3D VIR_DOMAIN_RUNNING; newReason =3D VIR_DOMAIN_RUNNING_BOOTED; - ignore_value(VIR_STRDUP_QUIET(msg, "finished booting")); + msg =3D g_strdup("finished booting"); } else if (state =3D=3D VIR_DOMAIN_PAUSED && running) { newState =3D VIR_DOMAIN_RUNNING; newReason =3D VIR_DOMAIN_RUNNING_UNPAUSED; - ignore_value(VIR_STRDUP_QUIET(msg, "was unpaused")); + msg =3D g_strdup("was unpaused"); } else if (state =3D=3D VIR_DOMAIN_RUNNING && !running) { if (reason =3D=3D VIR_DOMAIN_PAUSED_SHUTTING_DOWN) { newState =3D VIR_DOMAIN_SHUTDOWN; newReason =3D VIR_DOMAIN_SHUTDOWN_UNKNOWN; - ignore_value(VIR_STRDUP_QUIET(msg, "shutdown")); + msg =3D g_strdup("shutdown"); } else if (reason =3D=3D VIR_DOMAIN_PAUSED_CRASHED) { newState =3D VIR_DOMAIN_CRASHED; newReason =3D VIR_DOMAIN_CRASHED_PANICKED; - ignore_value(VIR_STRDUP_QUIET(msg, "crashed")); + msg =3D g_strdup("crashed"); } else { newState =3D VIR_DOMAIN_PAUSED; newReason =3D reason; diff --git a/src/util/virerror.c b/src/util/virerror.c index b45c53b7df..512b2bc7fe 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -187,8 +187,7 @@ virErrorGenericFailure(virErrorPtr err) err->code =3D VIR_ERR_INTERNAL_ERROR; err->domain =3D VIR_FROM_NONE; err->level =3D VIR_ERR_ERROR; - ignore_value(VIR_STRDUP_QUIET(err->message, - _("An error occurred, but the cause is u= nknown"))); + err->message =3D g_strdup(_("An error occurred, but the cause is unkno= wn")); } =20 =20 @@ -831,7 +830,7 @@ virRaiseErrorFull(const char *filename, * formats the message; drop message on OOM situations */ if (fmt =3D=3D NULL) { - ignore_value(VIR_STRDUP_QUIET(str, _("No error message provided"))= ); + str =3D g_strdup(_("No error message provided")); } else { va_list ap; va_start(ap, fmt); @@ -850,9 +849,9 @@ virRaiseErrorFull(const char *filename, to->code =3D code; to->message =3D str; to->level =3D level; - ignore_value(VIR_STRDUP_QUIET(to->str1, str1)); - ignore_value(VIR_STRDUP_QUIET(to->str2, str2)); - ignore_value(VIR_STRDUP_QUIET(to->str3, str3)); + to->str1 =3D g_strdup(str1); + to->str2 =3D g_strdup(str2); + to->str3 =3D g_strdup(str3); to->int1 =3D int1; to->int2 =3D int2; =20 diff --git a/src/util/virfile.c b/src/util/virfile.c index 2fb389eeb2..15713a58d9 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1264,7 +1264,7 @@ virFileFindMountPoint(const char *type) =20 while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) { if (STREQ(mb.mnt_type, type)) { - ignore_value(VIR_STRDUP_QUIET(ret, mb.mnt_dir)); + ret =3D g_strdup(mb.mnt_dir); goto cleanup; } } @@ -1667,7 +1667,7 @@ virFindFileInPath(const char *file) if (IS_ABSOLUTE_FILE_NAME(file)) { char *ret =3D NULL; if (virFileIsExecutable(file)) - ignore_value(VIR_STRDUP_QUIET(ret, file)); + ret =3D g_strdup(file); return ret; } =20 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 098d2684cc..64e09d7951 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1711,7 +1711,7 @@ virStorageFileChainLookup(virStorageSourcePtr chain, if (*parent && virStorageSourceIsLocalStorage(*parent)) parentDir =3D mdir_name((*parent)->path); else - ignore_value(VIR_STRDUP_QUIET(parentDir, ".")); + parentDir =3D g_strdup("."); =20 if (!parentDir) { virReportOOMError(); diff --git a/src/util/virutil.c b/src/util/virutil.c index 637d19e46c..63071e2fa6 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -523,7 +523,7 @@ virGetHostnameImpl(bool quiet) * string as-is; it's up to callers to check whether "localhost" * is allowed. */ - ignore_value(VIR_STRDUP_QUIET(result, hostname)); + result =3D g_strdup(hostname); goto cleanup; } =20 @@ -539,7 +539,7 @@ virGetHostnameImpl(bool quiet) if (!quiet) VIR_WARN("getaddrinfo failed for '%s': %s", hostname, gai_strerror(r)); - ignore_value(VIR_STRDUP_QUIET(result, hostname)); + result =3D g_strdup(hostname); goto cleanup; } =20 @@ -552,10 +552,10 @@ virGetHostnameImpl(bool quiet) * localhost. Ignore the canonicalized name and just return the * original hostname */ - ignore_value(VIR_STRDUP_QUIET(result, hostname)); + result =3D g_strdup(hostname); else /* Caller frees this string. */ - ignore_value(VIR_STRDUP_QUIET(result, info->ai_canonname)); + result =3D g_strdup(info->ai_canonname); =20 freeaddrinfo(info); =20 diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltes= t.c index e49eef6162..b8e974971a 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -53,8 +53,8 @@ testCommandDryRun(const char *const*args G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { *status =3D 0; - ignore_value(VIR_STRDUP_QUIET(*output, "")); - ignore_value(VIR_STRDUP_QUIET(*error, "")); + *output =3D g_strdup(""); + *error =3D g_strdup(""); } =20 static int testCompareXMLToArgvFiles(const char *xml, diff --git a/tests/virfilemock.c b/tests/virfilemock.c index 6d1153dd9f..00efb820ad 100644 --- a/tests/virfilemock.c +++ b/tests/virfilemock.c @@ -190,7 +190,7 @@ canonicalize_file_name(const char *path) if ((p =3D STRSKIP(path, "/some/symlink"))) ignore_value(virAsprintfQuiet(&ret, "/gluster%s", p)); else - ignore_value(VIR_STRDUP_QUIET(ret, path)); + ret =3D g_strdup(path); =20 return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576189; cv=none; d=zoho.com; s=zohoarc; b=C1wyRCLpC2iPADYdwW2BCsqsPCrS1+nfAPECmdr/vqGMX2LFydcSEA4ElVTuJ4h9Nfre53sbzAZgCW+pSs7LYH9T7bDQ1Vz0EjYRVRGifDJhuTilftEkr04bsNwpxeyRsbpeYizM4b2Dit3hV2KM/YmWlbaeE1n6oL2lG8ucM1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576189; 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=DTwSJZj8edKw25yA5vQBN0rc4dSBH640NKLBEchOcjA=; b=TVDjDKijd7QWeRC+yFQdXVvaC/5jsAoKuJoxiQtDWlXzAzK56qBTS1ykD7eLitSwqdexRj7GkUIHrA6+xizO4/Bx7iqtrtaybPN5OYCb/ppHONy1Cn5ZJSrSaQeVdHvanVQsbrquFWc5ndFwyNBjZmKGZKJCV3GO1IkjzcyBXK4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 157157618997792.56848037686598; Sun, 20 Oct 2019 05:56:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-9gEN8xQpNiqgr4sIs7vPWQ-1; Sun, 20 Oct 2019 08:56:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41D8F801E73; Sun, 20 Oct 2019 12:56:11 +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 1A11A1001DE0; Sun, 20 Oct 2019 12:56:11 +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 C626A1803B4A; Sun, 20 Oct 2019 12:56:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtc1O023350 for ; Sun, 20 Oct 2019 08:55:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0CC471EC; Sun, 20 Oct 2019 12:55:38 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66318196AE for ; Sun, 20 Oct 2019 12:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576188; 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=DTwSJZj8edKw25yA5vQBN0rc4dSBH640NKLBEchOcjA=; b=gDSvZZVk4s6IMuQjp/oAuOc57pCn7g38Y1vDIo2vvICNm+xqoT/LJW3OcfcfN2RoSJTmLk 6G0aUJIUyrsU98G6zZjCx7OQjG6degwiow9T/i4m0MGYUUBMcJC7OyXG0KWPYuIvDuqwWA RQYweimvvEA+Zo95333mpwo3/kzn2AE= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/34] drivers: use g_strdup in probe functions X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 9gEN8xQpNiqgr4sIs7vPWQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The callers expect '1' on a successful probe, so return 1 just like VIR_STRDUP would. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_driver.c | 3 ++- src/libxl/libxl_driver.c | 3 ++- src/lxc/lxc_driver.c | 3 ++- src/openvz/openvz_driver.c | 3 ++- src/vbox/vbox_common.c | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 52e1895052..db3d71f2b2 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -185,7 +185,8 @@ bhyveConnectURIProbe(char **uri) if (bhyve_driver =3D=3D NULL) return 0; =20 - return VIR_STRDUP(*uri, "bhyve:///system"); + *uri =3D g_strdup("bhyve:///system"); + return 1; } =20 =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 14bd62b383..eaa35481ed 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -855,7 +855,8 @@ libxlConnectURIProbe(char **uri) if (libxl_driver =3D=3D NULL) return 0; =20 - return VIR_STRDUP(*uri, "xen:///system"); + *uri =3D g_strdup("xen:///system"); + return 1; } =20 =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 7c2e6cf561..65d17aba8e 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -128,7 +128,8 @@ lxcConnectURIProbe(char **uri) if (lxc_driver =3D=3D NULL) return 0; =20 - return VIR_STRDUP(*uri, "lxc:///system"); + *uri =3D g_strdup("lxc:///system"); + return 1; } =20 =20 diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index d1153edd00..bf399986a7 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1317,7 +1317,8 @@ openvzConnectURIProbe(char **uri) if (access("/proc/vz", W_OK) < 0) return 0; =20 - return VIR_STRDUP(*uri, "openvz:///system"); + *uri =3D g_strdup("openvz:///system"); + return 1; } =20 =20 diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 02c0a894e7..94a79bde64 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -502,7 +502,8 @@ vboxAttachStorageControllers(virDomainDefPtr def, static int vboxConnectURIProbe(char **uri) { - return VIR_STRDUP(*uri, geteuid() ? "vbox:///session" : "vbox:///syste= m"); + *uri =3D g_strdup(geteuid() ? "vbox:///session" : "vbox:///system"); + return 1; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576189; cv=none; d=zoho.com; s=zohoarc; b=PATDTKEbmtUQnF1G6y5XdHjVZv/QnA8KkiQLt4shLaWrP3NTcztAqQ0Ljr+UKpCmbN9/MJRXEDrxkStRvWbG2XdnGOkiRwaclheogezcJMjNOaxWfUcuWlZLZcnDJlkPl6XYZAjqeeJymzkNmFw8gN9e/TRA0+GTkiHzzg4CaFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576189; 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=Onnu2gu6CWtV6oW4+8u0L6aTw6Sj4CUByUUlfbPNZiQ=; b=AMjcM3JGXPoMWg6U7IHk3qtXrPRL3CaBwnrzQXj6qGBW6zouS+LlYJ1l+FJzF0km7PNSeP2xoOCiA/N2qP6PkmLs072A5QcCAHGZcjHpa3C+XcBVPwQlRz1XjjhJEAwEgw9BGOyan6b0ExuCS8AWZBRqHUZ8TF+/D+XhVvChSMs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576189355806.6568945234361; Sun, 20 Oct 2019 05:56:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-67-XM2zcIfSMWifP4qs_VD_0Q-1; Sun, 20 Oct 2019 08:56:21 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0916E100552E; Sun, 20 Oct 2019 12:56:16 +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 D846D6012D; Sun, 20 Oct 2019 12:56:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9AF06180BA9C; Sun, 20 Oct 2019 12:56:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtd48023357 for ; Sun, 20 Oct 2019 08:55:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03C34196AE; Sun, 20 Oct 2019 12:55:39 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 671001EC for ; Sun, 20 Oct 2019 12:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576188; 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=Onnu2gu6CWtV6oW4+8u0L6aTw6Sj4CUByUUlfbPNZiQ=; b=bbVgCKEaEIEVsFo6g4bWFlWKr9hdbmqz3GhpXG7lSnYXs5ivFtfmea02AdZH8sn3RtxZmb NIda+EtC4R+iwFwjKhOF0RPMtNQM+dd0hGKnulKQ6a1n+g4u2EN1c2FKAkyRqw9NxHVurn CnSq6fHHtt3+z6N3gD/g7hA0F7YiWSE= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:25 +0200 Message-Id: <9a14fc54264a5737d37eda7a7977a2d43f36e9b7.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/34] Use g_strdup where VIR_STRDUP's return value was propagated X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: XM2zcIfSMWifP4qs_VD_0Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" All the callers of these functions only check for a negative return value. However, virNetDevOpenvswitchGetVhostuserIfname is documented as returning 1 for openvswitch interfaces so preserve that. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/esx/esx_vi.c | 3 ++- src/esx/esx_vi_types.c | 6 ++---- src/qemu/qemu_alias.c | 21 ++++++++++++++------- src/qemu/qemu_monitor_json.c | 3 ++- src/storage/storage_util.c | 3 ++- src/util/vircgroupv2.c | 6 ++++-- src/util/viriscsi.c | 6 ++++-- src/util/virnuma.c | 3 ++- src/util/virresctrl.c | 3 ++- src/util/virstoragefile.c | 3 ++- src/util/viruri.c | 3 ++- tests/qemuxml2argvmock.c | 6 ++++-- tests/securityselinuxhelper.c | 6 ++++-- 13 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 004434c454..ef37bbf88d 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -2388,7 +2388,8 @@ esxVI_GetVirtualMachineMORef(esxVI_ObjectContent *vir= tualMachine, if (virtualMachine->obj && STREQ(virtualMachine->obj->type, "VirtualMachine") && virtualMachine->obj->value) { - return VIR_STRDUP(*moref, virtualMachine->obj->value); + *moref =3D g_strdup(virtualMachine->obj->value); + return 0; } } return -1; diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index deb6ebd09f..29b1b01b9b 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -1206,10 +1206,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *= src) { ESX_VI_CHECK_ARG_LIST(dest); =20 - if (!src) - return 0; - - return VIR_STRDUP(*dest, src); + *dest =3D g_strdup(src); + return 0; } =20 /* esxVI_String_CastFromAnyType */ diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 5af3725bf5..d4d8eb4252 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -134,7 +134,8 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainD= ef, * hardcoded the name of their single PCI controller as * "pci". */ - return VIR_STRDUP(controller->info.alias, "pci"); + controller->info.alias =3D g_strdup("pci"); + return 0; } else if (controller->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PC= IE_ROOT) { /* The pcie-root controller on Q35 machinetypes uses a * different naming convention ("pcie.0"), because it is @@ -153,18 +154,24 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domai= nDef, * controller hardcoded with id "ide" */ if (qemuDomainHasBuiltinIDE(domainDef) && - controller->idx =3D=3D 0) - return VIR_STRDUP(controller->info.alias, "ide"); + controller->idx =3D=3D 0) { + controller->info.alias =3D g_strdup("ide"); + return 0; + } } else if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_SATA) { /* for any Q35 machine, the first SATA controller is the * integrated one, and it too is hardcoded with id "ide" */ - if (qemuDomainIsQ35(domainDef) && controller->idx =3D=3D 0) - return VIR_STRDUP(controller->info.alias, "ide"); + if (qemuDomainIsQ35(domainDef) && controller->idx =3D=3D 0) { + controller->info.alias =3D g_strdup("ide"); + return 0; + } } else if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB) { /* first USB device is "usb", others are normal "usb%d" */ - if (controller->idx =3D=3D 0) - return VIR_STRDUP(controller->info.alias, "usb"); + if (controller->idx =3D=3D 0) { + controller->info.alias =3D g_strdup("usb"); + return 0; + } } /* all other controllers use the default ${type}${index} naming * scheme for alias/id. diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 4b765da0b1..602a0380d7 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5957,7 +5957,8 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr m= on, return -1; } =20 - return VIR_STRDUP(*result, data_result); + *result =3D g_strdup(data_result); + return 0; } =20 =20 diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index a4c8a5e971..692b3e7a9d 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2072,7 +2072,8 @@ virStorageBackendVolCreateLocal(virStoragePoolObjPtr = pool, } =20 VIR_FREE(vol->key); - return VIR_STRDUP(vol->key, vol->target.path); + vol->key =3D g_strdup(vol->target.path); + return 0; } =20 =20 diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 621ab71eb5..7a64e74c3a 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -146,7 +146,8 @@ static int virCgroupV2CopyMounts(virCgroupPtr group, virCgroupPtr parent) { - return VIR_STRDUP(group->unified.mountPoint, parent->unified.mountPoin= t); + group->unified.mountPoint =3D g_strdup(parent->unified.mountPoint); + return 0; } =20 =20 @@ -189,7 +190,8 @@ virCgroupV2DetectMounts(virCgroupPtr group, =20 VIR_FREE(group->unified.mountPoint); =20 - return VIR_STRDUP(group->unified.mountPoint, mntDir); + group->unified.mountPoint =3D g_strdup(mntDir); + return 0; } =20 =20 diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index dc553e7752..1b143ec61f 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -60,8 +60,10 @@ virISCSIExtractSession(char **const groups, struct virISCSISessionData *data =3D opaque; =20 if (!data->session && - STREQ(groups[1], data->devpath)) - return VIR_STRDUP(data->session, groups[0]); + STREQ(groups[1], data->devpath)) { + data->session =3D g_strdup(groups[0]); + return 0; + } return 0; } =20 diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 8f50634c2a..448833d8d1 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -579,7 +579,8 @@ static int virNumaGetHugePageInfoDir(char **path, int node) { if (node =3D=3D -1) { - return VIR_STRDUP(*path, HUGEPAGES_SYSTEM_PREFIX); + *path =3D g_strdup(HUGEPAGES_SYSTEM_PREFIX); + return 0; } else { return virAsprintf(path, HUGEPAGES_NUMA_PREFIX "node%d/hugepages/", diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index ab650b59b9..e52408ed06 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1388,7 +1388,8 @@ virResctrlSetID(char **resctrlid, return -1; } =20 - return VIR_STRDUP(*resctrlid, id); + *resctrlid =3D g_strdup(id); + return 0; } =20 =20 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 64e09d7951..c13ed9fee5 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4468,7 +4468,8 @@ int virStorageSourceInitiatorCopy(virStorageSourceInitiatorDefPtr dest, const virStorageSourceInitiatorDef *src) { - return VIR_STRDUP(dest->iqn, src->iqn); + dest->iqn =3D g_strdup(src->iqn); + return 0; } =20 void diff --git a/src/util/viruri.c b/src/util/viruri.c index a43fe2afd4..af2e828c28 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -350,7 +350,8 @@ virURIFindAliasMatch(char *const*aliases, const char *a= lias, STREQLEN(*aliases, alias, alias_len)) { VIR_DEBUG("Resolved alias '%s' to '%s'", alias, offset+1); - return VIR_STRDUP(*uri, offset+1); + *uri =3D g_strdup(offset + 1); + return 0; } =20 aliases++; diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 2b9e5e7a49..34e0eb91a6 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -153,7 +153,8 @@ virNetDevTapCreate(char **ifname, return 0; } else { VIR_FREE(*ifname); - return VIR_STRDUP(*ifname, "vnet0"); + *ifname =3D g_strdup("vnet0"); + return 0; } } =20 @@ -229,7 +230,8 @@ int virNetDevOpenvswitchGetVhostuserIfname(const char *path G_GNUC_UNUSED, char **ifname) { - return VIR_STRDUP(*ifname, "vhost-user0"); + *ifname =3D g_strdup("vhost-user0"); + return 1; } =20 int diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c index 6391f67360..814250b731 100644 --- a/tests/securityselinuxhelper.c +++ b/tests/securityselinuxhelper.c @@ -111,7 +111,8 @@ int getcon_raw(security_context_t *context) errno =3D EINVAL; return -1; } - return VIR_STRDUP_QUIET(*context, getenv("FAKE_SELINUX_CONTEXT")); + *context =3D g_strdup(getenv("FAKE_SELINUX_CONTEXT")); + return 0; } =20 int getcon(security_context_t *context) @@ -135,7 +136,8 @@ int getpidcon_raw(pid_t pid, security_context_t *contex= t) errno =3D EINVAL; return -1; } - return VIR_STRDUP_QUIET(*context, getenv("FAKE_SELINUX_CONTEXT")); + *context =3D g_strdup(getenv("FAKE_SELINUX_CONTEXT")); + return 0; } =20 int getpidcon(pid_t pid, security_context_t *context) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576191; cv=none; d=zoho.com; s=zohoarc; b=kv90SS+wodNJ2jqY/LP5hAXCAUN31rhFXNxLvvaXotoof3C1AU1yCQGQUKTRnKe3NSCDpPs7xD9HRnHKxMv+wn2C4IUWRWnPMYJRqVin/yNzT8Slbtoo1j39MNaFsT8/Qqdic/sbpRKTuClu0wyP5DR1f2CVD8aEeIcMKCaAs0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576191; 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=gfKzAszrbPtiuXxBi0D+kurVMh/uxYKXlA+s2ajPuwU=; b=WyD0mDUgxMEI80iCay9O+dA2uyfTGQK1dvulmUlckHdTHayv/eypsz2dWUndcOP3UeTDhNgLSm1Q2GPtZKELxMu6E4qv+EvIYVLscW7qDJ6RpqHYUIzCs6xZjzev3lTnXQLwyUQkUq8sVuNlaF5hbRbHSS5sZFN4Gopm3Px9URY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571576190991524.2319080357219; Sun, 20 Oct 2019 05:56:30 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-kDbwipA8PMKa-nD-E7jnUw-1; Sun, 20 Oct 2019 08:56:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 493AF1800E0E; Sun, 20 Oct 2019 12:56:19 +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 234BA6012D; Sun, 20 Oct 2019 12:56:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DA8EF180BAA3; Sun, 20 Oct 2019 12:56:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCten1023367 for ; Sun, 20 Oct 2019 08:55:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 18A773CC8; Sun, 20 Oct 2019 12:55:40 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6713B196AE for ; Sun, 20 Oct 2019 12:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576189; 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=gfKzAszrbPtiuXxBi0D+kurVMh/uxYKXlA+s2ajPuwU=; b=J641FN+WcYkgsgnj/UuUrdcKjqM1vHD3LYB3elf8ZnB6B/ilRZ7p96R0lskUzpE0vlfO96 boywoqGeXJpIT3rkBUUapg/o7NtHA7XtScy25tBYVecpk6yudsv33nqLfi/yV73IQWRTgi tQ1XX1P2zwLX/AinRwSKYuiM1dEN6Rw= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:26 +0200 Message-Id: <6b53eacf8009a28673ec61ed991dd72cb949f38d.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/34] Use g_strdup to fill in default values X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: kDbwipA8PMKa-nD-E7jnUw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace: if (!s && VIR_STRDUP(s, str) < 0) goto; with: if (!s) s =3D g_strdup(str); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 4 ++-- src/conf/storage_conf.c | 4 ++-- src/esx/esx_util.c | 5 ++--- src/esx/esx_vi_types.c | 4 ++-- src/hyperv/hyperv_util.c | 5 ++--- src/node_device/node_device_udev.c | 4 ++-- src/qemu/qemu_capabilities.c | 5 ++--- src/qemu/qemu_domain.c | 5 ++--- src/qemu/qemu_hotplug.c | 14 ++++++-------- src/remote/remote_driver.c | 4 ++-- src/security/security_apparmor.c | 4 ++-- src/security/security_selinux.c | 9 ++++----- src/storage/storage_backend_logical.c | 4 ++-- src/storage/storage_backend_zfs.c | 4 ++-- src/test/test_driver.c | 4 ++-- src/util/virfile.c | 8 ++++---- src/util/virlease.c | 8 ++------ src/util/virpci.c | 6 ++---- src/util/virtypedparam.c | 4 ++-- src/vmx/vmx.c | 4 ++-- tests/domaincapstest.c | 6 ++---- 21 files changed, 50 insertions(+), 65 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cd9b6ca993..d0dd7b3fa9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13140,8 +13140,8 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, switch (def->type) { case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: path =3D virXPathString("string(./backend/device/@path)", ctxt); - if (!path && VIR_STRDUP(path, VIR_DOMAIN_TPM_DEFAULT_DEVICE) < 0) - goto error; + if (!path) + path =3D g_strdup(VIR_DOMAIN_TPM_DEFAULT_DEVICE); def->data.passthrough.source.data.file.path =3D g_steal_pointer(&p= ath); def->data.passthrough.source.type =3D VIR_DOMAIN_CHR_TYPE_DEV; break; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 9e4978b560..ba3e3ec326 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1414,8 +1414,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, if ((n =3D virXPathNodeSet("./target/features/*", ctxt, &nodes)) <= 0) return NULL; =20 - if (!def->target.compat && VIR_STRDUP(def->target.compat, "1.1") <= 0) - return NULL; + if (!def->target.compat) + def->target.compat =3D g_strdup("1.1"); =20 if (!(def->target.features =3D virBitmapNew(VIR_STORAGE_FILE_FEATU= RE_LAST))) return NULL; diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index d7210375fa..1bed01054b 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -156,9 +156,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIP= tr uri) if (VIR_STRDUP((*parsedUri)->path, uri->path) < 0) goto cleanup; =20 - if (!(*parsedUri)->transport && - VIR_STRDUP((*parsedUri)->transport, "https") < 0) - goto cleanup; + if (!(*parsedUri)->transport) + (*parsedUri)->transport =3D g_strdup("https"); =20 result =3D 0; =20 diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 29b1b01b9b..a32f674740 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -1034,8 +1034,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyT= ype **anyType) (*anyType)->value =3D (char *)xmlNodeListGetString(node->doc, node->children, 1); =20 - if (!(*anyType)->value && VIR_STRDUP((*anyType)->value, "") < 0) - goto failure; + if (!(*anyType)->value) + (*anyType)->value =3D g_strdup(""); =20 #define _DESERIALIZE_NUMBER(_type, _xsdType, _name, _min, _max) \ do { \ diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c index 73b32694a1..3b84713426 100644 --- a/src/hyperv/hyperv_util.c +++ b/src/hyperv/hyperv_util.c @@ -71,9 +71,8 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri) } } =20 - if (!(*parsedUri)->transport && - VIR_STRDUP((*parsedUri)->transport, "https") < 0) - goto cleanup; + if (!(*parsedUri)->transport) + (*parsedUri)->transport =3D g_strdup("https"); =20 result =3D 0; =20 diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index c9449ace9e..84f69da8de 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1307,8 +1307,8 @@ udevSetParent(struct udev_device *device, =20 } while (def->parent =3D=3D NULL && parent_device !=3D NULL); =20 - if (!def->parent && VIR_STRDUP(def->parent, "computer") < 0) - goto cleanup; + if (!def->parent) + def->parent =3D g_strdup("computer"); =20 ret =3D 0; =20 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3ce1556fc2..0377cea51a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3735,9 +3735,8 @@ virQEMUCapsLoadCache(virArch hostArch, =20 if (virXPathBoolean("boolean(./package)", ctxt) > 0) { qemuCaps->package =3D virXPathString("string(./package)", ctxt); - if (!qemuCaps->package && - VIR_STRDUP(qemuCaps->package, "") < 0) - goto cleanup; + if (!qemuCaps->package) + qemuCaps->package =3D g_strdup(""); } =20 if (virXPathBoolean("boolean(./kernelVersion)", ctxt) > 0) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3ef84cc9a6..ab13eebd39 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13339,9 +13339,8 @@ qemuDomainSetupDev(virQEMUDriverConfigPtr cfg, =20 mount_options =3D qemuSecurityGetMountOptions(mgr, vm->def); =20 - if (!mount_options && - VIR_STRDUP(mount_options, "") < 0) - goto cleanup; + if (!mount_options) + mount_options =3D g_strdup(""); =20 /* * tmpfs is limited to 64kb, since we only have device nodes in there diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bf301919cc..5b42bbfd48 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3574,8 +3574,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, } =20 /* ifname: check if it's set in newdev. If not, retain the autogenerat= ed one */ - if (!newdev->ifname && VIR_STRDUP(newdev->ifname, olddev->ifname) < 0) - goto cleanup; + if (!newdev->ifname) + newdev->ifname =3D g_strdup(olddev->ifname); if (STRNEQ_NULLABLE(olddev->ifname, newdev->ifname)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network device tap name")); @@ -3603,9 +3603,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, goto cleanup; } /* grab alias from olddev if not set in newdev */ - if (!newdev->info.alias && - VIR_STRDUP(newdev->info.alias, olddev->info.alias) < 0) - goto cleanup; + if (!newdev->info.alias) + newdev->info.alias =3D g_strdup(olddev->info.alias); =20 /* device alias is checked already in virDomainDefCompatibleDevice */ =20 @@ -3617,9 +3616,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, goto cleanup; } =20 - if (!newdev->info.romfile && - VIR_STRDUP(newdev->info.romfile, olddev->info.romfile) < 0) - goto cleanup; + if (!newdev->info.romfile) + newdev->info.romfile =3D g_strdup(olddev->info.romfile); if (STRNEQ_NULLABLE(olddev->info.romfile, newdev->info.romfile)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network rom file")); diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9228c7d0ed..c22b257197 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1247,8 +1247,8 @@ doRemoteOpen(virConnectPtr conn, break; =20 case REMOTE_DRIVER_TRANSPORT_SSH: - if (!command && VIR_STRDUP(command, "ssh") < 0) - goto failed; + if (!command) + command =3D g_strdup("ssh"); =20 if (!(priv->client =3D virNetClientNewSSH(priv->hostname, port, diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index dd8f7d3808..82826d193c 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -459,8 +459,8 @@ AppArmorGenSecurityLabel(virSecurityManagerPtr mgr G_GN= UC_UNUSED, if (VIR_STRDUP(secdef->imagelabel, profile_name) < 0) goto err; =20 - if (!secdef->model && VIR_STRDUP(secdef->model, SECURITY_APPARMOR_NAME= ) < 0) - goto err; + if (!secdef->model) + secdef->model =3D g_strdup(SECURITY_APPARMOR_NAME); =20 /* Now that we have a label, load the profile into the kernel. */ if (load_profile(mgr, secdef->label, def, NULL, false) < 0) { diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 4988659044..c24a63afd6 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -938,9 +938,8 @@ virSecuritySELinuxGenLabel(virSecurityManagerPtr mgr, if (!seclabel->imagelabel) goto cleanup; =20 - if (!seclabel->model && - VIR_STRDUP(seclabel->model, SECURITY_SELINUX_NAME) < 0) - goto cleanup; + if (!seclabel->model) + seclabel->model =3D g_strdup(SECURITY_SELINUX_NAME); =20 rc =3D 0; =20 @@ -3368,8 +3367,8 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurity= ManagerPtr mgr, return NULL; } =20 - if (!opts && VIR_STRDUP(opts, "") < 0) - return NULL; + if (!opts) + opts =3D g_strdup(""); =20 VIR_DEBUG("imageLabel=3D%s opts=3D%s", secdef ? secdef->imagelabel : "(null)", opts); diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 5de21103f5..80d2dfd0b4 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -325,8 +325,8 @@ virStorageBackendLogicalMakeVol(char **const groups, vol->target.backingStore->type =3D VIR_STORAGE_TYPE_BLOCK; } =20 - if (!vol->key && VIR_STRDUP(vol->key, groups[2]) < 0) - goto cleanup; + if (!vol->key) + vol->key =3D g_strdup(groups[2]); =20 if (virStorageBackendUpdateVolInfo(vol, false, VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < = 0) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 6bfff9f5dd..75edab4b26 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -136,8 +136,8 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, goto cleanup; } =20 - if (!volume->key && VIR_STRDUP(volume->key, tokens[0]) < 0) - goto cleanup; + if (!volume->key) + volume->key =3D g_strdup(tokens[0]); =20 if (volume->target.path =3D=3D NULL) { if (virAsprintf(&volume->target.path, "%s/%s", diff --git a/src/test/test_driver.c b/src/test/test_driver.c index bd095604c7..6af40ee35c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1100,8 +1100,8 @@ testOpenVolumesForPool(const char *file, return -1; } =20 - if (!volDef->key && VIR_STRDUP(volDef->key, volDef->target.path) <= 0) - return -1; + if (!volDef->key) + volDef->key =3D g_strdup(volDef->target.path); =20 if (virStoragePoolObjAddVol(obj, volDef) < 0) return -1; diff --git a/src/util/virfile.c b/src/util/virfile.c index 15713a58d9..6a26d4838c 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4008,12 +4008,12 @@ virFileComparePaths(const char *p1, const char *p2) * comparison. */ ignore_value(virFileResolveLink(p1, &res1)); - if (!res1 && VIR_STRDUP(res1, p1) < 0) - return -1; + if (!res1) + res1 =3D g_strdup(p1); =20 ignore_value(virFileResolveLink(p2, &res2)); - if (!res2 && VIR_STRDUP(res2, p2) < 0) - return -1; + if (!res2) + res2 =3D g_strdup(p2); =20 return STREQ_NULLABLE(res1, res2); } diff --git a/src/util/virlease.c b/src/util/virlease.c index a49bd5b9fb..3d851eb808 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -106,12 +106,8 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_arr= ay_new, /* This is an ipv6 lease */ if ((server_duid_tmp =3D virJSONValueObjectGetString(lease_tmp, "server-duid")= )) { - if (!*server_duid && VIR_STRDUP(*server_duid, server_duid_= tmp) < 0) { - /* Control reaches here when the 'action' is not for an - * ipv6 lease or, for some weird reason the env var - * DNSMASQ_SERVER_DUID wasn't set*/ - return -1; - } + if (!*server_duid) + *server_duid =3D g_strdup(server_duid_tmp); } else { /* Inject server-duid into those ipv6 leases which * didn't have it previously, for example, those diff --git a/src/util/virpci.c b/src/util/virpci.c index 2c54c8baa1..59a93a5e81 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2493,10 +2493,8 @@ virPCIGetNetName(const char *device_link_sysfs_path, * needed because some NIC drivers (e.g. i40e) * implement phys_port_id for PFs, but not for VFs */ - if (!firstEntryName && - VIR_STRDUP(firstEntryName, entry->d_name) < 0) { - goto cleanup; - } + if (!firstEntryName) + firstEntryName =3D g_strdup(entry->d_name); =20 continue; } diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index c2dadfd410..db440611dc 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -240,8 +240,8 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr = param, param->value.s =3D va_arg(ap, char *); } =20 - if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0) - return -1; + if (!param->value.s) + param->value.s =3D g_strdup(""); break; default: virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 7d20351a83..c9a80ba35d 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2659,8 +2659,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, = virDomainNetDefPtr *def) true) < 0) goto cleanup; =20 - if (!networkName && VIR_STRDUP(networkName, "") < 0) - goto cleanup; + if (!networkName) + networkName =3D g_strdup(""); } =20 /* vmx:vnet -> def:data.ifname */ diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index db14114cba..07bc99cc03 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -100,10 +100,8 @@ fillQemuCaps(virDomainCapsPtr domCaps, goto cleanup; } =20 - if (!domCaps->machine && - VIR_STRDUP(domCaps->machine, - virQEMUCapsGetPreferredMachine(qemuCaps)) < 0) - goto cleanup; + if (!domCaps->machine) + domCaps->machine =3D g_strdup(virQEMUCapsGetPreferredMachine(qemuC= aps)); =20 if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps, false, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576175; cv=none; d=zoho.com; s=zohoarc; b=eMzh8iPP+T1u5xaKU2FBK+bd2PauwKteAShe6nQCf0wzwcTSU7lrcM8IafEX6kEixpH0Xi5UFo+v88nacaVy34VqH053qsgEhgSTUj9UEr95Emr4N1YBqOlUzX2YbfLzgMUtvRONkdQXQgJvoHzcL6lfZf7Fbq83S+zCn0XtR38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576175; 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=KcGOF60QO70SfTVe601JciiRqIqIDlg+4gGOAF9/F6k=; b=Kqgk+kqtKbJ7FbjnNgRD9lqp2+XlVEKHr9RZUSUWnol7/L9/dGek9r+HT5Fg3daDaN6iVdKW2jMa7ekTEDeFX0YV7ZYs3tolgX/x27Lp8gppWnXFDCniiZd7mEIcopy3a6M8d9QO27t70bzNP1rfXmAQmAtXJnVfyAiCHDlO2dA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576175504956.0807112452845; Sun, 20 Oct 2019 05:56:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-jfg0AMsIO9qSIxKSOatJ8Q-1; Sun, 20 Oct 2019 08:56:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C10E0800D49; Sun, 20 Oct 2019 12:56:07 +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 9CE196061E; Sun, 20 Oct 2019 12:56:07 +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 638344EDA6; Sun, 20 Oct 2019 12:56:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtfai023377 for ; Sun, 20 Oct 2019 08:55:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 291BF196AE; Sun, 20 Oct 2019 12:55:41 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8523E194B9 for ; Sun, 20 Oct 2019 12:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576174; 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=KcGOF60QO70SfTVe601JciiRqIqIDlg+4gGOAF9/F6k=; b=bp7zrwI32dF3uZCCi2EbmnTA9X4/KlILeXoYkkV3MfKY+OjXCl3tgg7t1PwuApqyfQHGYC IxRNtySjkJ1m8p+KHJPSbLl0BRZ4SaSTbS25Iuau57LIfagZuQw4iMjWtz3tIsJ+GGcgop EYJ1AGEcXmBZ3rBJy8T+OFsnH5KgXCo= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:27 +0200 Message-Id: <2b75625a839567460dc7f4d4ad49f54c4fa8aaa1.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/34] bhyve: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: jfg0AMsIO9qSIxKSOatJ8Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_command.c | 15 +++++--------- src/bhyve/bhyve_conf.c | 3 +-- src/bhyve/bhyve_driver.c | 3 +-- src/bhyve/bhyve_parse_command.c | 35 +++++++++------------------------ 4 files changed, 16 insertions(+), 40 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 912cf99683..8ea76cee2e 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -58,12 +58,10 @@ bhyveBuildNetArgStr(virConnectPtr conn, virDomainNetType actualType =3D virDomainNetGetActualType(net); =20 if (net->model =3D=3D VIR_DOMAIN_NET_MODEL_VIRTIO) { - if (VIR_STRDUP(nic_model, "virtio-net") < 0) - return -1; + nic_model =3D g_strdup("virtio-net"); } else if (net->model =3D=3D VIR_DOMAIN_NET_MODEL_E1000) { if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_NET_E1000) !=3D 0) { - if (VIR_STRDUP(nic_model, "e1000") < 0) - return -1; + nic_model =3D g_strdup("e1000"); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("NIC model 'e1000' is not supported " @@ -77,8 +75,7 @@ bhyveBuildNetArgStr(virConnectPtr conn, } =20 if (actualType =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE) { - if (VIR_STRDUP(brname, virDomainNetGetActualBridgeName(net)) < 0) - goto cleanup; + brname =3D g_strdup(virDomainNetGetActualBridgeName(net)); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Network type %d is not supported"), @@ -90,8 +87,7 @@ bhyveBuildNetArgStr(virConnectPtr conn, STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) || strchr(net->ifname, '%')) { VIR_FREE(net->ifname); - if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0) - goto cleanup; + net->ifname =3D g_strdup(VIR_NET_GENERATED_TAP_PREFIX "%d"); } =20 if (!dryRun) { @@ -117,8 +113,7 @@ bhyveBuildNetArgStr(virConnectPtr conn, if (virNetDevSetOnline(net->ifname, true) !=3D 0) goto cleanup; } else { - if (VIR_STRDUP(realifname, "tap0") < 0) - goto cleanup; + realifname =3D g_strdup("tap0"); } =20 =20 diff --git a/src/bhyve/bhyve_conf.c b/src/bhyve/bhyve_conf.c index 617b25eb8f..ab5d7f467b 100644 --- a/src/bhyve/bhyve_conf.c +++ b/src/bhyve/bhyve_conf.c @@ -56,8 +56,7 @@ virBhyveDriverConfigNew(void) if (!(cfg =3D virObjectNew(virBhyveDriverConfigClass))) return NULL; =20 - if (VIR_STRDUP(cfg->firmwareDir, DATADIR "/uefi-firmware") < 0) - goto error; + cfg->firmwareDir =3D g_strdup(DATADIR "/uefi-firmware"); =20 return cfg; =20 diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index db3d71f2b2..e3d984f69a 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -470,8 +470,7 @@ bhyveDomainGetOSType(virDomainPtr dom) if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)) < 0) - goto cleanup; + ret =3D g_strdup(virDomainOSTypeToString(vm->def->os.type)); =20 cleanup: virDomainObjEndAPI(&vm); diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index 7c72651b00..fa3b881f21 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -299,16 +299,8 @@ bhyveParseBhyveLPCArg(virDomainDefPtr def, goto error; } =20 - if (VIR_STRDUP(chr->source->data.nmdm.master, param) < 0) { - virDomainChrDefFree(chr); - goto error; - } - - if (VIR_STRDUP(chr->source->data.nmdm.slave, chr->source->data.fil= e.path) - < 0) { - virDomainChrDefFree(chr); - goto error; - } + chr->source->data.nmdm.master =3D g_strdup(param); + chr->source->data.nmdm.slave =3D g_strdup(chr->source->data.file.p= ath); =20 /* If the last character of the master is 'A', the slave will be '= B' * and vice versa */ @@ -456,13 +448,11 @@ bhyveParsePCIDisk(virDomainDefPtr def, if (bus =3D=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { idx =3D *nvirtiodisk; *nvirtiodisk +=3D 1; - if (VIR_STRDUP(disk->dst, "vda") < 0) - goto error; + disk->dst =3D g_strdup("vda"); } else if (bus =3D=3D VIR_DOMAIN_DISK_BUS_SATA) { idx =3D *nahcidisk; *nahcidisk +=3D 1; - if (VIR_STRDUP(disk->dst, "sda") < 0) - goto error; + disk->dst =3D g_strdup("sda"); } =20 if (idx > 'z' - 'a') { @@ -507,8 +497,7 @@ bhyveParsePCINet(virDomainDefPtr def, * guess the actual bridge name from the command line, * try to come up with some reasonable defaults */ net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; - if (VIR_STRDUP(net->data.bridge.brname, "virbr0") < 0) - goto error; + net->data.bridge.brname =3D g_strdup("virbr0"); =20 net->model =3D model; net->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -738,8 +727,7 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def, } =20 if (def->name =3D=3D NULL) { - if (VIR_STRDUP(def->name, argv[argc]) < 0) - goto error; + def->name =3D g_strdup(argv[argc]); } else if (STRNEQ(def->name, argv[argc])) { /* the vm name of the loader and the bhyverun command differ, thro= w an * error here */ @@ -819,15 +807,12 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def, if (arguments !=3D 3) { /* Set os.bootloader since virDomainDefFormatInternal will only fo= rmat * the bootloader arguments if os->bootloader is set. */ - if (VIR_STRDUP(def->os.bootloader, argv[0]) < 0) - goto error; - + def->os.bootloader =3D g_strdup(argv[0]); def->os.bootloaderArgs =3D virStringListJoin((const char**) &argv[= 1], " "); } =20 if (def->name =3D=3D NULL) { - if (VIR_STRDUP(def->name, argv[argc]) < 0) - goto error; + def->name =3D g_strdup(argv[argc]); } else if (STRNEQ(def->name, argv[argc])) { /* the vm name of the loader and the bhyverun command differ, thro= w an * error here */ @@ -849,9 +834,7 @@ bhyveParseCustomLoaderCommandLine(virDomainDefPtr def, if (!argv) goto error; =20 - if (VIR_STRDUP(def->os.bootloader, argv[0]) < 0) - goto error; - + def->os.bootloader =3D g_strdup(argv[0]); def->os.bootloaderArgs =3D virStringListJoin((const char**) &argv[1], = " "); =20 return 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576187; cv=none; d=zoho.com; s=zohoarc; b=N6i87LYrgXYur/jRpq89kHze1kso1vwZmKJw0eHXzixPEonzr+4hu1g0XRo+bxS2TOk99ojitqqFpifLovVJ1gnaWOsBePzHPBTIPdNecEtx7mkaAZ+NRGFrga8ZDuapynkJk93L05oVpPl4Hfqv6Zz/3E9/Mwf37zMLOg1Tfpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576187; 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=cu2viLwCzRpfb50QN49er7gpnX1lCVsDt6aIY0NNF40=; b=WIblrsxZxitQ5LB/2rdB7stZPQSVXzUc9Sgr1u6iZF+sr7MXbyYFS4MY25OcXO/p6OpY9BRfZAwBBChGDlpIuOEQDMKdgVmrViJb+K0uwhuG1tOMx1VvCRo4TUp/oaxLvqj367jcrtAb2rEZbhvwjdL7ZRaKfIApKN/sMP0egF8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576187571677.4063192726594; Sun, 20 Oct 2019 05:56:27 -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-329-s94GU_n4M8OGEcvu3EesLQ-1; Sun, 20 Oct 2019 08:56:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9466C800D54; Sun, 20 Oct 2019 12:56:14 +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 6AC6F1000232; Sun, 20 Oct 2019 12:56:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 239F74EE6A; Sun, 20 Oct 2019 12:56:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtgla023389 for ; Sun, 20 Oct 2019 08:55:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 366DC1EC; Sun, 20 Oct 2019 12:55:42 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C3EF196AE for ; Sun, 20 Oct 2019 12:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576186; 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=cu2viLwCzRpfb50QN49er7gpnX1lCVsDt6aIY0NNF40=; b=Eurcvfwlr1HzIiS+5ecZybQBxOEoQO9vx4jGl+5Yw0iigJx2Ga+3FDBIN29nh208VV0g8W Dtgs2HaBueV9jwgodV+sWvhkxr5Movif26hfvLnsFGbFJb0jf6V8q+7dQBf3jIyCqcPBee 44evdVywCrmm6PMHoWL7Br4szak1IV4= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:28 +0200 Message-Id: <8159f20b2087365f254965634ae73beee4c10bbe.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/34] conf: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: s94GU_n4M8OGEcvu3EesLQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/conf/capabilities.c | 33 +++---- src/conf/checkpoint_conf.c | 9 +- src/conf/cpu_conf.c | 15 ++-- src/conf/domain_audit.c | 15 +--- src/conf/domain_capabilities.c | 8 +- src/conf/domain_conf.c | 143 ++++++++++-------------------- src/conf/domain_event.c | 103 ++++++--------------- src/conf/domain_nwfilter.c | 14 ++- src/conf/networkcommon_conf.c | 3 +- src/conf/node_device_conf.c | 14 +-- src/conf/node_device_util.c | 3 +- src/conf/nwfilter_conf.c | 4 +- src/conf/nwfilter_ipaddrmap.c | 3 +- src/conf/nwfilter_params.c | 12 +-- src/conf/object_event.c | 10 +-- src/conf/snapshot_conf.c | 9 +- src/conf/storage_conf.c | 13 ++- src/conf/virchrdev.c | 6 +- src/conf/virdomainmomentobjlist.c | 7 +- src/conf/virdomainobjlist.c | 10 +-- src/conf/virinterfaceobj.c | 11 +-- src/conf/virnetworkobj.c | 7 +- src/conf/virnodedeviceobj.c | 10 +-- src/conf/virnwfilterbindingdef.c | 12 +-- src/conf/virnwfilterobj.c | 11 +-- src/conf/virstorageobj.c | 28 ++---- 26 files changed, 153 insertions(+), 360 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 1781c1df0a..697d464fe9 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -288,8 +288,7 @@ virCapabilitiesAddHostFeature(virCapsPtr caps, caps->host.nfeatures, 1) < 0) return -1; =20 - if (VIR_STRDUP(caps->host.features[caps->host.nfeatures], name) < 0) - return -1; + caps->host.features[caps->host.nfeatures] =3D g_strdup(name); caps->host.nfeatures++; =20 return 0; @@ -310,8 +309,7 @@ virCapabilitiesAddHostMigrateTransport(virCapsPtr caps, caps->host.nmigrateTrans, 1) < 0) return -1; =20 - if (VIR_STRDUP(caps->host.migrateTrans[caps->host.nmigrateTrans], name= ) < 0) - return -1; + caps->host.migrateTrans[caps->host.nmigrateTrans] =3D g_strdup(name); caps->host.nmigrateTrans++; =20 return 0; @@ -328,8 +326,7 @@ int virCapabilitiesSetNetPrefix(virCapsPtr caps, const char *prefix) { - if (VIR_STRDUP(caps->host.netprefix, prefix) < 0) - return -1; + caps->host.netprefix =3D g_strdup(prefix); =20 return 0; } @@ -423,11 +420,11 @@ virCapabilitiesAllocMachines(const char *const *names= , int nnames) return NULL; =20 for (i =3D 0; i < nnames; i++) { - if (VIR_ALLOC(machines[i]) < 0 || - VIR_STRDUP(machines[i]->name, names[i]) < 0) { + if (VIR_ALLOC(machines[i]) < 0) { virCapabilitiesFreeMachines(machines, nnames); return NULL; } + machines[i]->name =3D g_strdup(names[i]); } =20 return machines; @@ -486,9 +483,8 @@ virCapabilitiesAddGuest(virCapsPtr caps, guest->arch.id =3D arch; guest->arch.wordsize =3D virArchGetWordSize(arch); =20 - if (VIR_STRDUP(guest->arch.defaultInfo.emulator, emulator) < 0 || - VIR_STRDUP(guest->arch.defaultInfo.loader, loader) < 0) - goto error; + guest->arch.defaultInfo.emulator =3D g_strdup(emulator); + guest->arch.defaultInfo.loader =3D g_strdup(loader); =20 if (VIR_RESIZE_N(caps->guests, caps->nguests_max, caps->nguests, 1) < 0) @@ -534,9 +530,8 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest, goto error; =20 dom->type =3D hvtype; - if (VIR_STRDUP(dom->info.emulator, emulator) < 0 || - VIR_STRDUP(dom->info.loader, loader) < 0) - goto error; + dom->info.emulator =3D g_strdup(emulator); + dom->info.loader =3D g_strdup(loader); =20 if (VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max, guest->arch.ndomains, 1) < 0) @@ -577,8 +572,7 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest, if (VIR_ALLOC(feature) < 0) goto no_memory; =20 - if (VIR_STRDUP(feature->name, name) < 0) - goto no_memory; + feature->name =3D g_strdup(name); feature->defaultOn =3D defaultOn; feature->toggle =3D toggle; =20 @@ -612,11 +606,8 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSec= ModelPtr secmodel, if (type =3D=3D NULL || label =3D=3D NULL) return -1; =20 - if (VIR_STRDUP(t, type) < 0) - goto no_memory; - - if (VIR_STRDUP(l, label) < 0) - goto no_memory; + t =3D g_strdup(type); + l =3D g_strdup(label); =20 if (VIR_EXPAND_N(secmodel->labels, secmodel->nlabels, 1) < 0) goto no_memory; diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index b254dce7fd..4fa743e0b0 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -275,8 +275,7 @@ virDomainCheckpointDefAssignBitmapNames(virDomainCheckp= ointDefPtr def) disk->bitmap) continue; =20 - if (VIR_STRDUP(disk->bitmap, def->parent.name) < 0) - return -1; + disk->bitmap =3D g_strdup(def->parent.name); } =20 return 0; @@ -365,8 +364,7 @@ virDomainCheckpointAlignDisks(virDomainCheckpointDefPtr= def) =20 if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) { VIR_FREE(disk->name); - if (VIR_STRDUP(disk->name, def->parent.dom->disks[idx]->dst) <= 0) - goto cleanup; + disk->name =3D g_strdup(def->parent.dom->disks[idx]->dst); } } =20 @@ -382,8 +380,7 @@ virDomainCheckpointAlignDisks(virDomainCheckpointDefPtr= def) if (virBitmapIsBitSet(map, i)) continue; disk =3D &def->disks[ndisks++]; - if (VIR_STRDUP(disk->name, def->parent.dom->disks[i]->dst) < 0) - goto cleanup; + disk->name =3D g_strdup(def->parent.dom->disks[i]->dst); disk->idx =3D i; =20 /* Don't checkpoint empty or readonly drives */ diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 80b7687b86..1d9feb2f0a 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -136,11 +136,12 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst, size_t i; size_t n; =20 - if (VIR_STRDUP(dst->model, src->model) < 0 || - VIR_STRDUP(dst->vendor, src->vendor) < 0 || - VIR_STRDUP(dst->vendor_id, src->vendor_id) < 0 || - VIR_ALLOC_N(dst->features, src->nfeatures) < 0) + if (VIR_ALLOC_N(dst->features, src->nfeatures) < 0) return -1; + + dst->model =3D g_strdup(src->model); + dst->vendor =3D g_strdup(src->vendor); + dst->vendor_id =3D g_strdup(src->vendor_id); dst->microcodeVersion =3D src->microcodeVersion; dst->nfeatures_max =3D src->nfeatures; dst->nfeatures =3D 0; @@ -161,8 +162,7 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst, dst->features[n].policy =3D src->features[i].policy; } =20 - if (VIR_STRDUP(dst->features[n].name, src->features[i].name) < 0) - return -1; + dst->features[n].name =3D g_strdup(src->features[i].name); } =20 return 0; @@ -896,8 +896,7 @@ virCPUDefUpdateFeatureInternal(virCPUDefPtr def, def->nfeatures, 1) < 0) return -1; =20 - if (VIR_STRDUP(def->features[def->nfeatures].name, name) < 0) - return -1; + def->features[def->nfeatures].name =3D g_strdup(name); =20 def->features[def->nfeatures].policy =3D policy; def->nfeatures++; diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index e455661e4f..2ae39e3698 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -414,16 +414,10 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHo= stdevDefPtr hostdev, break; } case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: - if (VIR_STRDUP_QUIET(address, hostsrc->wwpn) < 0) { - VIR_WARN("OOM while encoding audit message"); - goto cleanup; - } + address =3D g_strdup(hostsrc->wwpn); break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: - if (VIR_STRDUP_QUIET(address, mdevsrc->uuidstr) < 0) { - VIR_WARN("OOM while encoding audit message"); - goto cleanup; - } + address =3D g_strdup(mdevsrc->uuidstr); break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: default: @@ -518,10 +512,7 @@ virDomainAuditRedirdev(virDomainObjPtr vm, virDomainRe= dirdevDefPtr redirdev, =20 switch (redirdev->bus) { case VIR_DOMAIN_REDIRDEV_BUS_USB: - if (VIR_STRDUP_QUIET(address, "USB redirdev") < 0) { - VIR_WARN("OOM while encoding audit message"); - goto cleanup; - } + address =3D g_strdup("USB redirdev"); break; default: VIR_WARN("Unexpected redirdev bus while encoding audit message: %d= ", diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 43a778a505..3c4c7fd6d1 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -124,16 +124,12 @@ virDomainCapsNew(const char *path, if (!(caps =3D virObjectLockableNew(virDomainCapsClass))) return NULL; =20 - if (VIR_STRDUP(caps->path, path) < 0 || - VIR_STRDUP(caps->machine, machine) < 0) - goto error; + caps->path =3D g_strdup(path); + caps->machine =3D g_strdup(machine); caps->arch =3D arch; caps->virttype =3D virttype; =20 return caps; - error: - virObjectUnref(caps); - return NULL; } =20 =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d0dd7b3fa9..afa997b381 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2548,30 +2548,19 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr = dest, case VIR_DOMAIN_CHR_TYPE_PIPE: if (src->type =3D=3D VIR_DOMAIN_CHR_TYPE_FILE) dest->data.file.append =3D src->data.file.append; - if (VIR_STRDUP(dest->data.file.path, src->data.file.path) < 0) - return -1; + dest->data.file.path =3D g_strdup(src->data.file.path); break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: - if (VIR_STRDUP(dest->data.udp.bindHost, src->data.udp.bindHost) < = 0) - return -1; - - if (VIR_STRDUP(dest->data.udp.bindService, src->data.udp.bindServi= ce) < 0) - return -1; - - if (VIR_STRDUP(dest->data.udp.connectHost, src->data.udp.connectHo= st) < 0) - return -1; - - if (VIR_STRDUP(dest->data.udp.connectService, src->data.udp.connec= tService) < 0) - return -1; + dest->data.udp.bindHost =3D g_strdup(src->data.udp.bindHost); + dest->data.udp.bindService =3D g_strdup(src->data.udp.bindService); + dest->data.udp.connectHost =3D g_strdup(src->data.udp.connectHost); + dest->data.udp.connectService =3D g_strdup(src->data.udp.connectSe= rvice); break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: - if (VIR_STRDUP(dest->data.tcp.host, src->data.tcp.host) < 0) - return -1; - - if (VIR_STRDUP(dest->data.tcp.service, src->data.tcp.service) < 0) - return -1; + dest->data.tcp.host =3D g_strdup(src->data.tcp.host); + dest->data.tcp.service =3D g_strdup(src->data.tcp.service); =20 dest->data.tcp.haveTLS =3D src->data.tcp.haveTLS; dest->data.tcp.tlsFromConfig =3D src->data.tcp.tlsFromConfig; @@ -2581,18 +2570,15 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr = dest, break; =20 case VIR_DOMAIN_CHR_TYPE_UNIX: - if (VIR_STRDUP(dest->data.nix.path, src->data.nix.path) < 0) - return -1; + dest->data.nix.path =3D g_strdup(src->data.nix.path); =20 dest->data.nix.reconnect.enabled =3D src->data.nix.reconnect.enabl= ed; dest->data.nix.reconnect.timeout =3D src->data.nix.reconnect.timeo= ut; break; =20 case VIR_DOMAIN_CHR_TYPE_NMDM: - if (VIR_STRDUP(dest->data.nmdm.master, src->data.nmdm.master) < 0) - return -1; - if (VIR_STRDUP(dest->data.nmdm.slave, src->data.nmdm.slave) < 0) - return -1; + dest->data.nmdm.master =3D g_strdup(src->data.nmdm.master); + dest->data.nmdm.slave =3D g_strdup(src->data.nmdm.slave); =20 break; } @@ -5066,8 +5052,7 @@ virDomainRNGDefPostParse(virDomainRNGDefPtr rng) /* set default path for virtio-rng "random" backend to /dev/random */ if (rng->backend =3D=3D VIR_DOMAIN_RNG_BACKEND_RANDOM && !rng->source.file) { - if (VIR_STRDUP(rng->source.file, "/dev/random") < 0) - return -1; + rng->source.file =3D g_strdup("/dev/random"); } =20 return 0; @@ -8854,8 +8839,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, /* Copy model from host. */ VIR_DEBUG("Found seclabel without a model, using '%s'", host->secModels[0].model); - if (VIR_STRDUP(def->seclabels[0]->model, host->secModels[0].mo= del) < 0) - goto error; + def->seclabels[0]->model =3D g_strdup(host->secModels[0].model= ); =20 if (STREQ(def->seclabels[0]->model, "none") && flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) { @@ -9188,8 +9172,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, =20 src->volume =3D src->path; =20 - if (VIR_STRDUP(src->path, tmp + 1) < 0) - return -1; + src->path =3D g_strdup(tmp + 1); =20 tmp[0] =3D '\0'; } @@ -11244,9 +11227,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node, */ addrtype =3D virXPathString("string(./source/address/@type)", ctxt= ); /* if not explicitly stated, source/vendor implies usb device */ - if (!addrtype && virXPathNode("./source/vendor", ctxt) && - VIR_STRDUP(addrtype, "usb") < 0) - goto error; + if (!addrtype && virXPathNode("./source/vendor", ctxt)) + addrtype =3D g_strdup("usb"); hostdev->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, hostdev, flags) < 0) { @@ -11877,9 +11859,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlop= t, */ addrtype =3D virXPathString("string(./source/address/@type)", ctxt= ); /* if not explicitly stated, source/vendor implies usb device */ - if (!addrtype && virXPathNode("./source/vendor", ctxt) && - VIR_STRDUP(addrtype, "usb") < 0) - goto error; + if (!addrtype && virXPathNode("./source/vendor", ctxt)) + addrtype =3D g_strdup("usb"); hostdev->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, hostdev, flags) < 0) { @@ -14972,8 +14953,7 @@ virSysinfoSystemParseXML(xmlNodePtr node, * properly so that it's used correctly later. */ virUUIDFormat(uuidbuf, uuidstr); - if (VIR_STRDUP(def->uuid, uuidstr) < 0) - goto cleanup; + def->uuid =3D g_strdup(uuidstr); } def->sku =3D virXPathString("string(entry[@name=3D'sku'])", ctxt); @@ -17986,8 +17966,7 @@ virDomainDefGetDefaultEmulator(virDomainDefPtr def, def->os.arch, def->virtType, NULL, NULL))) return NULL; =20 - if (VIR_STRDUP(retemu, capsdata->emulator) < 0) - return NULL; + retemu =3D g_strdup(capsdata->emulator); =20 return retemu; } @@ -19011,9 +18990,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, _("No data supplied for element")= ); return -1; } - if (VIR_STRDUP(def->os.initargv[i], - (const char*) nodes[i]->children->content) < 0) - return -1; + def->os.initargv[i] =3D g_strdup((const char *)nodes[i]->child= ren->content); } def->os.initargv[n] =3D NULL; VIR_FREE(nodes); @@ -19042,9 +19019,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, return -1; =20 def->os.initenv[i]->name =3D name; - if (VIR_STRDUP(def->os.initenv[i]->value, - (const char*) nodes[i]->children->content) < 0) - return -1; + def->os.initenv[i]->value =3D g_strdup((const char *)nodes[i]-= >children->content); } def->os.initenv[n] =3D NULL; VIR_FREE(nodes); @@ -19407,8 +19382,7 @@ virDomainResctrlMonDefParse(virDomainDefPtr def, if (rv =3D=3D 1) { const char *alloc_id =3D virResctrlAllocGetID(resctrl->alloc); =20 - if (VIR_STRDUP(id, alloc_id) < 0) - goto cleanup; + id =3D g_strdup(alloc_id); } else { if (!(tmp =3D virBitmapFormat(domresmon->vcpus))) goto cleanup; @@ -19633,9 +19607,8 @@ virDomainDefParseCaps(virDomainDefPtr def, } else { if (!def->os.arch) def->os.arch =3D capsdata->arch; - if ((!def->os.machine && - VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0)) - return -1; + if (!def->os.machine) + def->os.machine =3D g_strdup(capsdata->machinetype); } =20 return 0; @@ -29809,8 +29782,7 @@ virDomainNetSetModelString(virDomainNetDefPtr net, return -1; } =20 - if (VIR_STRDUP(net->modelstr, model) < 0) - return -1; + net->modelstr =3D g_strdup(model); return 0; } =20 @@ -29847,8 +29819,7 @@ virDomainGraphicsListenAppendAddress(virDomainGraph= icsDefPtr def, =20 glisten.type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; =20 - if (VIR_STRDUP(glisten.address, address) < 0) - goto error; + glisten.address =3D g_strdup(address); =20 if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten) < 0) goto error; @@ -29870,8 +29841,7 @@ virDomainGraphicsListenAppendSocket(virDomainGraphi= csDefPtr def, =20 glisten.type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; =20 - if (VIR_STRDUP(glisten.socket, socketPath) < 0) - goto error; + glisten.socket =3D g_strdup(socketPath); =20 if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten) < 0) goto error; @@ -30165,13 +30135,11 @@ virDomainObjGetMetadata(virDomainObjPtr vm, =20 switch ((virDomainMetadataType) type) { case VIR_DOMAIN_METADATA_DESCRIPTION: - if (VIR_STRDUP(ret, def->description) < 0) - return NULL; + ret =3D g_strdup(def->description); break; =20 case VIR_DOMAIN_METADATA_TITLE: - if (VIR_STRDUP(ret, def->title) < 0) - return NULL; + ret =3D g_strdup(def->title); break; =20 case VIR_DOMAIN_METADATA_ELEMENT: @@ -30216,16 +30184,16 @@ virDomainDefSetMetadata(virDomainDefPtr def, =20 switch ((virDomainMetadataType) type) { case VIR_DOMAIN_METADATA_DESCRIPTION: - if (STRNEQ_NULLABLE(metadata, "") && VIR_STRDUP(tmp, metadata) < 0) - goto cleanup; + if (STRNEQ_NULLABLE(metadata, "")) + tmp =3D g_strdup(metadata); =20 VIR_FREE(def->description); def->description =3D tmp; break; =20 case VIR_DOMAIN_METADATA_TITLE: - if (STRNEQ_NULLABLE(metadata, "") && VIR_STRDUP(tmp, metadata) < 0) - goto cleanup; + if (STRNEQ_NULLABLE(metadata, "")) + tmp =3D g_strdup(metadata); =20 VIR_FREE(def->title); def->title =3D tmp; @@ -30511,8 +30479,7 @@ virDomainDiskSetBlockIOTune(virDomainDiskDefPtr dis= k, { char *tmp_group =3D NULL; =20 - if (VIR_STRDUP(tmp_group, info->group_name) < 0) - return -1; + tmp_group =3D g_strdup(info->group_name); =20 VIR_FREE(disk->blkdeviotune.group_name); disk->blkdeviotune =3D *info; @@ -30640,11 +30607,9 @@ virDomainNetDefToNetworkPort(virDomainDefPtr dom, } =20 memcpy(port->owneruuid, dom->uuid, VIR_UUID_BUFLEN); - if (VIR_STRDUP(port->ownername, dom->name) < 0) - return NULL; + port->ownername =3D g_strdup(dom->name); =20 - if (VIR_STRDUP(port->group, iface->data.network.portgroup) < 0) - return NULL; + port->group =3D g_strdup(iface->data.network.portgroup); =20 memcpy(&port->mac, &iface->mac, VIR_MAC_BUFLEN); =20 @@ -30684,25 +30649,19 @@ virDomainNetDefActualFromNetworkPort(virDomainNet= DefPtr iface, =20 case VIR_NETWORK_PORT_PLUG_TYPE_NETWORK: actual->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; - if (VIR_STRDUP(actual->data.bridge.brname, - port->plug.bridge.brname) < 0) - goto error; + actual->data.bridge.brname =3D g_strdup(port->plug.bridge.brname); actual->data.bridge.macTableManager =3D port->plug.bridge.macTable= Manager; break; =20 case VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE: actual->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; - if (VIR_STRDUP(actual->data.bridge.brname, - port->plug.bridge.brname) < 0) - goto error; + actual->data.bridge.brname =3D g_strdup(port->plug.bridge.brname); actual->data.bridge.macTableManager =3D port->plug.bridge.macTable= Manager; break; =20 case VIR_NETWORK_PORT_PLUG_TYPE_DIRECT: actual->type =3D VIR_DOMAIN_NET_TYPE_DIRECT; - if (VIR_STRDUP(actual->data.direct.linkdev, - port->plug.direct.linkdev) < 0) - goto error; + actual->data.direct.linkdev =3D g_strdup(port->plug.direct.linkdev= ); actual->data.direct.mode =3D port->plug.direct.mode; break; =20 @@ -30810,36 +30769,28 @@ virDomainNetDefActualToNetworkPort(virDomainDefPt= r dom, } =20 memcpy(port->owneruuid, dom->uuid, VIR_UUID_BUFLEN); - if (VIR_STRDUP(port->ownername, dom->name) < 0) - return NULL; + port->ownername =3D g_strdup(dom->name); =20 - if (VIR_STRDUP(port->group, iface->data.network.portgroup) < 0) - return NULL; + port->group =3D g_strdup(iface->data.network.portgroup); =20 memcpy(&port->mac, &iface->mac, VIR_MAC_BUFLEN); =20 switch (virDomainNetGetActualType(iface)) { case VIR_DOMAIN_NET_TYPE_NETWORK: port->plugtype =3D VIR_NETWORK_PORT_PLUG_TYPE_NETWORK; - if (VIR_STRDUP(port->plug.bridge.brname, - actual->data.bridge.brname) < 0) - return NULL; + port->plug.bridge.brname =3D g_strdup(actual->data.bridge.brname); port->plug.bridge.macTableManager =3D actual->data.bridge.macTable= Manager; break; =20 case VIR_DOMAIN_NET_TYPE_BRIDGE: port->plugtype =3D VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE; - if (VIR_STRDUP(port->plug.bridge.brname, - actual->data.bridge.brname) < 0) - return NULL; + port->plug.bridge.brname =3D g_strdup(actual->data.bridge.brname); port->plug.bridge.macTableManager =3D actual->data.bridge.macTable= Manager; break; =20 case VIR_DOMAIN_NET_TYPE_DIRECT: port->plugtype =3D VIR_NETWORK_PORT_PLUG_TYPE_DIRECT; - if (VIR_STRDUP(port->plug.direct.linkdev, - actual->data.direct.linkdev) < 0) - return NULL; + port->plug.direct.linkdev =3D g_strdup(actual->data.direct.linkdev= ); port->plug.direct.mode =3D actual->data.direct.mode; break; =20 @@ -31235,8 +31186,7 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDe= fPtr def, if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0) goto cleanup; =20 - if (VIR_STRDUP(def->src->hosts[0].name, pooldef->source.hosts[0].name)= < 0) - goto cleanup; + def->src->hosts[0].name =3D g_strdup(pooldef->source.hosts[0].name); =20 def->src->hosts[0].port =3D pooldef->source.hosts[0].port ? pooldef->source.hosts[0].port : 3260; @@ -31308,8 +31258,7 @@ virDomainDiskTranslateISCSIDirect(virDomainDiskDefP= tr def, if (def->src->auth && !def->src->auth->secrettype) { const char *secrettype =3D virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI); - if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0) - return -1; + def->src->auth->secrettype =3D g_strdup(secrettype); } =20 if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0) diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index c0dcf8f716..644f6eb595 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -753,12 +753,9 @@ virDomainEventIOErrorNewFromDomImpl(int event, return NULL; =20 ev->action =3D action; - if (VIR_STRDUP(ev->srcPath, srcPath) < 0 || - VIR_STRDUP(ev->devAlias, devAlias) < 0 || - VIR_STRDUP(ev->reason, reason) < 0) { - virObjectUnref(ev); - ev =3D NULL; - } + ev->srcPath =3D g_strdup(srcPath); + ev->devAlias =3D g_strdup(devAlias); + ev->reason =3D g_strdup(reason); =20 return (virObjectEventPtr)ev; } @@ -782,12 +779,9 @@ virDomainEventIOErrorNewFromObjImpl(int event, return NULL; =20 ev->action =3D action; - if (VIR_STRDUP(ev->srcPath, srcPath) < 0 || - VIR_STRDUP(ev->devAlias, devAlias) < 0 || - VIR_STRDUP(ev->reason, reason) < 0) { - virObjectUnref(ev); - ev =3D NULL; - } + ev->srcPath =3D g_strdup(srcPath); + ev->devAlias =3D g_strdup(devAlias); + ev->reason =3D g_strdup(reason); =20 return (virObjectEventPtr)ev; } @@ -858,10 +852,7 @@ virDomainEventGraphicsNewFromDom(virDomainPtr dom, return NULL; =20 ev->phase =3D phase; - if (VIR_STRDUP(ev->authScheme, authScheme) < 0) { - virObjectUnref(ev); - return NULL; - } + ev->authScheme =3D g_strdup(authScheme); ev->local =3D local; ev->remote =3D remote; ev->subject =3D subject; @@ -889,10 +880,7 @@ virDomainEventGraphicsNewFromObj(virDomainObjPtr obj, return NULL; =20 ev->phase =3D phase; - if (VIR_STRDUP(ev->authScheme, authScheme) < 0) { - virObjectUnref(ev); - return NULL; - } + ev->authScheme =3D g_strdup(authScheme); ev->local =3D local; ev->remote =3D remote; ev->subject =3D subject; @@ -919,10 +907,7 @@ virDomainEventBlockJobNew(int event, id, name, uuid))) return NULL; =20 - if (VIR_STRDUP(ev->disk, disk) < 0) { - virObjectUnref(ev); - return NULL; - } + ev->disk =3D g_strdup(disk); ev->type =3D type; ev->status =3D status; =20 @@ -1024,22 +1009,13 @@ virDomainEventDiskChangeNew(int id, id, name, uuid))) return NULL; =20 - if (VIR_STRDUP(ev->devAlias, devAlias) < 0) - goto error; - - if (VIR_STRDUP(ev->oldSrcPath, oldSrcPath) < 0) - goto error; - - if (VIR_STRDUP(ev->newSrcPath, newSrcPath) < 0) - goto error; + ev->devAlias =3D g_strdup(devAlias); + ev->oldSrcPath =3D g_strdup(oldSrcPath); + ev->newSrcPath =3D g_strdup(newSrcPath); =20 ev->reason =3D reason; =20 return (virObjectEventPtr)ev; - - error: - virObjectUnref(ev); - return NULL; } =20 virObjectEventPtr @@ -1083,16 +1059,11 @@ virDomainEventTrayChangeNew(int id, id, name, uuid))) return NULL; =20 - if (VIR_STRDUP(ev->devAlias, devAlias) < 0) - goto error; + ev->devAlias =3D g_strdup(devAlias); =20 ev->reason =3D reason; =20 return (virObjectEventPtr)ev; - - error: - virObjectUnref(ev); - return NULL; } =20 virObjectEventPtr @@ -1275,14 +1246,9 @@ virDomainEventDeviceRemovedNew(int id, id, name, uuid))) return NULL; =20 - if (VIR_STRDUP(ev->devAlias, devAlias) < 0) - goto error; + ev->devAlias =3D g_strdup(devAlias); =20 return (virObjectEventPtr)ev; - - error: - virObjectUnref(ev); - return NULL; } =20 virObjectEventPtr @@ -1317,14 +1283,9 @@ virDomainEventDeviceAddedNew(int id, id, name, uuid))) return NULL; =20 - if (VIR_STRDUP(ev->devAlias, devAlias) < 0) - goto error; + ev->devAlias =3D g_strdup(devAlias); =20 return (virObjectEventPtr)ev; - - error: - virObjectUnref(ev); - return NULL; } =20 virObjectEventPtr @@ -1360,14 +1321,9 @@ virDomainEventDeviceRemovalFailedNew(int id, id, name, uuid))) return NULL; =20 - if (VIR_STRDUP(ev->devAlias, devAlias) < 0) - goto error; + ev->devAlias =3D g_strdup(devAlias); =20 return (virObjectEventPtr)ev; - - error: - virObjectUnref(ev); - return NULL; } =20 virObjectEventPtr @@ -1587,14 +1543,10 @@ virDomainEventMetadataChangeNew(int id, return NULL; =20 ev->type =3D type; - if (nsuri && VIR_STRDUP(ev->nsuri, nsuri) < 0) - goto error; + if (nsuri) + ev->nsuri =3D g_strdup(nsuri); =20 return (virObjectEventPtr)ev; - - error: - virObjectUnref(ev); - return NULL; } =20 virObjectEventPtr @@ -1635,11 +1587,8 @@ virDomainEventBlockThresholdNew(int id, id, name, uuid))) return NULL; =20 - if (VIR_STRDUP(ev->dev, dev) < 0 || - VIR_STRDUP(ev->path, path) < 0) { - virObjectUnref(ev); - return NULL; - } + ev->dev =3D g_strdup(dev); + ev->path =3D g_strdup(path); ev->threshold =3D threshold; ev->excess =3D excess; =20 @@ -1986,12 +1935,13 @@ virDomainQemuMonitorEventNew(int id, return NULL; =20 /* event is mandatory, details are optional */ - if (VIR_STRDUP(ev->event, event) <=3D 0) + if (!event) goto error; + + ev->event =3D g_strdup(event); ev->seconds =3D seconds; ev->micros =3D micros; - if (VIR_STRDUP(ev->details, details) < 0) - goto error; + ev->details =3D g_strdup(details); =20 return (virObjectEventPtr)ev; =20 @@ -2318,9 +2268,8 @@ virDomainQemuMonitorEventStateRegisterID(virConnectPt= r conn, VIR_FREE(data); return -1; } - } else if (VIR_STRDUP(data->event, event) < 0) { - VIR_FREE(data); - return -1; + } else { + data->event =3D g_strdup(event); } } data->opaque =3D opaque; diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c index 495fafcd61..a72db6f876 100644 --- a/src/conf/domain_nwfilter.c +++ b/src/conf/domain_nwfilter.c @@ -47,22 +47,18 @@ virNWFilterBindingDefForNet(const char *vmname, if (VIR_ALLOC(ret) < 0) return NULL; =20 - if (VIR_STRDUP(ret->ownername, vmname) < 0) - goto error; + ret->ownername =3D g_strdup(vmname); =20 memcpy(ret->owneruuid, vmuuid, sizeof(ret->owneruuid)); =20 - if (VIR_STRDUP(ret->portdevname, net->ifname) < 0) - goto error; + ret->portdevname =3D g_strdup(net->ifname); =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT && - VIR_STRDUP(ret->linkdevname, net->data.direct.linkdev) < 0) - goto error; + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT) + ret->linkdevname =3D g_strdup(net->data.direct.linkdev); =20 ret->mac =3D net->mac; =20 - if (VIR_STRDUP(ret->filter, net->filter) < 0) - goto error; + ret->filter =3D g_strdup(net->filter); =20 if (!(ret->filterparams =3D virNWFilterHashTableCreate(0))) goto error; diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index 6de4ab1f58..de807e2a54 100644 --- a/src/conf/networkcommon_conf.c +++ b/src/conf/networkcommon_conf.c @@ -47,8 +47,7 @@ virNetDevIPRouteCreate(const char *errorDetail, if (VIR_ALLOC(def) < 0) return NULL; =20 - if (VIR_STRDUP(def->family, family) < 0) - goto error; + def->family =3D g_strdup(family); =20 def->prefix =3D prefix; def->has_prefix =3D hasPrefix; diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 5b4bb34a5a..7eb52dbf85 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1944,8 +1944,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, goto error; } } else { - if (VIR_STRDUP(def->name, "new device") < 0) - goto error; + def->name =3D g_strdup("new device"); } =20 def->sysfs_path =3D virXPathString("string(./path[1])", ctxt); @@ -2122,12 +2121,8 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def, while (cap !=3D NULL) { if (cap->data.type =3D=3D VIR_NODE_DEV_CAP_SCSI_HOST && cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST)= { - if (VIR_STRDUP(*wwnn, cap->data.scsi_host.wwnn) < 0 || - VIR_STRDUP(*wwpn, cap->data.scsi_host.wwpn) < 0) { - /* Free the other one, if allocated... */ - VIR_FREE(*wwnn); - goto cleanup; - } + *wwnn =3D g_strdup(cap->data.scsi_host.wwnn); + *wwpn =3D g_strdup(cap->data.scsi_host.wwpn); break; } =20 @@ -2459,8 +2454,7 @@ virNodeDeviceGetSCSITargetCaps(const char *sysfsPath, if (!(dir =3D mdir_name(sysfsPath))) return -1; =20 - if (VIR_STRDUP(rport, last_component(dir)) < 0) - goto cleanup; + rport =3D g_strdup(last_component(dir)); =20 if (!virFCIsCapableRport(rport)) goto cleanup; diff --git a/src/conf/node_device_util.c b/src/conf/node_device_util.c index 3b1e8e487f..2728b8a510 100644 --- a/src/conf/node_device_util.c +++ b/src/conf/node_device_util.c @@ -85,8 +85,7 @@ virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchos= t) NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn); =20 if (fchost->parent) { - if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0) - goto cleanup; + parent_hoststr =3D g_strdup(fchost->parent); } else if (fchost->parent_wwnn && fchost->parent_wwpn) { if (!(parent_hoststr =3D virVHBAGetHostByWWN(NULL, fchost->parent_= wwnn, fchost->parent_wwpn))) { diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 0f025637ee..cd97eb87ac 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2674,9 +2674,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) } chain =3D NULL; } else { - if (VIR_STRDUP(ret->chainsuffix, - virNWFilterChainSuffixTypeToString(VIR_NWFILTER_CHA= INSUFFIX_ROOT)) < 0) - goto cleanup; + ret->chainsuffix =3D g_strdup(virNWFilterChainSuffixTypeToString(V= IR_NWFILTER_CHAINSUFFIX_ROOT)); } =20 uuid =3D virXPathString("string(./uuid)", ctxt); diff --git a/src/conf/nwfilter_ipaddrmap.c b/src/conf/nwfilter_ipaddrmap.c index eb1ed76af8..672a58be3a 100644 --- a/src/conf/nwfilter_ipaddrmap.c +++ b/src/conf/nwfilter_ipaddrmap.c @@ -53,8 +53,7 @@ virNWFilterIPAddrMapAddIPAddr(const char *ifname, char *a= ddr) char *addrCopy; virNWFilterVarValuePtr val; =20 - if (VIR_STRDUP(addrCopy, addr) < 0) - return -1; + addrCopy =3D g_strdup(addr); =20 virMutexLock(&ipAddressMapLock); =20 diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c index 7640717948..7608d4960e 100644 --- a/src/conf/nwfilter_params.c +++ b/src/conf/nwfilter_params.c @@ -76,16 +76,14 @@ virNWFilterVarValueCopy(const virNWFilterVarValue *val) =20 switch (res->valType) { case NWFILTER_VALUE_TYPE_SIMPLE: - if (VIR_STRDUP(res->u.simple.value, val->u.simple.value) < 0) - goto err_exit; + res->u.simple.value =3D g_strdup(val->u.simple.value); break; case NWFILTER_VALUE_TYPE_ARRAY: if (VIR_ALLOC_N(res->u.array.values, val->u.array.nValues) < 0) goto err_exit; res->u.array.nValues =3D val->u.array.nValues; for (i =3D 0; i < val->u.array.nValues; i++) { - if (VIR_STRDUP(str, val->u.array.values[i]) < 0) - goto err_exit; + str =3D g_strdup(val->u.array.values[i]); res->u.array.values[i] =3D str; } break; @@ -126,8 +124,7 @@ virNWFilterVarValueCreateSimpleCopyValue(const char *va= lue) char *val; virNWFilterVarValuePtr ret; =20 - if (VIR_STRDUP(val, value) < 0) - return NULL; + val =3D g_strdup(value); ret =3D virNWFilterVarValueCreateSimple(val); if (!ret) VIR_FREE(val); @@ -255,8 +252,7 @@ int virNWFilterVarValueAddValueCopy(virNWFilterVarValuePtr val, const char *va= lue) { char *valdup; - if (VIR_STRDUP(valdup, value) < 0) - return -1; + valdup =3D g_strdup(value); if (virNWFilterVarValueAddValue(val, valdup) < 0) { VIR_FREE(valdup); return -1; diff --git a/src/conf/object_event.c b/src/conf/object_event.c index 453fab74b1..408e0fd2b2 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -437,8 +437,7 @@ virObjectEventCallbackListAddID(virConnectPtr conn, =20 if (key) { cb->key_filter =3D true; - if (VIR_STRDUP(cb->key, key) < 0) - goto cleanup; + cb->key =3D g_strdup(key); } cb->filter =3D filter; cb->filter_opaque =3D filter_opaque; @@ -623,11 +622,8 @@ virObjectEventNew(virClassPtr klass, event->eventID =3D eventID; event->remoteID =3D -1; =20 - if (VIR_STRDUP(event->meta.name, name) < 0 || - VIR_STRDUP(event->meta.key, key) < 0) { - virObjectUnref(event); - return NULL; - } + event->meta.name =3D g_strdup(name); + event->meta.key =3D g_strdup(key); event->meta.id =3D id; if (uuid) memcpy(event->meta.uuid, uuid, VIR_UUID_BUFLEN); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 0e9d307321..f9fbca3c07 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -612,8 +612,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapsh= otDefPtr def) return -1; } =20 - if (VIR_STRDUP(tmppath, origpath) < 0) - return -1; + tmppath =3D g_strdup(origpath); =20 /* drop suffix of the file name */ if ((tmp =3D strrchr(tmppath, '.')) && !strchr(tmp, '/')) @@ -741,8 +740,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, } if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) { VIR_FREE(disk->name); - if (VIR_STRDUP(disk->name, def->parent.dom->disks[idx]->dst) <= 0) - goto cleanup; + disk->name =3D g_strdup(def->parent.dom->disks[idx]->dst); } } =20 @@ -760,8 +758,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, disk =3D &def->disks[ndisks++]; if (!(disk->src =3D virStorageSourceNew())) goto cleanup; - if (VIR_STRDUP(disk->name, def->parent.dom->disks[i]->dst) < 0) - goto cleanup; + disk->name =3D g_strdup(def->parent.dom->disks[i]->dst); disk->idx =3D i; =20 /* Don't snapshot empty drives */ diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index ba3e3ec326..f212eefe25 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -640,9 +640,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, if (sourcedir) source->dir =3D virFileSanitizePath(sourcedir); /* In gluster, a missing dir defaults to "/" */ - if (!source->dir && pool_type =3D=3D VIR_STORAGE_POOL_GLUSTER && - VIR_STRDUP(source->dir, "/") < 0) - goto cleanup; + if (!source->dir && pool_type =3D=3D VIR_STORAGE_POOL_GLUSTER) + source->dir =3D g_strdup("/"); =20 if ((adapternode =3D virXPathNode("./adapter", ctxt))) { if (virStorageAdapterParseXML(&source->adapter, adapternode, ctxt)= < 0) @@ -885,9 +884,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) =20 def->name =3D virXPathString("string(./name)", ctxt); if (def->name =3D=3D NULL && - options->flags & VIR_STORAGE_POOL_SOURCE_NAME && - VIR_STRDUP(def->name, def->source.name) < 0) - return NULL; + options->flags & VIR_STORAGE_POOL_SOURCE_NAME) + def->name =3D g_strdup(def->source.name); =20 if (def->name =3D=3D NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -934,8 +932,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) { if (def->source.name =3D=3D NULL) { /* source name defaults to pool name */ - if (VIR_STRDUP(def->source.name, def->name) < 0) - return NULL; + def->source.name =3D g_strdup(def->name); } } =20 diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index 59d4864735..1d02a4ad66 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -73,8 +73,7 @@ static char *virChrdevLockFilePath(const char *dev) char *filename; char *p; =20 - if (VIR_STRDUP(devCopy, dev) < 0) - goto cleanup; + devCopy =3D g_strdup(dev); =20 /* skip the leading "/dev/" */ filename =3D STRSKIP(devCopy, "/dev"); @@ -407,8 +406,7 @@ int virChrdevOpen(virChrdevsPtr devs, added =3D true; =20 cbdata->devs =3D devs; - if (VIR_STRDUP(cbdata->path, path) < 0) - goto error; + cbdata->path =3D g_strdup(path); =20 /* open the character device */ switch (source->type) { diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index a4f9ce9c3f..ef702eb6aa 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -328,11 +328,8 @@ static int virDomainMomentObjListCopyNames(void *paylo= ad, if (!data->filter(obj, data->filter_flags)) return 0; =20 - if (data->names && data->count < data->maxnames && - VIR_STRDUP(data->names[data->count], obj->def->name) < 0) { - data->error =3D true; - return 0; - } + if (data->names && data->count < data->maxnames) + data->names[data->count] =3D g_strdup(obj->def->name); data->count++; return 0; } diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index fa1985f474..744dd87296 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -440,8 +440,7 @@ virDomainObjListRename(virDomainObjListPtr doms, return ret; } =20 - if (VIR_STRDUP(old_name, dom->def->name) < 0) - return ret; + old_name =3D g_strdup(dom->def->name); =20 /* doms and dom locks must be attained in right order thus relock dom.= */ /* dom reference is touched for the benefit of those callers that @@ -761,11 +760,10 @@ virDomainObjListCopyInactiveNames(void *payload, !data->filter(data->conn, obj->def)) goto cleanup; if (!virDomainObjIsActive(obj) && data->numnames < data->maxnames) { - if (VIR_STRDUP(data->names[data->numnames], obj->def->name) < 0) - data->oom =3D 1; - else - data->numnames++; + data->names[data->numnames] =3D g_strdup(obj->def->name); + data->numnames++; } + cleanup: virObjectUnlock(obj); return 0; diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index b77d4152f5..43ba395d2b 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -176,14 +176,10 @@ virInterfaceObjListFindByMACStringCb(void *payload, virObjectLock(obj); =20 if (STRCASEEQ(obj->def->mac, data->matchStr)) { - if (VIR_STRDUP(data->names[data->nnames], obj->def->name) < 0) { - data->error =3D true; - goto cleanup; - } + data->names[data->nnames] =3D g_strdup(obj->def->name); data->nnames++; } =20 - cleanup: virObjectUnlock(obj); return 0; } @@ -544,10 +540,7 @@ virInterfaceObjListGetNamesCb(void *payload, if (data->wantActive !=3D virInterfaceObjIsActive(obj)) goto cleanup; =20 - if (VIR_STRDUP(data->names[data->nnames], obj->def->name) < 0) { - data->error =3D true; - goto cleanup; - } + data->names[data->nnames] =3D g_strdup(obj->def->name); =20 data->nnames++; =20 diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 435f3611e9..e7017bffa9 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1522,11 +1522,8 @@ virNetworkObjListGetHelper(void *payload, =20 if ((data->active && virNetworkObjIsActive(obj)) || (!data->active && !virNetworkObjIsActive(obj))) { - if (data->names && - VIR_STRDUP(data->names[data->nnames], obj->def->name) < 0) { - data->error =3D true; - goto cleanup; - } + if (data->names) + data->names[data->nnames] =3D g_strdup(obj->def->name); data->nnames++; } =20 diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 7656a5eed2..3a34a324ca 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -761,14 +761,10 @@ virNodeDeviceObjListGetNamesCallback(void *payload, =20 if ((!filter || filter(data->conn, def)) && (!data->matchstr || virNodeDeviceObjHasCapStr(obj, data->matchstr)= )) { - if (VIR_STRDUP(data->names[data->nnames], def->name) < 0) { - data->error =3D true; - goto cleanup; - } + data->names[data->nnames] =3D g_strdup(def->name); data->nnames++; } =20 - cleanup: virObjectUnlock(obj); return 0; } @@ -869,12 +865,12 @@ virNodeDeviceObjListExportCallback(void *payload, if ((!data->filter || data->filter(data->conn, def)) && virNodeDeviceObjMatch(obj, data->flags)) { if (data->devices) { - if (!(device =3D virGetNodeDevice(data->conn, def->name)) || - VIR_STRDUP(device->parentName, def->parent) < 0) { + if (!(device =3D virGetNodeDevice(data->conn, def->name))) { virObjectUnref(device); data->error =3D true; goto cleanup; } + device->parentName =3D g_strdup(def->parent); data->devices[data->ndevices] =3D device; } data->ndevices++; diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbinding= def.c index 6f13bc581a..dbd0a9a04f 100644 --- a/src/conf/virnwfilterbindingdef.c +++ b/src/conf/virnwfilterbindingdef.c @@ -54,21 +54,17 @@ virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src) if (VIR_ALLOC(ret) < 0) return NULL; =20 - if (VIR_STRDUP(ret->ownername, src->ownername) < 0) - goto error; + ret->ownername =3D g_strdup(src->ownername); =20 memcpy(ret->owneruuid, src->owneruuid, sizeof(ret->owneruuid)); =20 - if (VIR_STRDUP(ret->portdevname, src->portdevname) < 0) - goto error; + ret->portdevname =3D g_strdup(src->portdevname); =20 - if (VIR_STRDUP(ret->linkdevname, src->linkdevname) < 0) - goto error; + ret->linkdevname =3D g_strdup(src->linkdevname); =20 ret->mac =3D src->mac; =20 - if (VIR_STRDUP(ret->filter, src->filter) < 0) - goto error; + ret->filter =3D g_strdup(src->filter); =20 if (!(ret->filterparams =3D virNWFilterHashTableCreate(0))) goto error; diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c index d2d957a1cc..c9e224061d 100644 --- a/src/conf/virnwfilterobj.c +++ b/src/conf/virnwfilterobj.c @@ -421,22 +421,13 @@ virNWFilterObjListGetNames(virNWFilterObjListPtr nwfi= lters, virNWFilterObjLock(obj); def =3D obj->def; if (!filter || filter(conn, def)) { - if (VIR_STRDUP(names[nnames], def->name) < 0) { - virNWFilterObjUnlock(obj); - goto failure; - } + names[nnames] =3D g_strdup(def->name); nnames++; } virNWFilterObjUnlock(obj); } =20 return nnames; - - failure: - while (--nnames >=3D 0) - VIR_FREE(names[nnames]); - - return -1; } =20 =20 diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index e5ef9c8a68..a4fd330663 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -931,12 +931,8 @@ virStoragePoolObjVolumeGetNamesCb(void *payload, !data->filter(data->conn, data->pooldef, volobj->voldef)) goto cleanup; =20 - if (data->names) { - if (VIR_STRDUP(data->names[data->nnames], volobj->voldef->name) < = 0) { - data->error =3D true; - goto cleanup; - } - } + if (data->names) + data->names[data->nnames] =3D g_strdup(volobj->voldef->name); =20 data->nnames++; =20 @@ -1642,17 +1638,9 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools, def =3D NULL; =20 VIR_FREE(obj->configFile); /* for driver reload */ - if (VIR_STRDUP(obj->configFile, path) < 0) { - virStoragePoolObjRemove(pools, obj); - virStoragePoolObjEndAPI(&obj); - return NULL; - } + obj->configFile =3D g_strdup(path); VIR_FREE(obj->autostartLink); /* for driver reload */ - if (VIR_STRDUP(obj->autostartLink, autostartLink) < 0) { - virStoragePoolObjRemove(pools, obj); - virStoragePoolObjEndAPI(&obj); - return NULL; - } + obj->autostartLink =3D g_strdup(autostartLink); =20 obj->autostart =3D virFileLinkPointsTo(obj->autostartLink, obj->configFile); @@ -1919,12 +1907,8 @@ virStoragePoolObjGetNamesCb(void *payload, if (data->wantActive !=3D virStoragePoolObjIsActive(obj)) goto cleanup; =20 - if (data->names) { - if (VIR_STRDUP(data->names[data->nnames], obj->def->name) < 0) { - data->error =3D true; - goto cleanup; - } - } + if (data->names) + data->names[data->nnames] =3D g_strdup(obj->def->name); =20 data->nnames++; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576286; cv=none; d=zoho.com; s=zohoarc; b=c9GnumiSOUGj4wN1s8XUegmKTxa0m2rAf3QpzGs7rD3Sj9xHccLOAKpmFuRPVsA36cZYg+Jai+Mcb3ZORqzPNta7QHV0FNwa00p6+rSWyknYo3MxorpFUUeoGM7l3odUg34+d1UwiawIKrszrJFVu/GHkBQ9zgeJg/rSAKmKE8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576286; 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=Xq80tQ0Iqwi8cbAJxSf7ZDBOMhH4lSD5h08TmidQq24=; b=MScXxT4Ba0Z2qbrvfc1/gqRYZPct0Sfqr9p7ImUYhgrrxFBm6h2f73GM+fI3pKO0YLREMnF7v3Fi9n/ob/4dGEpNl6NDf5D1VrOHXZSD2BbmmXXWTH4tstkL8n41LWfgk2n9FruD5Eq+cm7bcv5Eb8YknXFky5Aqtd7i+1e2770= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576286437295.75141562212843; Sun, 20 Oct 2019 05:58:06 -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-99-hmrco8UKPb-5fo0RJsjLnw-1; Sun, 20 Oct 2019 08:56:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39206615; Sun, 20 Oct 2019 12:56:23 +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 162385E1B0; Sun, 20 Oct 2019 12:56:23 +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 CE9324EE96; Sun, 20 Oct 2019 12:56:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCthdX023397 for ; Sun, 20 Oct 2019 08:55:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 645361EC; Sun, 20 Oct 2019 12:55:43 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 931D3196AE for ; Sun, 20 Oct 2019 12:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576285; 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=Xq80tQ0Iqwi8cbAJxSf7ZDBOMhH4lSD5h08TmidQq24=; b=NI+gt/rf/7sAPQCntxqVmmjb3XDorvOBMTcqkJthEygLhitjUqewx5UxKqGhgS9I/hDnlu kZwtbvXVHb5MrbpN6sBBrVPI+6Vu6Hq+yHoAUY2E+70N81qTUYo3oiTuGt/HOmmIdMCSqr 41y+Mt2KMJ1FD8SCiVfYnZhqhLYCico= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:29 +0200 Message-Id: <05b87738b03464c66b9e81458309172ca631894b.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/34] cpu: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: hmrco8UKPb-5fo0RJsjLnw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/cpu/cpu_arm.c | 5 +++-- src/cpu/cpu_ppc64.c | 31 +++++++++++++------------------ src/cpu/cpu_x86.c | 45 ++++++++++++++++++++++----------------------- 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index c271e53a90..a102c6fda4 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -78,12 +78,13 @@ virCPUarmBaseline(virCPUDefPtr *cpus, { virCPUDefPtr cpu =3D NULL; =20 - if (VIR_ALLOC(cpu) < 0 || - VIR_STRDUP(cpu->model, cpus[0]->model) < 0) { + if (VIR_ALLOC(cpu) < 0) { virCPUDefFree(cpu); return NULL; } =20 + cpu->model =3D g_strdup(cpus[0]->model); + cpu->type =3D VIR_CPU_TYPE_GUEST; cpu->match =3D VIR_CPU_MATCH_EXACT; =20 diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index 1d9d6bca12..59a5e1fc1d 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -188,8 +188,7 @@ ppc64ModelCopy(const struct ppc64_model *model) if (VIR_ALLOC(copy) < 0) goto error; =20 - if (VIR_STRDUP(copy->name, model->name) < 0) - goto error; + copy->name =3D g_strdup(model->name); =20 if (ppc64DataCopy(©->data, &model->data) < 0) goto error; @@ -287,8 +286,7 @@ ppc64VendorParse(xmlXPathContextPtr ctxt G_GNUC_UNUSED, if (VIR_ALLOC(vendor) < 0) return -1; =20 - if (VIR_STRDUP(vendor->name, name) < 0) - goto cleanup; + vendor->name =3D g_strdup(name); =20 if (ppc64VendorFind(map, vendor->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -324,8 +322,7 @@ ppc64ModelParse(xmlXPathContextPtr ctxt, if (VIR_ALLOC(model) < 0) goto cleanup; =20 - if (VIR_STRDUP(model->name, name) < 0) - goto cleanup; + model->name =3D g_strdup(name); =20 if (ppc64ModelFind(map, model->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -620,10 +617,9 @@ ppc64DriverDecode(virCPUDefPtr cpu, goto cleanup; } =20 - if (VIR_STRDUP(cpu->model, model->name) < 0 || - (model->vendor && VIR_STRDUP(cpu->vendor, model->vendor->name) < 0= )) { - goto cleanup; - } + cpu->model =3D g_strdup(model->name); + if (model->vendor) + cpu->vendor =3D g_strdup(model->vendor->name); =20 ret =3D 0; =20 @@ -765,12 +761,13 @@ virCPUppc64Baseline(virCPUDefPtr *cpus, } } =20 - if (VIR_ALLOC(cpu) < 0 || - VIR_STRDUP(cpu->model, model->name) < 0) + if (VIR_ALLOC(cpu) < 0) goto error; =20 - if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0) - goto error; + cpu->model =3D g_strdup(model->name); + + if (vendor) + cpu->vendor =3D g_strdup(vendor->name); =20 cpu->type =3D VIR_CPU_TYPE_GUEST; cpu->match =3D VIR_CPU_MATCH_EXACT; @@ -801,10 +798,8 @@ virCPUppc64DriverGetModels(char ***models) if (VIR_ALLOC_N(*models, map->nmodels + 1) < 0) goto error; =20 - for (i =3D 0; i < map->nmodels; i++) { - if (VIR_STRDUP((*models)[i], map->models[i]->name) < 0) - goto error; - } + for (i =3D 0; i < map->nmodels; i++) + (*models)[i] =3D g_strdup(map->models[i]->name); } =20 ret =3D map->nmodels; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 3de99ca057..d7fcb3b147 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -775,16 +775,18 @@ x86DataToCPU(const virCPUx86Data *data, virCPUx86Data modelData =3D VIR_CPU_X86_DATA_INIT; virCPUx86VendorPtr vendor; =20 - if (VIR_ALLOC(cpu) < 0 || - VIR_STRDUP(cpu->model, model->name) < 0 || - x86DataCopy(©, data) < 0 || - x86DataCopy(&modelData, &model->data) < 0) + if (VIR_ALLOC(cpu) < 0) goto error; =20 - if ((vendor =3D x86DataToVendor(©, map)) && - VIR_STRDUP(cpu->vendor, vendor->name) < 0) + cpu->model =3D g_strdup(model->name); + + if (x86DataCopy(©, data) < 0 || + x86DataCopy(&modelData, &model->data) < 0) goto error; =20 + if ((vendor =3D x86DataToVendor(©, map))) + cpu->vendor =3D g_strdup(vendor->name); + x86DataSubtract(©, &modelData); x86DataSubtract(&modelData, data); =20 @@ -862,8 +864,7 @@ x86VendorParse(xmlXPathContextPtr ctxt, if (VIR_ALLOC(vendor) < 0) goto cleanup; =20 - if (VIR_STRDUP(vendor->name, name) < 0) - goto cleanup; + vendor->name =3D g_strdup(name); =20 if (x86VendorFind(map, vendor->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1062,8 +1063,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, =20 feature->migratable =3D true; =20 - if (VIR_STRDUP(feature->name, name) < 0) - goto cleanup; + feature->name =3D g_strdup(name); =20 if (x86FeatureFind(map, feature->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1177,9 +1177,12 @@ x86ModelCopy(virCPUx86ModelPtr model) { virCPUx86ModelPtr copy; =20 - if (VIR_ALLOC(copy) < 0 || - VIR_STRDUP(copy->name, model->name) < 0 || - x86ModelCopySignatures(copy, model) < 0 || + if (VIR_ALLOC(copy) < 0) + return NULL; + + copy->name =3D g_strdup(model->name); + + if (x86ModelCopySignatures(copy, model) < 0 || x86DataCopy(©->data, &model->data) < 0) { x86ModelFree(copy); return NULL; @@ -1517,8 +1520,7 @@ x86ModelParse(xmlXPathContextPtr ctxt, if (!(model =3D x86ModelNew())) goto cleanup; =20 - if (VIR_STRDUP(model->name, name) < 0) - goto cleanup; + model->name =3D g_strdup(name); =20 if (x86ModelParseAncestor(model, ctxt, map) < 0) goto cleanup; @@ -2210,8 +2212,8 @@ x86Decode(virCPUDefPtr cpu, } } =20 - if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0) - goto cleanup; + if (vendor) + cpu->vendor =3D g_strdup(vendor->name); =20 sigs =3D x86FormatSignatures(model); =20 @@ -2947,8 +2949,7 @@ x86UpdateHostModel(virCPUDefPtr guest, =20 if (guest->vendor_id) { VIR_FREE(updated->vendor_id); - if (VIR_STRDUP(updated->vendor_id, guest->vendor_id) < 0) - goto cleanup; + updated->vendor_id =3D g_strdup(guest->vendor_id); } =20 for (i =3D 0; i < guest->nfeatures; i++) { @@ -3134,10 +3135,8 @@ virCPUx86GetModels(char ***models) if (VIR_ALLOC_N(*models, map->nmodels + 1) < 0) goto error; =20 - for (i =3D 0; i < map->nmodels; i++) { - if (VIR_STRDUP((*models)[i], map->models[i]->name) < 0) - goto error; - } + for (i =3D 0; i < map->nmodels; i++) + (*models)[i] =3D g_strdup(map->models[i]->name); } =20 return map->nmodels; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576198; cv=none; d=zoho.com; s=zohoarc; b=Vhs4rppBK5ys8dO/MDnERGolqOzEnY49QUw3XHbE9PNWi0vaKejEm+KWaj89fcBvbzLzrj1V4LZ1rlwcckq1Vm1Hoo6ZHzMuh/vIvNKkEFTBTHF5GWxWoFEwsuaCYR2ntFeVZBdZn0pwC5kR/hLZFOYQZeWlzgvEaAdJ8lXun1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576198; 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=ZHPd/2XOkLZ4WtgJhSYPPsHVYl/afy36Jj/wpSfZUHU=; b=Q3rWbNLPB93dIOZGIs/sWqWYpLk+OTNfaTdUMNJOqAd+cifPQUkiXJqNlWtwJvNkjtMTu50hx3usZcxhEaYJOrpco8XfR549kv7o8SnoIOGecdUFYEBUdUHfLAQ+zaMTnnVHYVJM8/yJJYE5pAFC/fu0lkADrXsVCP7Roz4lM50= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576198364523.140134919431; Sun, 20 Oct 2019 05:56:38 -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-221-nICoVje2P1KiPyX99kNdEw-1; Sun, 20 Oct 2019 08:56:35 -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 8E5CA107AFC7; Sun, 20 Oct 2019 12:56:26 +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 64CA960C4E; Sun, 20 Oct 2019 12:56:26 +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 233E81806B14; Sun, 20 Oct 2019 12:56:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtii5023407 for ; Sun, 20 Oct 2019 08:55:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 693B4196AE; Sun, 20 Oct 2019 12:55:44 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id C26553CC8 for ; Sun, 20 Oct 2019 12:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576197; 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=ZHPd/2XOkLZ4WtgJhSYPPsHVYl/afy36Jj/wpSfZUHU=; b=IjKkEqepLjog5lIiGW1Shf/1bQK0McxKLSO6ZdXp15EizVB66mN8nuASUylkctvIO//ogo nUXfVPAYdvRbhNnWkOhu0bbNE8iBio+xitllYABrYmdd1eUda2nLm+yNSLSW6xGSKsQZ9r 2reeVnUqpPldfroC0kBvFqF8j1XBBy0= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:30 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/34] datatypes: use g_strdup instead of VIR_STRDUP 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-MC-Unique: nICoVje2P1KiPyX99kNdEw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/datatypes.c | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/src/datatypes.c b/src/datatypes.c index 33c3f6be88..552115c7a3 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -290,8 +290,7 @@ virGetDomain(virConnectPtr conn, if (!(ret =3D virObjectNew(virDomainClass))) goto error; =20 - if (VIR_STRDUP(ret->name, name) < 0) - goto error; + ret->name =3D g_strdup(name); =20 ret->conn =3D virObjectRef(conn); ret->id =3D id; @@ -354,8 +353,7 @@ virGetNetwork(virConnectPtr conn, const char *name, con= st unsigned char *uuid) if (!(ret =3D virObjectNew(virNetworkClass))) goto error; =20 - if (VIR_STRDUP(ret->name, name) < 0) - goto error; + ret->name =3D g_strdup(name); =20 ret->conn =3D virObjectRef(conn); memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN); @@ -477,9 +475,8 @@ virGetInterface(virConnectPtr conn, const char *name, c= onst char *mac) if (!(ret =3D virObjectNew(virInterfaceClass))) goto error; =20 - if (VIR_STRDUP(ret->name, name) < 0 || - VIR_STRDUP(ret->mac, mac) < 0) - goto error; + ret->name =3D g_strdup(name); + ret->mac =3D g_strdup(mac); =20 ret->conn =3D virObjectRef(conn); =20 @@ -542,8 +539,7 @@ virGetStoragePool(virConnectPtr conn, const char *name, if (!(ret =3D virObjectNew(virStoragePoolClass))) goto error; =20 - if (VIR_STRDUP(ret->name, name) < 0) - goto error; + ret->name =3D g_strdup(name); =20 ret->conn =3D virObjectRef(conn); memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN); @@ -618,10 +614,9 @@ virGetStorageVol(virConnectPtr conn, const char *pool,= const char *name, if (!(ret =3D virObjectNew(virStorageVolClass))) goto error; =20 - if (VIR_STRDUP(ret->pool, pool) < 0 || - VIR_STRDUP(ret->name, name) < 0 || - VIR_STRDUP(ret->key, key) < 0) - goto error; + ret->pool =3D g_strdup(pool); + ret->name =3D g_strdup(name); + ret->key =3D g_strdup(key); =20 ret->conn =3D virObjectRef(conn); =20 @@ -687,8 +682,7 @@ virGetNodeDevice(virConnectPtr conn, const char *name) if (!(ret =3D virObjectNew(virNodeDeviceClass))) goto error; =20 - if (VIR_STRDUP(ret->name, name) < 0) - goto error; + ret->name =3D g_strdup(name); =20 ret->conn =3D virObjectRef(conn); return ret; @@ -749,8 +743,7 @@ virGetSecret(virConnectPtr conn, const unsigned char *u= uid, =20 memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN); ret->usageType =3D usageType; - if (VIR_STRDUP(ret->usageID, NULLSTR_EMPTY(usageID)) < 0) - goto error; + ret->usageID =3D g_strdup(NULLSTR_EMPTY(usageID)); =20 ret->conn =3D virObjectRef(conn); =20 @@ -859,8 +852,7 @@ virGetNWFilter(virConnectPtr conn, const char *name, if (!(ret =3D virObjectNew(virNWFilterClass))) goto error; =20 - if (VIR_STRDUP(ret->name, name) < 0) - goto error; + ret->name =3D g_strdup(name); =20 memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN); =20 @@ -924,11 +916,9 @@ virGetNWFilterBinding(virConnectPtr conn, const char *= portdev, if (!(ret =3D virObjectNew(virNWFilterBindingClass))) goto error; =20 - if (VIR_STRDUP(ret->portdev, portdev) < 0) - goto error; + ret->portdev =3D g_strdup(portdev); =20 - if (VIR_STRDUP(ret->filtername, filtername) < 0) - goto error; + ret->filtername =3D g_strdup(filtername); =20 ret->conn =3D virObjectRef(conn); =20 @@ -987,8 +977,7 @@ virGetDomainCheckpoint(virDomainPtr domain, =20 if (!(ret =3D virObjectNew(virDomainCheckpointClass))) goto error; - if (VIR_STRDUP(ret->name, name) < 0) - goto error; + ret->name =3D g_strdup(name); =20 ret->domain =3D virObjectRef(domain); =20 @@ -1044,8 +1033,7 @@ virGetDomainSnapshot(virDomainPtr domain, const char = *name) =20 if (!(ret =3D virObjectNew(virDomainSnapshotClass))) goto error; - if (VIR_STRDUP(ret->name, name) < 0) - goto error; + ret->name =3D g_strdup(name); =20 ret->domain =3D virObjectRef(domain); =20 @@ -1192,8 +1180,7 @@ virAdmGetServer(virAdmConnectPtr conn, const char *na= me) =20 if (!(ret =3D virObjectNew(virAdmServerClass))) goto error; - if (VIR_STRDUP(ret->name, name) < 0) - goto error; + ret->name =3D g_strdup(name); =20 ret->conn =3D virObjectRef(conn); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576414; cv=none; d=zoho.com; s=zohoarc; b=bkkPrbJKX66SVK3zA7ks8TqxE9RmiSmV88C+eOzOnj2qOjewBKgNp02pmw2tnNnujH0RUzHvW11yLUUw4dm713qJHv/4ujcnJDpvD9TfvAJaW3cQhbomIkUwm6eYTAJFKHparTZAldsvfSAw42dhIWIyuvXcaSnC9i5CznwE9+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576414; 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=l2udm+ihU/Vdp2ZXqXQQmBuKcfmN/MQSE5Eyn2F3OIw=; b=QcU6Zu5VXaOh5cs/dEUasZdEROfOfAQJVsJehnY3xcA+/K/AB447239L1447XNDoa9nAuwmpVU8RSC1q1JrOgG70KyAyJdlbfxSyT0g9198/7LjgbupLFIvP77qwzslhx03uFuqzrqMu4XFpT3XGaDkd7dmifko5haxcBpD1vt0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576414699985.4987365982353; Sun, 20 Oct 2019 06:00:14 -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-361-jrP2kc48OKC605rI0fn5bQ-1; Sun, 20 Oct 2019 08:56:35 -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 DB70B800D65; Sun, 20 Oct 2019 12:56:29 +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 A898960C4E; Sun, 20 Oct 2019 12:56:29 +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 5D2BA1803B49; Sun, 20 Oct 2019 12:56:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtjLI023420 for ; Sun, 20 Oct 2019 08:55:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id A4CFF1EC; Sun, 20 Oct 2019 12:55:45 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id D05F3194B9 for ; Sun, 20 Oct 2019 12:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576413; 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=l2udm+ihU/Vdp2ZXqXQQmBuKcfmN/MQSE5Eyn2F3OIw=; b=Wbhyl/5eS3E5xYZtjCWRPu23ZLvRqwNkfVFhJdtBgx3rR43vi49FZ7ovQ7HbxYoZ3wVoSF 79mE5IYFu3+22sq2HQPw8EcB/VCRMnCpxv7vZuLICSFPmWt53kh7zvlUZx1A6gwoI7QqsC +lYXQvZI5BsNcVmTj161UMyQecPAMUc= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:31 +0200 Message-Id: <40ed55fc5045d1a808c44958cb34f0ff3f080577.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/34] esx: use g_strdup instead of VIR_STRDUP 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-MC-Unique: jrP2kc48OKC605rI0fn5bQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/esx/esx_driver.c | 35 ++++--------- src/esx/esx_interface_driver.c | 15 +----- src/esx/esx_network_driver.c | 33 +++--------- src/esx/esx_storage_backend_iscsi.c | 9 ++-- src/esx/esx_storage_backend_vmfs.c | 15 ++---- src/esx/esx_util.c | 33 ++++-------- src/esx/esx_vi.c | 79 ++++++++++++----------------- src/esx/esx_vi_types.c | 13 +++-- 8 files changed, 77 insertions(+), 155 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 6c80e97220..8e39075701 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -177,8 +177,7 @@ esxParseVMXFileName(const char *fileName, void *opaque) while (*tmp =3D=3D '/' || *tmp =3D=3D '\\') ++tmp; =20 - if (VIR_STRDUP(strippedFileName, tmp) < 0) - goto cleanup; + strippedFileName =3D g_strdup(tmp); =20 tmp =3D strippedFileName; =20 @@ -199,8 +198,7 @@ esxParseVMXFileName(const char *fileName, void *opaque) =20 /* Fallback to direct datastore name match */ if (!result && STRPREFIX(fileName, "/vmfs/volumes/")) { - if (VIR_STRDUP(copyOfFileName, fileName) < 0) - goto cleanup; + copyOfFileName =3D g_strdup(fileName); =20 /* Expected format: '/vmfs/volumes//' */ if (!(tmp =3D STRSKIP(copyOfFileName, "/vmfs/volumes/")) || @@ -235,8 +233,7 @@ esxParseVMXFileName(const char *fileName, void *opaque) /* If it's an absolute path outside of a datastore just use it as = is */ if (!result && *fileName =3D=3D '/') { /* FIXME: need to deal with Windows paths here too */ - if (VIR_STRDUP(result, fileName) < 0) - goto cleanup; + result =3D g_strdup(fileName); } =20 if (!result) { @@ -334,8 +331,7 @@ esxFormatVMXFileName(const char *fileName, void *opaque) result =3D virBufferContentAndReset(&buffer); } else if (*fileName =3D=3D '/') { /* FIXME: need to deal with Windows paths here too */ - if (VIR_STRDUP(result, fileName) < 0) - goto cleanup; + result =3D g_strdup(fileName); } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not handle file name '%s'"), fileName); @@ -632,8 +628,7 @@ esxConnectToHost(esxPrivate *priv, return -1; =20 if (conn->uri->user) { - if (VIR_STRDUP(username, conn->uri->user) < 0) - goto cleanup; + username =3D g_strdup(conn->uri->user); } else { if (!(username =3D virAuthGetUsername(conn, auth, "esx", "root", conn->uri->server))) @@ -683,8 +678,7 @@ esxConnectToHost(esxPrivate *priv, if (inMaintenanceMode =3D=3D esxVI_Boolean_True) VIR_WARN("The server is in maintenance mode"); =20 - if (VIR_STRDUP(*vCenterIPAddress, *vCenterIPAddress) < 0) - goto cleanup; + *vCenterIPAddress =3D g_strdup(*vCenterIPAddress); =20 result =3D 0; =20 @@ -724,8 +718,7 @@ esxConnectToVCenter(esxPrivate *priv, return -1; =20 if (conn->uri->user) { - if (VIR_STRDUP(username, conn->uri->user) < 0) - goto cleanup; + username =3D g_strdup(conn->uri->user); } else { if (!(username =3D virAuthGetUsername(conn, auth, "esx", "administ= rator", hostname))) @@ -1169,19 +1162,13 @@ esxConnectGetHostname(virConnectPtr conn) } =20 if (!domainName || strlen(domainName) < 1) { - if (VIR_STRDUP(complete, hostName) < 0) - goto cleanup; + complete =3D g_strdup(hostName); } else { if (virAsprintf(&complete, "%s.%s", hostName, domainName) < 0) goto cleanup; } =20 cleanup: - /* - * If we goto cleanup in case of an error then complete is still NULL, - * either VIR_STRDUP returned -1 or virAsprintf failed. When virAsprin= tf - * fails it guarantees setting complete to NULL - */ esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&hostSystem); =20 @@ -2431,8 +2418,7 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr= stream, =20 url =3D virBufferContentAndReset(&buffer); =20 - if (VIR_STRDUP(mimeType, "image/png") < 0) - goto cleanup; + mimeType =3D g_strdup("image/png"); =20 if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0) { VIR_FREE(mimeType); @@ -3454,8 +3440,7 @@ esxDomainGetSchedulerType(virDomainPtr domain G_GNUC_= UNUSED, int *nparams) { char *type; =20 - if (VIR_STRDUP(type, "allocation") < 0) - return NULL; + type =3D g_strdup("allocation"); =20 if (nparams) *nparams =3D 3; /* reservation, limit, shares */ diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c index 76dcb3d53c..7873dd223f 100644 --- a/src/esx/esx_interface_driver.c +++ b/src/esx/esx_interface_driver.c @@ -66,12 +66,10 @@ esxConnectNumOfInterfaces(virConnectPtr conn) static int esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxna= mes) { - bool success =3D false; esxPrivate *priv =3D conn->privateData; esxVI_PhysicalNic *physicalNicList =3D NULL; esxVI_PhysicalNic *physicalNic =3D NULL; int count =3D 0; - size_t i; =20 if (maxnames =3D=3D 0) return 0; @@ -83,22 +81,11 @@ esxConnectListInterfaces(virConnectPtr conn, char **con= st names, int maxnames) =20 for (physicalNic =3D physicalNicList; physicalNic; physicalNic =3D physicalNic->_next) { - if (VIR_STRDUP(names[count], physicalNic->device) < 0) - goto cleanup; + names[count] =3D g_strdup(physicalNic->device); =20 ++count; } =20 - success =3D true; - - cleanup: - if (! success) { - for (i =3D 0; i < count; ++i) - VIR_FREE(names[i]); - - count =3D -1; - } - esxVI_PhysicalNic_Free(&physicalNicList); =20 return count; diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index aaf6c77635..b5dcfe0a80 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -73,12 +73,10 @@ esxConnectNumOfNetworks(virConnectPtr conn) static int esxConnectListNetworks(virConnectPtr conn, char **const names, int maxname= s) { - bool success =3D false; esxPrivate *priv =3D conn->privateData; esxVI_HostVirtualSwitch *hostVirtualSwitchList =3D NULL; esxVI_HostVirtualSwitch *hostVirtualSwitch =3D NULL; int count =3D 0; - size_t i; =20 if (maxnames =3D=3D 0) return 0; @@ -91,22 +89,11 @@ esxConnectListNetworks(virConnectPtr conn, char **const= names, int maxnames) =20 for (hostVirtualSwitch =3D hostVirtualSwitchList; hostVirtualSwitch; hostVirtualSwitch =3D hostVirtualSwitch->_next) { - if (VIR_STRDUP(names[count], hostVirtualSwitch->name) < 0) - goto cleanup; + names[count] =3D g_strdup(hostVirtualSwitch->name); =20 ++count; } =20 - success =3D true; - - cleanup: - if (! success) { - for (i =3D 0; i < count; ++i) - VIR_FREE(names[i]); - - count =3D -1; - } - esxVI_HostVirtualSwitch_Free(&hostVirtualSwitchList); =20 return count; @@ -447,12 +434,13 @@ esxNetworkDefineXML(virConnectPtr conn, const char *x= ml) =20 if (esxVI_HostPortGroupSpec_Alloc(&hostPortGroupSpec) < 0 || esxVI_HostNetworkPolicy_Alloc(&hostPortGroupSpec->policy) < 0 = || - esxVI_Int_Alloc(&hostPortGroupSpec->vlanId) < 0 || - VIR_STRDUP(hostPortGroupSpec->name, def->portGroups[i].name) <= 0 || - VIR_STRDUP(hostPortGroupSpec->vswitchName, def->name) < 0) { + esxVI_Int_Alloc(&hostPortGroupSpec->vlanId) < 0) { goto cleanup; } =20 + hostPortGroupSpec->name =3D g_strdup(def->portGroups[i].name); + hostPortGroupSpec->vswitchName =3D g_strdup(def->name); + hostPortGroupSpec->vlanId->value =3D 0; =20 if (def->portGroups[i].bandwidth) { @@ -670,8 +658,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned i= nt flags) if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, def-= >uuid) < 0) goto cleanup; =20 - if (VIR_STRDUP(def->name, hostVirtualSwitch->name) < 0) - goto cleanup; + def->name =3D g_strdup(hostVirtualSwitch->name); =20 def->forward.type =3D VIR_NETWORK_FORWARD_NONE; =20 @@ -702,9 +689,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned i= nt flags) if (STREQ(physicalNicKey->value, physicalNic->key)) { def->forward.ifs[def->forward.nifs].type =3D VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV; - if (VIR_STRDUP(def->forward.ifs[def->forward.nifs].dev= ice.dev, - physicalNic->device) < 0) - goto cleanup; + def->forward.ifs[def->forward.nifs].device.dev =3D g_s= trdup(physicalNic->device); =20 ++def->forward.nifs; =20 @@ -766,9 +751,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned i= nt flags) for (networkName =3D networkNameList; networkName; networkName =3D networkName->_next) { if (STREQ(networkName->value, hostPortGroup->spec-= >name)) { - if (VIR_STRDUP(def->portGroups[def->nPortGroup= s].name, - networkName->value) < 0) - goto cleanup; + def->portGroups[def->nPortGroups].name =3D g_s= trdup(networkName->value); =20 if (hostPortGroup->spec->policy) { if (esxShapingPolicyToBandwidth diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index a7e1f1b340..61354a6938 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -127,8 +127,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **c= onst names, */ for (target =3D hostInternetScsiHba->configuredStaticTarget; target && count < maxnames; target =3D target->_next) { - if (VIR_STRDUP(names[count], target->iScsiName) < 0) - goto cleanup; + names[count] =3D g_strdup(target->iScsiName); =20 ++count; } @@ -406,8 +405,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char = **const names, hostScsiTopologyLun && count < maxnames; hostScsiTopologyLun =3D hostScsiTopologyLun->_next) { if (STREQ(hostScsiTopologyLun->scsiLun, scsiLun->key)) { - if (VIR_STRDUP(names[count], scsiLun->deviceName) < 0) - goto cleanup; + names[count] =3D g_strdup(scsiLun->deviceName); =20 ++count; } @@ -705,8 +703,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, =20 virUUIDFormat(md5, uuid_string); =20 - if (VIR_STRDUP(def.key, uuid_string) < 0) - goto cleanup; + def.key =3D g_strdup(uuid_string); =20 /* iSCSI LUN exposes a block device */ def.type =3D VIR_STORAGE_VOL_BLOCK; diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index a69e097a52..dfb4b7be15 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -166,8 +166,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **c= onst names, goto cleanup; } =20 - if (VIR_STRDUP(names[count], dynamicProperty->val->string)= < 0) - goto cleanup; + names[count] =3D g_strdup(dynamicProperty->val->string); =20 ++count; break; @@ -605,8 +604,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char = **const names, for (fileInfo =3D searchResults->file; fileInfo; fileInfo =3D fileInfo->_next) { if (length < 1) { - if (VIR_STRDUP(names[count], fileInfo->path) < 0) - goto cleanup; + names[count] =3D g_strdup(fileInfo->path); } else if (virAsprintf(&names[count], "%s/%s", directoryAndFil= eName, fileInfo->path) < 0) { goto cleanup; @@ -774,8 +772,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char= *key) VIR_FREE(datastorePath); =20 if (length < 1) { - if (VIR_STRDUP(volumeName, fileInfo->path) < 0) - goto cleanup; + volumeName =3D g_strdup(fileInfo->path); } else if (virAsprintf(&volumeName, "%s/%s", directoryAndFileName, fileInfo->path) < 0) { @@ -1005,8 +1002,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, goto cleanup; } else { /* Fall back to the path as key */ - if (VIR_STRDUP(key, datastorePath) < 0) - goto cleanup; + key =3D g_strdup(datastorePath); } } else { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1191,8 +1187,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, goto cleanup; } else { /* Fall back to the path as key */ - if (VIR_STRDUP(key, datastorePath) < 0) - goto cleanup; + key =3D g_strdup(datastorePath); } } else { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index 1bed01054b..6f4ee3444f 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -59,8 +59,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr= uri) if (STRCASEEQ(queryParam->name, "transport")) { VIR_FREE((*parsedUri)->transport); =20 - if (VIR_STRDUP((*parsedUri)->transport, queryParam->value) < 0) - goto cleanup; + (*parsedUri)->transport =3D g_strdup(queryParam->value); =20 if (STRNEQ((*parsedUri)->transport, "http") && STRNEQ((*parsedUri)->transport, "https")) { @@ -73,8 +72,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr= uri) } else if (STRCASEEQ(queryParam->name, "vcenter")) { VIR_FREE((*parsedUri)->vCenter); =20 - if (VIR_STRDUP((*parsedUri)->vCenter, queryParam->value) < 0) - goto cleanup; + (*parsedUri)->vCenter =3D g_strdup(queryParam->value); } else if (STRCASEEQ(queryParam->name, "no_verify")) { if (virStrToLong_i(queryParam->value, NULL, 10, &noVerify) < 0= || (noVerify !=3D 0 && noVerify !=3D 1)) { @@ -123,8 +121,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIP= tr uri) tmp =3D queryParam->value; } =20 - if (VIR_STRDUP((*parsedUri)->proxy_hostname, tmp) < 0) - goto cleanup; + (*parsedUri)->proxy_hostname =3D g_strdup(tmp); =20 if ((tmp =3D strchr((*parsedUri)->proxy_hostname, ':'))) { if (tmp =3D=3D (*parsedUri)->proxy_hostname) { @@ -153,8 +150,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIP= tr uri) } } =20 - if (VIR_STRDUP((*parsedUri)->path, uri->path) < 0) - goto cleanup; + (*parsedUri)->path =3D g_strdup(uri->path); =20 if (!(*parsedUri)->transport) (*parsedUri)->transport =3D g_strdup("https"); @@ -226,8 +222,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, c= har **datastoreName, return -1; } =20 - if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0) - goto cleanup; + copyOfDatastorePath =3D g_strdup(datastorePath); =20 /* Expected format: '[] ' where is optional */ if (!(tmp =3D STRSKIP(copyOfDatastorePath, "[")) || *tmp =3D=3D ']' || @@ -238,10 +233,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, = char **datastoreName, goto cleanup; } =20 - if (datastoreName && - VIR_STRDUP(*datastoreName, preliminaryDatastoreName) < 0) { - goto cleanup; - } + if (datastoreName) + *datastoreName =3D g_strdup(preliminaryDatastoreName); =20 preliminaryDirectoryAndFileName =3D strtok_r(NULL, "", &saveptr); =20 @@ -252,10 +245,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, = char **datastoreName, strspn(preliminaryDirectoryAndFileName, " "); } =20 - if (directoryAndFileName && - VIR_STRDUP(*directoryAndFileName, preliminaryDirectoryAndFileName)= < 0) { - goto cleanup; - } + if (directoryAndFileName) + *directoryAndFileName =3D g_strdup(preliminaryDirectoryAndFileName= ); =20 if (directoryName) { /* Split into / and remove / */ @@ -264,8 +255,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, c= har **datastoreName, if (tmp) *tmp =3D '\0'; =20 - if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < = 0) - goto cleanup; + *directoryName =3D g_strdup(preliminaryDirectoryAndFileName); } =20 result =3D 0; @@ -447,8 +437,7 @@ esxUtil_EscapeDatastoreItem(const char *string) char *escaped1; char *escaped2 =3D NULL; =20 - if (VIR_STRDUP(replaced, string) < 0) - return NULL; + replaced =3D g_strdup(string); =20 esxUtil_ReplaceSpecialWindowsPathChars(replaced); =20 diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index ef37bbf88d..78e61ecd24 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -1012,14 +1012,15 @@ esxVI_Context_Connect(esxVI_Context *ctx, const cha= r *url, } =20 if (esxVI_CURL_Alloc(&ctx->curl) < 0 || - esxVI_CURL_Connect(ctx->curl, parsedUri) < 0 || - VIR_STRDUP(ctx->url, url) < 0 || - VIR_STRDUP(ctx->ipAddress, ipAddress) < 0 || - VIR_STRDUP(ctx->username, username) < 0 || - VIR_STRDUP(ctx->password, password) < 0) { + esxVI_CURL_Connect(ctx->curl, parsedUri) < 0) { goto cleanup; } =20 + ctx->url =3D g_strdup(url); + ctx->ipAddress =3D g_strdup(ipAddress); + ctx->username =3D g_strdup(username); + ctx->password =3D g_strdup(password); + if (VIR_ALLOC(ctx->sessionLock) < 0) goto cleanup; =20 @@ -1142,8 +1143,7 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx) return -1; } =20 - if (VIR_STRDUP(ctx->datacenterPath, ctx->datacenter->name) < 0) - return -1; + ctx->datacenterPath =3D g_strdup(ctx->datacenter->name); =20 /* Lookup (Cluster)ComputeResource */ if (esxVI_LookupComputeResource(ctx, NULL, ctx->datacenter->hostFolder, @@ -1158,8 +1158,7 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx) return -1; } =20 - if (VIR_STRDUP(ctx->computeResourcePath, ctx->computeResource->name) <= 0) - return -1; + ctx->computeResourcePath =3D g_strdup(ctx->computeResource->name); =20 /* Lookup HostSystem */ if (esxVI_LookupHostSystem(ctx, NULL, ctx->computeResource->_reference, @@ -1168,8 +1167,7 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx) return -1; } =20 - if (VIR_STRDUP(ctx->hostSystemName, ctx->hostSystem->name) < 0) - return -1; + ctx->hostSystemName =3D g_strdup(ctx->hostSystem->name); =20 return 0; } @@ -1186,8 +1184,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Contex= t *ctx, const char *path) esxVI_ManagedObjectReference *root =3D NULL; esxVI_Folder *folder =3D NULL; =20 - if (VIR_STRDUP(tmp, path) < 0) - goto cleanup; + tmp =3D g_strdup(path); =20 /* Lookup Datacenter */ item =3D strtok_r(tmp, "/", &saveptr); @@ -1330,8 +1327,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Contex= t *ctx, const char *path) goto cleanup; } =20 - if (VIR_STRDUP(ctx->hostSystemName, previousItem) < 0) - goto cleanup; + ctx->hostSystemName =3D g_strdup(previousItem); =20 if (esxVI_LookupHostSystem(ctx, ctx->hostSystemName, ctx->computeResource->_reference, NULL, @@ -1927,25 +1923,26 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSe= t, return -1; } =20 - if (esxVI_TraversalSpec_Alloc(&traversalSpec) < 0 || - VIR_STRDUP(traversalSpec->name, name) < 0 || - VIR_STRDUP(traversalSpec->type, type) < 0 || - VIR_STRDUP(traversalSpec->path, path) < 0) { + if (esxVI_TraversalSpec_Alloc(&traversalSpec) < 0) goto failure; - } =20 + traversalSpec->name =3D g_strdup(name); + traversalSpec->type =3D g_strdup(type); + traversalSpec->path =3D g_strdup(path); traversalSpec->skip =3D esxVI_Boolean_False; =20 if (selectSetNames) { currentSelectSetName =3D selectSetNames; =20 while (currentSelectSetName && *currentSelectSetName !=3D '\0') { - if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 || - VIR_STRDUP(selectionSpec->name, currentSelectSetName) < 0 = || - esxVI_SelectionSpec_AppendToList(&traversalSpec->selectSet, - selectionSpec) < 0) { + if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0) + goto failure; + + selectionSpec->name =3D g_strdup(currentSelectSetName); + + if (esxVI_SelectionSpec_AppendToList(&traversalSpec->selectSet, + selectionSpec) < 0) goto failure; - } =20 selectionSpec =3D NULL; currentSelectSetName +=3D strlen(currentSelectSetName) + 1; @@ -2646,8 +2643,7 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *= virtualMachine, goto failure; } =20 - if (VIR_STRDUP(*name, dynamicProperty->val->string) < 0) - goto failure; + *name =3D g_strdup(dynamicProperty->val->string); =20 if (virVMXUnescapeHexPercent(*name) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2754,8 +2750,7 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapsh= otTree *snapshotTreeList, snapshotTree && count < nameslen; snapshotTree =3D snapshotTree->_next) { if (!(leaves && snapshotTree->childSnapshotList)) { - if (VIR_STRDUP(names[count], snapshotTree->name) < 0) - goto failure; + names[count] =3D g_strdup(snapshotTree->name); =20 count++; } @@ -3597,8 +3592,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ct= x, datastoreName) < 0) goto cleanup; =20 - if (VIR_STRDUP(fileName, directoryAndFileName) < 0) - goto cleanup; + fileName =3D g_strdup(directoryAndFileName); } else { if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", datastoreName, directoryName) < 0) @@ -3614,8 +3608,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ct= x, goto cleanup; } =20 - if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0) - goto cleanup; + fileName =3D g_strdup(directoryAndFileName + length + 1); } =20 /* Lookup HostDatastoreBrowser */ @@ -3910,8 +3903,7 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Con= text *ctx, =20 if (!(*key)) { /* Other files don't have a UUID, fall back to the path as key */ - if (VIR_STRDUP(*key, datastorePath) < 0) - goto cleanup; + *key =3D g_strdup(datastorePath); } =20 result =3D 0; @@ -4430,8 +4422,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, =20 ESX_VI_CHECK_ARG_LIST(errorMessage); =20 - if (VIR_STRDUP(version, "") < 0) - return -1; + version =3D g_strdup(""); =20 if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) goto cleanup; @@ -4503,8 +4494,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, goto cleanup; =20 VIR_FREE(version); - if (VIR_STRDUP(version, updateSet->version) < 0) - goto cleanup; + version =3D g_strdup(updateSet->version); =20 if (!updateSet->filterSet) continue; @@ -4547,11 +4537,9 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, goto cleanup; =20 if (!taskInfo->error) { - if (VIR_STRDUP(*errorMessage, _("Unknown error")) < 0) - goto cleanup; + *errorMessage =3D g_strdup(_("Unknown error")); } else if (!taskInfo->error->localizedMessage) { - if (VIR_STRDUP(*errorMessage, taskInfo->error->fault->_actualT= ype) < 0) - goto cleanup; + *errorMessage =3D g_strdup(taskInfo->error->fault->_actualType= ); } else { if (virAsprintf(errorMessage, "%s - %s", taskInfo->error->fault->_actualType, @@ -5032,9 +5020,8 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Context= *ctx, for (hostScsiTopologyLun =3D hostScsiTopologyTarget->lun; hostScsiTopologyLun; hostScsiTopologyLun =3D hostScsiTopologyLun->_next) { - if (STREQ(hostScsiTopologyLun->scsiLun, key) && - VIR_STRDUP(*poolName, candidate->iScsiName) < 0) - goto cleanup; + if (STREQ(hostScsiTopologyLun->scsiLun, key)) + *poolName =3D g_strdup(candidate->iScsiName); } =20 /* hostScsiTopologyLun iteration done, terminate loop */ diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index a32f674740..1deb5026b7 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -951,10 +951,8 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_Any= Type *src) =20 (*dest)->type =3D src->type; =20 - if (VIR_STRDUP((*dest)->other, src->other) < 0 || - VIR_STRDUP((*dest)->value, src->value) < 0) { - goto failure; - } + (*dest)->other =3D g_strdup(src->other); + (*dest)->value =3D g_strdup(src->value); =20 switch ((int)src->type) { case esxVI_Type_Boolean: @@ -1153,8 +1151,7 @@ esxVI_String_AppendValueToList(esxVI_String **stringL= ist, const char *value) if (esxVI_String_Alloc(&string) < 0) return -1; =20 - if (VIR_STRDUP(string->value, value) < 0) - goto failure; + string->value =3D g_strdup(value); =20 if (esxVI_String_AppendToList(stringList, string) < 0) goto failure; @@ -1275,8 +1272,10 @@ esxVI_String_DeserializeValue(xmlNodePtr node, char = **value) ESX_VI_CHECK_ARG_LIST(value); =20 *value =3D (char *)xmlNodeListGetString(node->doc, node->children, 1); + if (!*value) + *value =3D g_strdup(""); =20 - return *value ? 0 : VIR_STRDUP(*value, ""); + return 0; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576182; cv=none; d=zoho.com; s=zohoarc; b=WEMXBglVrfi28dRRfQcq3ticui5G0eUGP1C8qrRZUCNowXMZG5zF2tpf9F/6bmBynaaAecfCvp+XAUGw/wchhT2wsvdgsjlUUcrbF1XR6QNKpDGQNYJMnZq6OIgRs4u8UGcCokzE7dzg4mf40QJir2k8JZF0lmf3Jf2pSwvkK38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576182; 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=DHGiMF9WIFq8SKu9y+p7WgqtvdYaITvw0vvwetf+WXU=; b=IQkHDgyMNkz1BzIuLlBSCoFW6qFlTuHDGW3dJLtLEi9C79hEsmtTz7Sf1uvys9MWaZtkZUSeNonhPtN4j/F+oNZp05/+M2HbBI0MIdmZkKhz2lUFHGtP+vHqR+cDR6UO6Rls41R5hYhh0EYkPuRWDPzLnNyHXNJaHbqHc1xPy5c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576182377599.4658226759088; Sun, 20 Oct 2019 05:56:22 -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-97-KtgYR2JsPryWVlMDfvvKOQ-1; Sun, 20 Oct 2019 08:56:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49A05801E74; Sun, 20 Oct 2019 12:56:11 +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 230BB60606; Sun, 20 Oct 2019 12:56:11 +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 DB2CD18037CA; Sun, 20 Oct 2019 12:56:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtnhu023444 for ; Sun, 20 Oct 2019 08:55:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 866021EC; Sun, 20 Oct 2019 12:55:49 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DCFD196AE for ; Sun, 20 Oct 2019 12:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576181; 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=DHGiMF9WIFq8SKu9y+p7WgqtvdYaITvw0vvwetf+WXU=; b=K6cutuUMdbgdHhtrnpK+X9tTw9KvM7YA8DvFn+4Cd0Si4PeZV2Z8hMCq6xKNfBqbPBSK4D 98g3cF62lD9HJ22nEL3DbQcxxgTk32OzH92BcbFLxU6m+7ycpvL/j8sy7qcTUN2YAgb+r2 bL6j+wTO0ilMqxzxZusyDbA7lWyLCLA= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:32 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/34] interface: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: KtgYR2JsPryWVlMDfvvKOQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/interface/interface_backend_netcf.c | 11 ++------- src/interface/interface_backend_udev.c | 30 ++++++------------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index 00b5c00822..27590af134 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -251,17 +251,10 @@ netcfGetMinimalDefForDevice(struct netcf_if *iface) if (VIR_ALLOC(def) < 0) return NULL; =20 - if (VIR_STRDUP(def->name, ncf_if_name(iface)) < 0) - goto cleanup; - - if (VIR_STRDUP(def->mac, ncf_if_mac_string(iface)) < 0) - goto cleanup; + def->name =3D g_strdup(ncf_if_name(iface)); + def->mac =3D g_strdup(ncf_if_mac_string(iface)); =20 return def; - - cleanup: - virInterfaceDefFree(def); - return NULL; } =20 =20 diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index dcf22af440..251c2ecdf0 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -89,17 +89,10 @@ udevGetMinimalDefForDevice(struct udev_device *dev) if (VIR_ALLOC(def) < 0) return NULL; =20 - if (VIR_STRDUP(def->name, udev_device_get_sysname(dev)) < 0) - goto cleanup; - - if (VIR_STRDUP(def->mac, udev_device_get_sysattr_value(dev, "address")= ) < 0) - goto cleanup; + def->name =3D g_strdup(udev_device_get_sysname(dev)); + def->mac =3D g_strdup(udev_device_get_sysattr_value(dev, "address")); =20 return def; - - cleanup: - virInterfaceDefFree(def); - return NULL; } =20 =20 @@ -236,11 +229,7 @@ udevListInterfacesByStatus(virConnectPtr conn, =20 def =3D udevGetMinimalDefForDevice(dev); if (filter(conn, def)) { - if (VIR_STRDUP(names[count], udev_device_get_sysname(dev)) < 0= ) { - udev_device_unref(dev); - virInterfaceDefFree(def); - goto error; - } + names[count] =3D g_strdup(udev_device_get_sysname(dev)); count++; } udev_device_unref(dev); @@ -755,8 +744,7 @@ udevGetIfaceDefBond(struct udev *udev, _("Could not retrieve 'bonding/arp_ip_target' for '%s'"), = name); goto error; } - if (VIR_STRDUP(ifacedef->data.bond.target, tmp_str) < 0) - goto error; + ifacedef->data.bond.target =3D g_strdup(tmp_str); =20 /* Slaves of the bond */ /* Get each slave in the bond */ @@ -837,8 +825,7 @@ udevGetIfaceDefBridge(struct udev *udev, goto error; } =20 - if (VIR_STRDUP(ifacedef->data.bridge.delay, tmp_str) < 0) - goto error; + ifacedef->data.bridge.delay =3D g_strdup(tmp_str); =20 /* Retrieve Spanning Tree State. Valid values =3D -1, 0, 1 */ tmp_str =3D udev_device_get_sysattr_value(dev, "bridge/stp_state"); @@ -1001,8 +988,7 @@ udevGetIfaceDef(struct udev *udev, const char *name) =20 /* Clear our structure and set safe defaults */ ifacedef->startmode =3D VIR_INTERFACE_START_UNSPECIFIED; - if (VIR_STRDUP(ifacedef->name, name) < 0) - goto error; + ifacedef->name =3D g_strdup(name); =20 /* Lookup the device we've been asked about */ dev =3D udev_device_new_from_subsystem_sysname(udev, "net", name); @@ -1013,9 +999,7 @@ udevGetIfaceDef(struct udev *udev, const char *name) } =20 /* MAC address */ - if (VIR_STRDUP(ifacedef->mac, - udev_device_get_sysattr_value(dev, "address")) < 0) - goto error; + ifacedef->mac =3D g_strdup(udev_device_get_sysattr_value(dev, "address= ")); =20 /* Link state and speed */ if (virNetDevGetLinkInfo(ifacedef->name, &ifacedef->lnk) < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576203; cv=none; d=zoho.com; s=zohoarc; b=JwPePRcHte07yEZy+lf+WBSoNaeC99VPquwKHQ2hL+02dN9JVP0R78WEapaCfAO+UkS8kzGtIEbb4IYxNuPOMjtE7S2Kozs9tQ35r9Jhoh0cwx5PGzGOK/VNhmEb3J0CN8yrKfa++eR6lGHBdAvDQvH7SHB/DMaAuQix/Z+leqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576203; 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=LNe/VizNEvCDArv7bQYUsmMGVqACD79BSwNcObKrQeY=; b=g+v7DQPZtbhnLyyHU6W0n2jI+7QLq1jqyYXVqRZ43bsY4Gv31dsPFsQ0IppDgK0IoyJSUz4bx+8A1x80KiOfueBI85WjS6SVTM/4+cgwPSWiBJ1355hZEtmLBbXOf97udhc50cVdZC/2xMlErE+XSIPERtAanmxFbe0cTUnLJxM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576203629622.4818587442585; Sun, 20 Oct 2019 05:56:43 -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-5-vxbLEgbnO_qibfcNEt-7YA-1; Sun, 20 Oct 2019 08:56:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D7B560C; Sun, 20 Oct 2019 12:56:33 +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 355815D721; Sun, 20 Oct 2019 12:56:33 +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 E7E5E1803B4F; Sun, 20 Oct 2019 12:56:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtqEb023455 for ; Sun, 20 Oct 2019 08:55:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 33C0B1EC; Sun, 20 Oct 2019 12:55:52 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72BA4194B9 for ; Sun, 20 Oct 2019 12:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576202; 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=LNe/VizNEvCDArv7bQYUsmMGVqACD79BSwNcObKrQeY=; b=SSbd2PFy8Uq6EVwAxtSCyf8XHDD3NUBd3YESzXED/3BQmnj2iyPjAgSy3QkSf/pjajOhe1 OP6KUG8Xc2IJGMdlY+96fpuPz2/odshNFk8BIrbmA5zmsKh/i02W8eeScaU63pRLNoTY0B yyELMiXsfYVHqvOpfBveaUsIO2Gyv38= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:33 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/34] libxl: use g_strdup instead of VIR_STRDUP 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.15 X-MC-Unique: vxbLEgbnO_qibfcNEt-7YA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/libxl/libxl_capabilities.c | 4 +- src/libxl/libxl_conf.c | 185 +++++++++++---------------------- src/libxl/libxl_driver.c | 18 ++-- src/libxl/libxl_migration.c | 8 +- src/libxl/xen_common.c | 62 ++++------- src/libxl/xen_xl.c | 30 ++---- src/libxl/xen_xm.c | 3 +- 7 files changed, 101 insertions(+), 209 deletions(-) diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 54a8c090b0..3b88121dca 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -615,9 +615,7 @@ libxlMakeDomainOSCaps(const char *machine, return -1; =20 for (i =3D 0; i < nfirmwares; i++) { - if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalue= s], - firmwares[i]->name) < 0) - return -1; + capsLoader->values.values[capsLoader->values.nvalues] =3D g_strdup= (firmwares[i]->name); capsLoader->values.nvalues++; } =20 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index bbf0f8d8c1..3f08f0f710 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -162,8 +162,7 @@ libxlMakeDomCreateInfo(libxl_ctx *ctx, c_info->type =3D LIBXL_DOMAIN_TYPE_PV; } =20 - if (VIR_STRDUP(c_info->name, def->name) < 0) - goto error; + c_info->name =3D g_strdup(def->name); =20 if (def->nseclabels && def->seclabels[0]->type =3D=3D VIR_DOMAIN_SECLABEL_STATIC) { @@ -208,8 +207,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_VC: case VIR_DOMAIN_CHR_TYPE_PTY: - if (VIR_STRDUP(*buf, type) < 0) - return -1; + *buf =3D g_strdup(type); break; =20 case VIR_DOMAIN_CHR_TYPE_FILE: @@ -219,8 +217,7 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf) break; =20 case VIR_DOMAIN_CHR_TYPE_DEV: - if (VIR_STRDUP(*buf, srcdef->data.file.path) < 0) - return -1; + *buf =3D g_strdup(srcdef->data.file.path); break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: { @@ -507,9 +504,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, VIR_TRISTATE_SWITCH_ON); =20 /* copy SLIC table path to acpi_firmware */ - if (def->os.slic_table && - VIR_STRDUP(b_info->u.hvm.acpi_firmware, def->os.slic_table= ) < 0) - return -1; + if (def->os.slic_table) + b_info->u.hvm.acpi_firmware =3D g_strdup(def->os.slic_table); =20 if (def->nsounds > 0) { /* @@ -518,9 +514,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, */ virDomainSoundDefPtr snd =3D def->sounds[0]; =20 - if (VIR_STRDUP(b_info->u.hvm.soundhw, - virDomainSoundModelTypeToString(snd->model)) < = 0) - return -1; + b_info->u.hvm.soundhw =3D g_strdup(virDomainSoundModelTypeToSt= ring(snd->model)); } =20 for (i =3D 0; i < def->os.nBootDevs; i++) { @@ -546,16 +540,12 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } else { bootorder[def->os.nBootDevs] =3D '\0'; } - if (VIR_STRDUP(b_info->u.hvm.boot, bootorder) < 0) - return -1; + b_info->u.hvm.boot =3D g_strdup(bootorder); =20 #ifdef LIBXL_HAVE_BUILDINFO_KERNEL - if (VIR_STRDUP(b_info->cmdline, def->os.cmdline) < 0) - return -1; - if (VIR_STRDUP(b_info->kernel, def->os.kernel) < 0) - return -1; - if (VIR_STRDUP(b_info->ramdisk, def->os.initrd) < 0) - return -1; + b_info->cmdline =3D g_strdup(def->os.cmdline); + b_info->kernel =3D g_strdup(def->os.kernel); + b_info->ramdisk =3D g_strdup(def->os.initrd); #endif =20 /* @@ -587,8 +577,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } =20 VIR_FREE(b_info->device_model); - if (VIR_STRDUP(b_info->device_model, def->emulator) < 0) - return -1; + b_info->device_model =3D g_strdup(def->emulator); =20 b_info->device_model_version =3D libxlDomainGetEmulatorType(de= f); } @@ -658,13 +647,11 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, switch (def->inputs[i]->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: VIR_FREE(*usbdevice); - if (VIR_STRDUP(*usbdevice, "mouse") < 0) - return -1; + *usbdevice =3D g_strdup("mouse"); break; case VIR_DOMAIN_INPUT_TYPE_TABLET: VIR_FREE(*usbdevice); - if (VIR_STRDUP(*usbdevice, "tablet") < 0) - return -1; + *usbdevice =3D g_strdup("tablet"); break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -682,15 +669,11 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } #endif } else if (pvh) { - if (VIR_STRDUP(b_info->cmdline, def->os.cmdline) < 0) - return -1; - if (VIR_STRDUP(b_info->kernel, def->os.kernel) < 0) - return -1; - if (VIR_STRDUP(b_info->ramdisk, def->os.initrd) < 0) - return -1; + b_info->cmdline =3D g_strdup(def->os.cmdline); + b_info->kernel =3D g_strdup(def->os.kernel); + b_info->ramdisk =3D g_strdup(def->os.initrd); #ifdef LIBXL_HAVE_BUILDINFO_BOOTLOADER - if (VIR_STRDUP(b_info->bootloader, def->os.bootloader) < 0) - return -1; + b_info->bootloader =3D g_strdup(def->os.bootloader); if (def->os.bootloaderArgs) { if (!(b_info->bootloader_args =3D virStringSplit(def->os.bootloaderArgs, " \t\n", 0))) @@ -703,27 +686,22 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, * if bootloader is not specified AND direct kernel boot is not sp= ecified. */ if (def->os.bootloader) { - if (VIR_STRDUP(b_info->u.pv.bootloader, def->os.bootloader) < = 0) - return -1; + b_info->u.pv.bootloader =3D g_strdup(def->os.bootloader); } else if (def->os.kernel =3D=3D NULL) { - if (VIR_STRDUP(b_info->u.pv.bootloader, LIBXL_BOOTLOADER_PATH)= < 0) - return -1; + b_info->u.pv.bootloader =3D g_strdup(LIBXL_BOOTLOADER_PATH); } if (def->os.bootloaderArgs) { if (!(b_info->u.pv.bootloader_args =3D virStringSplit(def->os.bootloaderArgs, " \t\n", 0))) return -1; } - if (VIR_STRDUP(b_info->u.pv.cmdline, def->os.cmdline) < 0) - return -1; + b_info->u.pv.cmdline =3D g_strdup(def->os.cmdline); if (def->os.kernel) { - /* libxl_init_build_info() sets VIR_STRDUP(kernel.path, "hvmlo= ader") */ + /* libxl_init_build_info() sets kernel.path =3D g_strdup("hvml= oader") */ VIR_FREE(b_info->u.pv.kernel); - if (VIR_STRDUP(b_info->u.pv.kernel, def->os.kernel) < 0) - return -1; + b_info->u.pv.kernel =3D g_strdup(def->os.kernel); } - if (VIR_STRDUP(b_info->u.pv.ramdisk, def->os.initrd) < 0) - return -1; + b_info->u.pv.ramdisk =3D g_strdup(def->os.initrd); } =20 /* only the 'xen' balloon device model is supported */ @@ -1036,12 +1014,10 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_dev= ice_disk *x_disk) if (libxlMakeNetworkDiskSrc(l_disk->src, &x_disk->pdev_path) < 0) return -1; } else { - if (VIR_STRDUP(x_disk->pdev_path, virDomainDiskGetSource(l_disk)) = < 0) - return -1; + x_disk->pdev_path =3D g_strdup(virDomainDiskGetSource(l_disk)); } =20 - if (VIR_STRDUP(x_disk->vdev, l_disk->dst) < 0) - return -1; + x_disk->vdev =3D g_strdup(l_disk->dst); =20 if (driver) { if (STREQ(driver, "tap") || STREQ(driver, "tap2")) { @@ -1159,8 +1135,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_devic= e_disk *x_disk) =20 if (l_disk->domain_name) { #ifdef LIBXL_HAVE_DEVICE_BACKEND_DOMNAME - if (VIR_STRDUP(x_disk->backend_domname, l_disk->domain_name) < 0) - return -1; + x_disk->backend_domname =3D g_strdup(l_disk->domain_name); #else virReportError(VIR_ERR_XML_DETAIL, "%s", _("this version of libxenlight does not " @@ -1289,8 +1264,7 @@ libxlMakeNic(virDomainDefPtr def, "Xen PV(H) domains")); return -1; } - if (VIR_STRDUP(x_nic->model, virDomainNetGetModelString(l_nic)) < = 0) - goto cleanup; + x_nic->model =3D g_strdup(virDomainNetGetModelString(l_nic)); if (l_nic->model =3D=3D VIR_DOMAIN_NET_MODEL_NETFRONT) x_nic->nictype =3D LIBXL_NIC_TYPE_VIF; else @@ -1302,8 +1276,7 @@ libxlMakeNic(virDomainDefPtr def, x_nic->nictype =3D LIBXL_NIC_TYPE_VIF; } =20 - if (VIR_STRDUP(x_nic->ifname, l_nic->ifname) < 0) - goto cleanup; + x_nic->ifname =3D g_strdup(l_nic->ifname); =20 port_profile =3D virDomainNetGetActualVirtPortProfile(l_nic); virt_vlan =3D virDomainNetGetActualVlan(l_nic); @@ -1343,13 +1316,10 @@ libxlMakeNic(virDomainDefPtr def, } if (virBufferCheckError(&buf) < 0) goto cleanup; - if (VIR_STRDUP(x_nic->bridge, - virBufferCurrentContent(&buf)) < 0) - goto cleanup; + x_nic->bridge =3D g_strdup(virBufferCurrentContent(&buf)); G_GNUC_FALLTHROUGH; case VIR_DOMAIN_NET_TYPE_ETHERNET: - if (VIR_STRDUP(x_nic->script, script) < 0) - goto cleanup; + x_nic->script =3D g_strdup(script); if (l_nic->guestIP.nips > 0) { x_nic->ip =3D xenMakeIPList(&l_nic->guestIP); if (!x_nic->ip) @@ -1394,8 +1364,7 @@ libxlMakeNic(virDomainDefPtr def, =20 if (l_nic->domain_name) { #ifdef LIBXL_HAVE_DEVICE_BACKEND_DOMNAME - if (VIR_STRDUP(x_nic->backend_domname, l_nic->domain_name) < 0) - goto cleanup; + x_nic->backend_domname =3D g_strdup(l_nic->domain_name); #else virReportError(VIR_ERR_XML_DETAIL, "%s", _("this version of libxenlight does not " @@ -1508,10 +1477,8 @@ libxlMakeVfb(virPortAllocatorRangePtr graphicsports, libxl_defbool_set(&x_vfb->sdl.enable, 1); libxl_defbool_set(&x_vfb->vnc.enable, 0); libxl_defbool_set(&x_vfb->sdl.opengl, 0); - if (VIR_STRDUP(x_vfb->sdl.display, l_vfb->data.sdl.display) < = 0) - return -1; - if (VIR_STRDUP(x_vfb->sdl.xauthority, l_vfb->data.sdl.xauth) <= 0) - return -1; + x_vfb->sdl.display =3D g_strdup(l_vfb->data.sdl.display); + x_vfb->sdl.xauthority =3D g_strdup(l_vfb->data.sdl.xauth); break; case VIR_DOMAIN_GRAPHICS_TYPE_VNC: libxl_defbool_set(&x_vfb->vnc.enable, 1); @@ -1528,20 +1495,16 @@ libxlMakeVfb(virPortAllocatorRangePtr graphicsports, =20 if ((glisten =3D virDomainGraphicsGetListen(l_vfb, 0))) { if (glisten->address) { - /* libxl_device_vfb_init() does VIR_STRDUP("127.0.0.1"= ) */ + /* libxl_device_vfb_init() does g_strdup("127.0.0.1") = */ VIR_FREE(x_vfb->vnc.listen); - if (VIR_STRDUP(x_vfb->vnc.listen, glisten->address) < = 0) - return -1; + x_vfb->vnc.listen =3D g_strdup(glisten->address); } else { - if (VIR_STRDUP(glisten->address, VIR_LOOPBACK_IPV4_ADD= R) < 0) - return -1; + glisten->address =3D g_strdup(VIR_LOOPBACK_IPV4_ADDR); } } =20 - if (VIR_STRDUP(x_vfb->vnc.passwd, l_vfb->data.vnc.auth.passwd)= < 0) - return -1; - if (VIR_STRDUP(x_vfb->keymap, l_vfb->data.vnc.keymap) < 0) - return -1; + x_vfb->vnc.passwd =3D g_strdup(l_vfb->data.vnc.auth.passwd); + x_vfb->keymap =3D g_strdup(l_vfb->data.vnc.keymap); break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_RDP: @@ -1642,22 +1605,17 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr grap= hicsports, =20 if ((glisten =3D virDomainGraphicsGetListen(l_vfb, 0))) { if (glisten->address) { - if (VIR_STRDUP(b_info->u.hvm.spice.host, glisten->address)= < 0) - return -1; + b_info->u.hvm.spice.host =3D g_strdup(glisten->address); } else { - if (VIR_STRDUP(b_info->u.hvm.spice.host, VIR_LOOPBACK_IPV4= _ADDR) < 0 || - VIR_STRDUP(glisten->address, VIR_LOOPBACK_IPV4_ADDR) <= 0) - return -1; + b_info->u.hvm.spice.host =3D g_strdup(VIR_LOOPBACK_IPV4_AD= DR); + glisten->address =3D g_strdup(VIR_LOOPBACK_IPV4_ADDR); } } =20 - if (VIR_STRDUP(b_info->u.hvm.keymap, l_vfb->data.spice.keymap) < 0) - return -1; + b_info->u.hvm.keymap =3D g_strdup(l_vfb->data.spice.keymap); =20 if (l_vfb->data.spice.auth.passwd) { - if (VIR_STRDUP(b_info->u.hvm.spice.passwd, - l_vfb->data.spice.auth.passwd) < 0) - return -1; + b_info->u.hvm.spice.passwd =3D g_strdup(l_vfb->data.spice.auth= .passwd); libxl_defbool_set(&b_info->u.hvm.spice.disable_ticketing, fals= e); } else { libxl_defbool_set(&b_info->u.hvm.spice.disable_ticketing, true= ); @@ -1693,10 +1651,8 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr graph= icsports, =20 if (libxl_defbool_val(x_vfb.vnc.enable)) { libxl_defbool_set(&b_info->u.hvm.vnc.enable, true); - if (VIR_STRDUP(b_info->u.hvm.vnc.listen, x_vfb.vnc.listen) < 0) - return -1; - if (VIR_STRDUP(b_info->u.hvm.vnc.passwd, x_vfb.vnc.passwd) < 0) - return -1; + b_info->u.hvm.vnc.listen =3D g_strdup(x_vfb.vnc.listen); + b_info->u.hvm.vnc.passwd =3D g_strdup(x_vfb.vnc.passwd); b_info->u.hvm.vnc.display =3D x_vfb.vnc.display; libxl_defbool_set(&b_info->u.hvm.vnc.findunused, libxl_defbool_val(x_vfb.vnc.findunused)); @@ -1704,14 +1660,11 @@ libxlMakeBuildInfoVfb(virPortAllocatorRangePtr grap= hicsports, libxl_defbool_set(&b_info->u.hvm.sdl.enable, true); libxl_defbool_set(&b_info->u.hvm.sdl.opengl, libxl_defbool_val(x_vfb.sdl.opengl)); - if (VIR_STRDUP(b_info->u.hvm.sdl.display, x_vfb.sdl.display) < 0) - return -1; - if (VIR_STRDUP(b_info->u.hvm.sdl.xauthority, x_vfb.sdl.xauthority)= < 0) - return -1; + b_info->u.hvm.sdl.display =3D g_strdup(x_vfb.sdl.display); + b_info->u.hvm.sdl.xauthority =3D g_strdup(x_vfb.sdl.xauthority); } =20 - if (VIR_STRDUP(b_info->u.hvm.keymap, x_vfb.keymap) < 0) - return -1; + b_info->u.hvm.keymap =3D g_strdup(x_vfb.keymap); =20 return 0; } @@ -1766,24 +1719,15 @@ libxlDriverConfigNew(void) if (!(cfg =3D virObjectNew(libxlDriverConfigClass))) return NULL; =20 - if (VIR_STRDUP(cfg->configBaseDir, LIBXL_CONFIG_BASE_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->configDir, LIBXL_CONFIG_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->autostartDir, LIBXL_AUTOSTART_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->logDir, LIBXL_LOG_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->stateDir, LIBXL_STATE_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->libDir, LIBXL_LIB_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->saveDir, LIBXL_SAVE_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->autoDumpDir, LIBXL_DUMP_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->channelDir, LIBXL_CHANNEL_DIR) < 0) - goto error; + cfg->configBaseDir =3D g_strdup(LIBXL_CONFIG_BASE_DIR); + cfg->configDir =3D g_strdup(LIBXL_CONFIG_DIR); + cfg->autostartDir =3D g_strdup(LIBXL_AUTOSTART_DIR); + cfg->logDir =3D g_strdup(LIBXL_LOG_DIR); + cfg->stateDir =3D g_strdup(LIBXL_STATE_DIR); + cfg->libDir =3D g_strdup(LIBXL_LIB_DIR); + cfg->saveDir =3D g_strdup(LIBXL_SAVE_DIR); + cfg->autoDumpDir =3D g_strdup(LIBXL_DUMP_DIR); + cfg->channelDir =3D g_strdup(LIBXL_CHANNEL_DIR); =20 if (virFileMakePath(cfg->logDir) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1832,9 +1776,7 @@ libxlDriverConfigNew(void) cfg->nfirmwares =3D 1; if (VIR_ALLOC(cfg->firmwares[0]) < 0) goto error; - if (VIR_STRDUP(cfg->firmwares[0]->name, - LIBXL_FIRMWARE_DIR "/ovmf.bin") < 0) - goto error; + cfg->firmwares[0]->name =3D g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bin"); #endif =20 /* Always add hvmloader to firmwares */ @@ -1843,9 +1785,7 @@ libxlDriverConfigNew(void) cfg->nfirmwares++; if (VIR_ALLOC(cfg->firmwares[cfg->nfirmwares - 1]) < 0) goto error; - if (VIR_STRDUP(cfg->firmwares[cfg->nfirmwares - 1]->name, - LIBXL_FIRMWARE_DIR "/hvmloader") < 0) - goto error; + cfg->firmwares[cfg->nfirmwares - 1]->name =3D g_strdup(LIBXL_FIRMWARE_= DIR "/hvmloader"); =20 return cfg; =20 @@ -2027,9 +1967,7 @@ libxlMakeChannel(virDomainChrDefPtr l_channel, break; case VIR_DOMAIN_CHR_TYPE_UNIX: x_channel->connection =3D LIBXL_CHANNEL_CONNECTION_SOCKET; - if (VIR_STRDUP(x_channel->u.socket.path, - l_channel->source->data.nix.path) < 0) - return -1; + x_channel->u.socket.path =3D g_strdup(l_channel->source->data.nix.= path); break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -2043,8 +1981,7 @@ libxlMakeChannel(virDomainChrDefPtr l_channel, return -1; } =20 - if (VIR_STRDUP(x_channel->name, l_channel->target.name) < 0) - return -1; + x_channel->name =3D g_strdup(l_channel->target.name); =20 return 0; } diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index eaa35481ed..ceedeb3795 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -610,8 +610,7 @@ libxlAddDom0(libxlDriverPrivatePtr driver) =20 def->id =3D 0; def->virtType =3D VIR_DOMAIN_VIRT_XEN; - if (VIR_STRDUP(def->name, "Domain-0") < 0) - goto cleanup; + def->name =3D g_strdup("Domain-0"); =20 def->os.type =3D VIR_DOMAIN_OSTYPE_XEN; =20 @@ -1577,8 +1576,7 @@ libxlDomainGetOSType(virDomainPtr dom) if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0) - goto cleanup; + type =3D g_strdup(virDomainOSTypeToString(vm->def->os.type)); =20 cleanup: virDomainObjEndAPI(&vm); @@ -5438,8 +5436,7 @@ libxlDomainBlockStatsVBD(virDomainObjPtr vm, =20 size =3D libxlDiskSectorSize(vm->def->id, devno); =20 - if (VIR_STRDUP(stats->backend, "vbd") < 0) - return ret; + stats->backend =3D g_strdup("vbd"); =20 if (virAsprintf(&path, "/sys/bus/xen-backend/devices/vbd-%d-%d/statist= ics", vm->def->id, devno) < 0) @@ -6306,19 +6303,16 @@ libxlGetDHCPInterfaces(virDomainPtr dom, if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) goto error; =20 - if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0) - goto cleanup; + iface->name =3D g_strdup(vm->def->nets[i]->ifname); =20 - if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) - goto cleanup; + iface->hwaddr =3D g_strdup(macaddr); } =20 for (j =3D 0; j < n_leases; j++) { virNetworkDHCPLeasePtr lease =3D leases[j]; virDomainIPAddressPtr ip_addr =3D &iface->addrs[j]; =20 - if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0) - goto cleanup; + ip_addr->addr =3D g_strdup(lease->ipaddr); =20 ip_addr->type =3D lease->type; ip_addr->prefix =3D lease->prefix; diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 770a300316..0a57b6fcb0 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -94,8 +94,7 @@ libxlMigrationCookieNew(virDomainObjPtr dom) if (VIR_ALLOC(mig) < 0) goto error; =20 - if (VIR_STRDUP(mig->name, dom->def->name) < 0) - goto error; + mig->name =3D g_strdup(dom->def->name); =20 memcpy(mig->uuid, dom->def->uuid, VIR_UUID_BUFLEN); =20 @@ -462,10 +461,7 @@ libxlDomainMigrationDstPrepareDef(libxlDriverPrivatePt= r driver, =20 if (dname) { name =3D def->name; - if (VIR_STRDUP(def->name, dname) < 0) { - virDomainDefFree(def); - def =3D NULL; - } + def->name =3D g_strdup(dname); } =20 cleanup: diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 1a36a632aa..cc9039a0cf 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -236,8 +236,7 @@ xenConfigGetString(virConfPtr conf, return -1; =20 if (rc =3D=3D 0 || !string) { - if (VIR_STRDUP(*value, def) < 0) - return -1; + *value =3D g_strdup(def); } else { *value =3D string; } @@ -277,10 +276,7 @@ xenConfigSetString(virConfPtr conf, const char *settin= g, const char *str) =20 value->type =3D VIR_CONF_STRING; value->next =3D NULL; - if (VIR_STRDUP(value->str, str) < 0) { - VIR_FREE(value); - return -1; - } + value->str =3D g_strdup(str); =20 return virConfSetValue(conf, setting, value); } @@ -702,14 +698,11 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) if (STREQ(key + 10, "1")) graphics->data.vnc.autoport =3D true; } else if (STRPREFIX(key, "vnclisten=3D")) { - if (VIR_STRDUP(listenAddr, key+10) < 0) - goto cleanup; + listenAddr =3D g_strdup(key + 10); } else if (STRPREFIX(key, "vncpasswd=3D")) { - if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key= + 10) < 0) - goto cleanup; + graphics->data.vnc.auth.passwd =3D g_strdup(key + = 10); } else if (STRPREFIX(key, "keymap=3D")) { - if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7)= < 0) - goto cleanup; + graphics->data.vnc.keymap =3D g_strdup(key + 7); } else if (STRPREFIX(key, "vncdisplay=3D")) { if (virStrToLong_i(key + 11, NULL, 10, &graphics->data.vnc.port) < 0) { @@ -722,11 +715,9 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) } } else { if (STRPREFIX(key, "display=3D")) { - if (VIR_STRDUP(graphics->data.sdl.display, key + 8= ) < 0) - goto cleanup; + graphics->data.sdl.display =3D g_strdup(key + 8); } else if (STRPREFIX(key, "xauthority=3D")) { - if (VIR_STRDUP(graphics->data.sdl.xauth, key + 11)= < 0) - goto cleanup; + graphics->data.sdl.xauth =3D g_strdup(key + 11); } } =20 @@ -786,8 +777,7 @@ xenParseSxprChar(const char *value, =20 if (value[0] =3D=3D '/') { def->source->type =3D VIR_DOMAIN_CHR_TYPE_DEV; - if (VIR_STRDUP(def->source->data.file.path, value) < 0) - goto error; + def->source->data.file.path =3D g_strdup(value); } else { if ((tmp =3D strchr(value, ':')) !=3D NULL) { *tmp =3D '\0'; @@ -808,14 +798,12 @@ xenParseSxprChar(const char *value, =20 switch (def->source->type) { case VIR_DOMAIN_CHR_TYPE_PTY: - if (VIR_STRDUP(def->source->data.file.path, tty) < 0) - goto error; + def->source->data.file.path =3D g_strdup(tty); break; =20 case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PIPE: - if (VIR_STRDUP(def->source->data.file.path, value) < 0) - goto error; + def->source->data.file.path =3D g_strdup(value); break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: @@ -877,11 +865,9 @@ xenParseSxprChar(const char *value, offset2 + 1, offset3 - offset2 - 1) < 0) goto error; =20 - if (VIR_STRDUP(def->source->data.udp.bindService, offset3 + 1)= < 0) - goto error; + def->source->data.udp.bindService =3D g_strdup(offset3 + 1); } else { - if (VIR_STRDUP(def->source->data.udp.connectService, offset + = 1) < 0) - goto error; + def->source->data.udp.connectService =3D g_strdup(offset + 1); } } break; @@ -1034,10 +1020,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *brid= ge) if (!vlanstr_list) return -1; =20 - if (VIR_STRDUP(net->data.bridge.brname, vlanstr_list[0]) < 0) { - virStringListFree(vlanstr_list); - return -1; - } + net->data.bridge.brname =3D g_strdup(vlanstr_list[0]); =20 for (i =3D 1; vlanstr_list[i]; i++) nvlans++; @@ -1065,8 +1048,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridg= e) return 0; } else { /* 'bridge' string only contains the bridge name */ - if (VIR_STRDUP(net->data.bridge.brname, bridge) < 0) - return -1; + net->data.bridge.brname =3D g_strdup(bridge); } =20 return 0; @@ -1086,8 +1068,7 @@ xenParseSxprVifRate(const char *rate, unsigned long l= ong *kbytes_per_sec) unsigned long long tmp; int ret =3D -1; =20 - if (VIR_STRDUP(trate, rate) < 0) - return -1; + trate =3D g_strdup(rate); =20 p =3D strchr(trate, '@'); if (p !=3D NULL) @@ -1271,9 +1252,8 @@ xenParseVif(char *entry, const char *vif_typename) virStringListFree(ip_list); } =20 - if (script && script[0] && - VIR_STRDUP(net->script, script) < 0) - goto cleanup; + if (script && script[0]) + net->script =3D g_strdup(script); =20 if (model[0]) { if (virDomainNetSetModelString(net, model) < 0) @@ -1283,9 +1263,8 @@ xenParseVif(char *entry, const char *vif_typename) net->model =3D VIR_DOMAIN_NET_MODEL_NETFRONT; } =20 - if (vifname[0] && - VIR_STRDUP(net->ifname, vifname) < 0) - goto cleanup; + if (vifname[0]) + net->ifname =3D g_strdup(vifname); =20 if (rate[0]) { virNetDevBandwidthPtr bandwidth; @@ -1482,8 +1461,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr = def, virCapsPtr caps) goto out; =20 def->os.arch =3D capsdata->arch; - if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0) - goto out; + def->os.machine =3D g_strdup(capsdata->machinetype); =20 ret =3D 0; out: diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index cbd3364fe9..6bdad2a59d 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -78,8 +78,7 @@ static int xenParseCmdline(virConfPtr conf, char **r_cmdl= ine) return -1; =20 if (buf) { - if (VIR_STRDUP(cmdline, buf) < 0) - return -1; + cmdline =3D g_strdup(buf); if (root || extra) VIR_WARN("ignoring root=3D and extra=3D in favour of cmdline= =3D"); } else { @@ -90,8 +89,7 @@ static int xenParseCmdline(virConfPtr conf, char **r_cmdl= ine) if (virAsprintf(&cmdline, "root=3D%s", root) < 0) return -1; } else if (extra) { - if (VIR_STRDUP(cmdline, extra) < 0) - return -1; + cmdline =3D g_strdup(extra); } } =20 @@ -119,17 +117,14 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, vi= rCapsPtr caps) def->os.loader->type =3D VIR_DOMAIN_LOADER_TYPE_PFLASH; def->os.loader->readonly =3D VIR_TRISTATE_BOOL_YES; =20 - if (VIR_STRDUP(def->os.loader->path, - LIBXL_FIRMWARE_DIR "/ovmf.bin") < 0) - return -1; + def->os.loader->path =3D g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bi= n"); } else { for (i =3D 0; i < caps->nguests; i++) { if (caps->guests[i]->ostype =3D=3D VIR_DOMAIN_OSTYPE_HVM && caps->guests[i]->arch.id =3D=3D def->os.arch) { - if (VIR_ALLOC(def->os.loader) < 0 || - VIR_STRDUP(def->os.loader->path, - caps->guests[i]->arch.defaultInfo.loade= r) < 0) + if (VIR_ALLOC(def->os.loader) < 0) return -1; + def->os.loader->path =3D g_strdup(caps->guests[i]->arc= h.defaultInfo.loader); } } } @@ -538,8 +533,7 @@ xenParseXLVnuma(virConfPtr conf, } =20 VIR_FREE(tmp); - if (VIR_STRDUP(tmp, vtoken) < 0) - goto cleanup; + tmp =3D g_strdup(vtoken); =20 virStringListFree(token); if (!(token =3D virStringSplitCount(tmp, ",", 0, &= ndistances))) @@ -736,8 +730,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def) if (xenParseXLDiskSrc(disk, libxldisk->pdev_path) < 0) goto fail; =20 - if (VIR_STRDUP(disk->dst, libxldisk->vdev) < 0) - goto fail; + disk->dst =3D g_strdup(libxldisk->vdev); =20 disk->src->readonly =3D !libxldisk->readwrite; disk->removable =3D libxldisk->removable; @@ -1376,8 +1369,7 @@ xenFormatXLCPUID(virConfPtr conf, virDomainDefPtr def) if (VIR_ALLOC_N(cpuid_pairs, def->cpu->nfeatures + 2) < 0) return -1; =20 - if (VIR_STRDUP(cpuid_pairs[0], "host") < 0) - goto cleanup; + cpuid_pairs[0] =3D g_strdup("host"); =20 j =3D 1; for (i =3D 0; i < def->cpu->nfeatures; i++) { @@ -1659,8 +1651,7 @@ xenFormatXLDiskSrc(virStorageSourcePtr src, char **sr= cstr) case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: - if (VIR_STRDUP(*srcstr, src->path) < 0) - return -1; + *srcstr =3D g_strdup(src->path); break; =20 case VIR_STORAGE_TYPE_NETWORK: @@ -1947,8 +1938,7 @@ xenFormatXLInputDevs(virConfPtr conf, virDomainDefPtr= def) lastdev =3D lastdev->next; } lastdev->type =3D VIR_CONF_STRING; - if (VIR_STRDUP(lastdev->str, devtype) < 0) - goto error; + lastdev->str =3D g_strdup(devtype); } } if (usbdevices->list !=3D NULL) { diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index e368482cac..fdf4e1cd29 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -96,8 +96,7 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) if (virAsprintf(&def->os.cmdline, "root=3D%s", root) < 0) return -1; } else if (extra) { - if (VIR_STRDUP(def->os.cmdline, extra) < 0) - return -1; + def->os.cmdline =3D g_strdup(extra); } } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576196; cv=none; d=zoho.com; s=zohoarc; b=WjGsnB6Eug/sqCskrFNxLcYWlxYFGl2GaXJmtkm6zJ8loK6erGSmCRis0BdWpA50bKT66FxoeIXpmtze5Awh1YWzPctE7UImI4DCwBVti45xEsxqp+nFay+NbIOjfMtSepV3cPYHGwYo2ZfD7zs7A2zUw0x6lJOt32+yHk/CAF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576196; 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=IaJsPUUYfm+NmdFF7xBGHQ+j20Vpch9UJppmU2egy/M=; b=kcZzPtS8c/A0lkYazE9zGfiYp/ZtMZmpQhNxFHti3nA6lwLKzT47eu5mvn+DgGzPuB2+gbvkWIubnFTBypEX2ocsDqNO8CRqQsV4vtWIL/RYr7sJ/EuOttDxrX5zIY0Q/3xkEMjkldC1tPWRaPeuRfVtiMbP9JI3fTc9WhdZs0Q= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 157157619622829.080016296133522; Sun, 20 Oct 2019 05:56:36 -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-265-Pd-PMOdNMqebjwEH_CtPBw-1; Sun, 20 Oct 2019 08:56:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4FE1801E5F; Sun, 20 Oct 2019 12:56:14 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 87C6D60C05; Sun, 20 Oct 2019 12:56:14 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3B096180BA9D; Sun, 20 Oct 2019 12:56:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtrYl023466 for ; Sun, 20 Oct 2019 08:55:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3978F3DA3; Sun, 20 Oct 2019 12:55:53 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B1EE3CC8 for ; Sun, 20 Oct 2019 12:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576195; 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=IaJsPUUYfm+NmdFF7xBGHQ+j20Vpch9UJppmU2egy/M=; b=drQl6JGvzKGWd2A2SeShHZ7R3l8VaAYsI1E7u26frxMaUs6s+O5h70XgpR8mx/AJ16/m8h 7B5Jb14OG9gyP8Wy/q2SZAb/Bj95HKFXk2O2IEKzkxaD5XYPJMF/5CydTdVeLRSztkag0k njDl7B0J1p+VjnRo40GKuYlJNmztTx8= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/34] locking: use g_strdup instead of VIR_STRDUP 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-MC-Unique: Pd-PMOdNMqebjwEH_CtPBw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/locking/lock_daemon.c | 24 +++++++----------------- src/locking/lock_daemon_config.c | 3 +-- src/locking/lock_daemon_dispatch.c | 3 +-- src/locking/lock_driver_lockd.c | 24 ++++++++---------------- src/locking/lock_driver_sanlock.c | 12 ++---------- src/locking/lock_manager.c | 3 +-- 6 files changed, 20 insertions(+), 49 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 0894ee8e93..7d8c11a2a3 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -447,9 +447,8 @@ virLockDaemonUnixSocketPaths(bool privileged, char **adminSockfile) { if (privileged) { - if (VIR_STRDUP(*sockfile, RUNSTATEDIR "/libvirt/virtlockd-sock") <= 0 || - VIR_STRDUP(*adminSockfile, RUNSTATEDIR "/libvirt/virtlockd-adm= in-sock") < 0) - goto error; + *sockfile =3D g_strdup(RUNSTATEDIR "/libvirt/virtlockd-sock"); + *adminSockfile =3D g_strdup(RUNSTATEDIR "/libvirt/virtlockd-admin-= sock"); } else { char *rundir =3D NULL; mode_t old_umask; @@ -760,8 +759,7 @@ virLockDaemonClientNewPostExecRestart(virNetServerClien= tPtr client, _("Missing ownerName data in JSON document")); goto error; } - if (VIR_STRDUP(priv->ownerName, ownerName) < 0) - goto error; + priv->ownerName =3D g_strdup(ownerName); if (!(ownerUUID =3D virJSONValueObjectGetString(object, "ownerUUID")))= { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing ownerUUID data in JSON document")); @@ -831,8 +829,7 @@ virLockDaemonExecRestartStatePath(bool privileged, char **state_file) { if (privileged) { - if (VIR_STRDUP(*state_file, RUNSTATEDIR "/virtlockd-restart-exec.j= son") < 0) - goto error; + *state_file =3D g_strdup(RUNSTATEDIR "/virtlockd-restart-exec.json= "); } else { char *rundir =3D NULL; mode_t old_umask; @@ -1162,14 +1159,12 @@ int main(int argc, char **argv) { =20 case 'p': VIR_FREE(pid_file); - if (VIR_STRDUP_QUIET(pid_file, optarg) < 0) - goto no_memory; + pid_file =3D g_strdup(optarg); break; =20 case 'f': VIR_FREE(remote_config_file); - if (VIR_STRDUP_QUIET(remote_config_file, optarg) < 0) - goto no_memory; + remote_config_file =3D g_strdup(optarg); break; =20 case 'V': @@ -1247,8 +1242,7 @@ int main(int argc, char **argv) { =20 /* Ensure the rundir exists (on tmpfs on some systems) */ if (privileged) { - if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0) - goto no_memory; + run_dir =3D g_strdup(RUNSTATEDIR "/libvirt"); } else { if (!(run_dir =3D virGetUserRuntimeDirectory())) { VIR_ERROR(_("Can't determine user directory")); @@ -1448,8 +1442,4 @@ int main(int argc, char **argv) { VIR_FREE(run_dir); virLockDaemonConfigFree(config); return ret; - - no_memory: - VIR_ERROR(_("Can't allocate memory")); - exit(EXIT_FAILURE); } diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_con= fig.c index a506423e5e..6e635f1e0b 100644 --- a/src/locking/lock_daemon_config.c +++ b/src/locking/lock_daemon_config.c @@ -39,8 +39,7 @@ int virLockDaemonConfigFilePath(bool privileged, char **configfile) { if (privileged) { - if (VIR_STRDUP(*configfile, SYSCONFDIR "/libvirt/virtlockd.conf") = < 0) - goto error; + *configfile =3D g_strdup(SYSCONFDIR "/libvirt/virtlockd.conf"); } else { char *configdir =3D NULL; =20 diff --git a/src/locking/lock_daemon_dispatch.c b/src/locking/lock_daemon_d= ispatch.c index d68fd9cf01..1a53772366 100644 --- a/src/locking/lock_daemon_dispatch.c +++ b/src/locking/lock_daemon_dispatch.c @@ -277,8 +277,7 @@ virLockSpaceProtocolDispatchRegister(virNetServerPtr se= rver G_GNUC_UNUSED, goto cleanup; } =20 - if (VIR_STRDUP(priv->ownerName, args->owner.name) < 0) - goto cleanup; + priv->ownerName =3D g_strdup(args->owner.name); memcpy(priv->ownerUUID, args->owner.uuid, VIR_UUID_BUFLEN); priv->ownerId =3D args->owner.id; priv->ownerPid =3D args->owner.pid; diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index 8277e5ba92..9452f2957c 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -120,8 +120,7 @@ static char *virLockManagerLockDaemonPath(bool privileg= ed) { char *path; if (privileged) { - if (VIR_STRDUP(path, RUNSTATEDIR "/libvirt/virtlockd-sock") < 0) - return NULL; + path =3D g_strdup(RUNSTATEDIR "/libvirt/virtlockd-sock"); } else { char *rundir =3D NULL; =20 @@ -422,8 +421,7 @@ static int virLockManagerLockDaemonNew(virLockManagerPt= r lock, if (STREQ(params[i].key, "uuid")) { memcpy(priv->uuid, params[i].value.uuid, VIR_UUID_BUFLEN); } else if (STREQ(params[i].key, "name")) { - if (VIR_STRDUP(priv->name, params[i].value.str) < 0) - goto cleanup; + priv->name =3D g_strdup(params[i].value.str); } else if (STREQ(params[i].key, "id")) { priv->id =3D params[i].value.iv; } else if (STREQ(params[i].key, "pid")) { @@ -515,8 +513,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, =20 if (newName) { VIR_DEBUG("Got an LVM UUID %s for %s", newName, name); - if (VIR_STRDUP(newLockspace, driver->lvmLockSpaceDir) < 0) - goto cleanup; + newLockspace =3D g_strdup(driver->lvmLockSpaceDir); autoCreate =3D true; break; } @@ -532,8 +529,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, =20 if (newName) { VIR_DEBUG("Got an SCSI ID %s for %s", newName, name); - if (VIR_STRDUP(newLockspace, driver->scsiLockSpaceDir) < 0) - goto cleanup; + newLockspace =3D g_strdup(driver->scsiLockSpaceDir); autoCreate =3D true; break; } @@ -542,17 +538,14 @@ static int virLockManagerLockDaemonAddResource(virLoc= kManagerPtr lock, } =20 if (driver->fileLockSpaceDir) { - if (VIR_STRDUP(newLockspace, driver->fileLockSpaceDir) < 0) - goto cleanup; + newLockspace =3D g_strdup(driver->fileLockSpaceDir); if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &newName= ) < 0) goto cleanup; autoCreate =3D true; VIR_DEBUG("Using indirect lease %s for %s", newName, name); } else { - if (VIR_STRDUP(newLockspace, "") < 0) - goto cleanup; - if (VIR_STRDUP(newName, name) < 0) - goto cleanup; + newLockspace =3D g_strdup(""); + newName =3D g_strdup(name); VIR_DEBUG("Using direct lease for %s", name); } =20 @@ -587,8 +580,7 @@ static int virLockManagerLockDaemonAddResource(virLockM= anagerPtr lock, if (virAsprintf(&newLockspace, "%s/%s", path, lockspace) < 0) goto cleanup; - if (VIR_STRDUP(newName, name) < 0) - goto cleanup; + newName =3D g_strdup(name); =20 } break; default: diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sa= nlock.c index 1d1691f6ba..beeeb6066b 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -440,10 +440,7 @@ static int virLockManagerSanlockInit(unsigned int vers= ion, driver->io_timeout =3D 0; driver->user =3D (uid_t) -1; driver->group =3D (gid_t) -1; - if (VIR_STRDUP(driver->autoDiskLeasePath, LOCALSTATEDIR "/lib/libvirt/= sanlock") < 0) { - VIR_FREE(driver); - goto error; - } + driver->autoDiskLeasePath =3D g_strdup(LOCALSTATEDIR "/lib/libvirt/san= lock"); =20 if (virLockManagerSanlockLoadConfig(driver, configFile) < 0) goto error; @@ -514,8 +511,7 @@ static int virLockManagerSanlockNew(virLockManagerPtr l= ock, if (STREQ(param->key, "uuid")) { memcpy(priv->vm_uuid, param->value.uuid, 16); } else if (STREQ(param->key, "name")) { - if (VIR_STRDUP(priv->vm_name, param->value.str) < 0) - goto error; + priv->vm_name =3D g_strdup(param->value.str); } else if (STREQ(param->key, "pid")) { priv->vm_pid =3D param->value.iv; } else if (STREQ(param->key, "id")) { @@ -540,10 +536,6 @@ static int virLockManagerSanlockNew(virLockManagerPtr = lock, =20 lock->privateData =3D priv; return 0; - - error: - VIR_FREE(priv); - return -1; } =20 static void virLockManagerSanlockFree(virLockManagerPtr lock) diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c index c6940e5a69..6898bfc556 100644 --- a/src/locking/lock_manager.c +++ b/src/locking/lock_manager.c @@ -179,8 +179,7 @@ virLockManagerPluginPtr virLockManagerPluginNew(const c= har *name, plugin->driver =3D driver; plugin->handle =3D handle; plugin->refs =3D 1; - if (VIR_STRDUP(plugin->name, name) < 0) - goto cleanup; + plugin->name =3D g_strdup(name); =20 VIR_FREE(configFile); VIR_FREE(modfile); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576205; cv=none; d=zoho.com; s=zohoarc; b=ap+CmLFO+59sqCL7r6+6kXGtSO4J6Co+5ygLD6WcSvkD30T6g9yQf8lpP8AidHDz9CkNE1Nc3ccAdkRfbusc+xk9rt6qpTuxkPP3Y+wpm+F8eHT+JLKWgBsi6Pk9+vKW5hDf3/zgQcuSvL7+xYTFmo6+5anRVRjyqvJ5YQ4t0Fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576205; 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=Xt6oMG+l4IZBwYBAxIJfgq5Xxh/DFnlGO1bvnmiRHO0=; b=CvMmCQyw4gd9HlCHSUINTbvoBhcv1i0QXf+E2N/+y5eBw9JoD9GYU1AzBdet9RhGL/mKlQ8OhnrfsxNtHCOEVpgVaXjwLiJEhDkPcr/hauL3yg2MLIx0TZMA+8kEWaJ0aOqKJJvlOhT8GxpNPMGcVgUvN6TdsQLJap3sXN1Wk3E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576205586742.8731904152056; Sun, 20 Oct 2019 05:56:45 -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-145-CY6bgWp3OD63upBmrWGVmA-1; Sun, 20 Oct 2019 08:56:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D779107AFD9; Sun, 20 Oct 2019 12:56:36 +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 6868C5D6A7; Sun, 20 Oct 2019 12:56:36 +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 2E5573FB45; Sun, 20 Oct 2019 12:56:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCts9Q023471 for ; Sun, 20 Oct 2019 08:55:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 364A63CC8; Sun, 20 Oct 2019 12:55:54 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1805194B9 for ; Sun, 20 Oct 2019 12:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576204; 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=Xt6oMG+l4IZBwYBAxIJfgq5Xxh/DFnlGO1bvnmiRHO0=; b=h1bXjQvB8HvOioBIdG5oa3DT5jkGpB6HFUqzzw5cSJZbnpZb9hsOSFPrtMWSQUswwcglPB fy/sr93BgKwfK1g4BVPwEteL+LxNO9HmX88v7nMncdcj+VvdusZTD7N2Bvmohu1NrZ1yvi LSe/rHI/4dbFyuMLNPOd0YtmJoEi+ic= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:35 +0200 Message-Id: <5d0ce4f141c83c8082b8f9cf287e12802ce3e1bf.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/34] logging: use g_strdup instead of VIR_STRDUP 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.15 X-MC-Unique: CY6bgWp3OD63upBmrWGVmA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/logging/log_daemon.c | 21 ++++++--------------- src/logging/log_daemon_config.c | 3 +-- src/logging/log_handler.c | 11 ++++------- src/logging/log_manager.c | 3 +-- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 851695b109..73bd3c4ac2 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -388,9 +388,8 @@ virLogDaemonUnixSocketPaths(bool privileged, char **adminSockfile) { if (privileged) { - if (VIR_STRDUP(*sockfile, RUNSTATEDIR "/libvirt/virtlogd-sock") < = 0 || - VIR_STRDUP(*adminSockfile, RUNSTATEDIR "/libvirt/virtlogd-admi= n-sock") < 0) - goto error; + *sockfile =3D g_strdup(RUNSTATEDIR "/libvirt/virtlogd-sock"); + *adminSockfile =3D g_strdup(RUNSTATEDIR "/libvirt/virtlogd-admin-s= ock"); } else { char *rundir =3D NULL; mode_t old_umask; @@ -623,8 +622,7 @@ virLogDaemonExecRestartStatePath(bool privileged, char **state_file) { if (privileged) { - if (VIR_STRDUP(*state_file, RUNSTATEDIR "/virtlogd-restart-exec.js= on") < 0) - goto error; + *state_file =3D g_strdup(RUNSTATEDIR "/virtlogd-restart-exec.json"= ); } else { char *rundir =3D NULL; mode_t old_umask; @@ -934,14 +932,12 @@ int main(int argc, char **argv) { =20 case 'p': VIR_FREE(pid_file); - if (VIR_STRDUP_QUIET(pid_file, optarg) < 0) - goto no_memory; + pid_file =3D g_strdup(optarg); break; =20 case 'f': VIR_FREE(remote_config_file); - if (VIR_STRDUP_QUIET(remote_config_file, optarg) < 0) - goto no_memory; + remote_config_file =3D g_strdup(optarg); break; =20 case 'V': @@ -1018,8 +1014,7 @@ int main(int argc, char **argv) { =20 /* Ensure the rundir exists (on tmpfs on some systems) */ if (privileged) { - if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0) - goto no_memory; + run_dir =3D g_strdup(RUNSTATEDIR "/libvirt"); } else { if (!(run_dir =3D virGetUserRuntimeDirectory())) { VIR_ERROR(_("Can't determine user directory")); @@ -1220,8 +1215,4 @@ int main(int argc, char **argv) { VIR_FREE(remote_config_file); virLogDaemonConfigFree(config); return ret; - - no_memory: - VIR_ERROR(_("Can't allocate memory")); - exit(EXIT_FAILURE); } diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_confi= g.c index c339da1808..df7c6339b7 100644 --- a/src/logging/log_daemon_config.c +++ b/src/logging/log_daemon_config.c @@ -40,8 +40,7 @@ int virLogDaemonConfigFilePath(bool privileged, char **configfile) { if (privileged) { - if (VIR_STRDUP(*configfile, SYSCONFDIR "/libvirt/virtlogd.conf") <= 0) - goto error; + *configfile =3D g_strdup(SYSCONFDIR "/libvirt/virtlogd.conf"); } else { char *configdir =3D NULL; =20 diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index 025a546b51..29ea3011b9 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -239,16 +239,14 @@ virLogHandlerLogFilePostExecRestart(virLogHandlerPtr = handler, _("Missing 'driver' in JSON document")); goto error; } - if (VIR_STRDUP(file->driver, tmp) < 0) - goto error; + file->driver =3D g_strdup(tmp); =20 if ((tmp =3D virJSONValueObjectGetString(object, "domname")) =3D=3D NU= LL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing 'domname' in JSON document")); goto error; } - if (VIR_STRDUP(file->domname, tmp) < 0) - goto error; + file->domname =3D g_strdup(tmp); =20 if ((domuuid =3D virJSONValueObjectGetString(object, "domuuid")) =3D= =3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -402,9 +400,8 @@ virLogHandlerDomainOpenLogFile(virLogHandlerPtr handler, file->pipefd =3D pipefd[0]; pipefd[0] =3D -1; memcpy(file->domuuid, domuuid, VIR_UUID_BUFLEN); - if (VIR_STRDUP(file->driver, driver) < 0 || - VIR_STRDUP(file->domname, domname) < 0) - goto error; + file->driver =3D g_strdup(driver); + file->domname =3D g_strdup(domname); =20 if ((file->file =3D virRotatingFileWriterNew(path, handler->max_size, diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c index 1613d1f8a8..b60a6aaf59 100644 --- a/src/logging/log_manager.c +++ b/src/logging/log_manager.c @@ -45,8 +45,7 @@ virLogManagerDaemonPath(bool privileged) { char *path; if (privileged) { - if (VIR_STRDUP(path, RUNSTATEDIR "/libvirt/virtlogd-sock") < 0) - return NULL; + path =3D g_strdup(RUNSTATEDIR "/libvirt/virtlogd-sock"); } else { char *rundir =3D NULL; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576193; cv=none; d=zoho.com; s=zohoarc; b=mSNeTZVTxi5Ber0EXbb7YhgdDk/ipoErpOHqpKYso4s/qkQgO0HcRMFEpORzZaIYHtbHAOBkMpOTRWBXUfc2m8QLk8/KIwzzWf1gW6Gs/vF8eM5qpQyAxqScq7WL54jeFwrxDwleIvcp/LJhjA+EcvgOuDC94FVD/yBSAufgO1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576193; 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=Uw6vlVp7KfPUbXL3muaiN36dfKs/QHInKzHesy8ZweI=; b=LmGeELHmuRD3T4M8KwhDnV41yDvQbld/jPHF6r+TGBCYlVzsZhzz/6ClJ/nhHKeR3nH6KU4XAM79738WuuTN8u/ODWAx4rAqUnQhq2LLJ/W+bLQxMMwKAELYhBVUVzcgQThC55s/uwbRGQd7wTSxsIg3bUh5zXJtG/4a7eHe6lY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 15715761936471004.3788182977007; Sun, 20 Oct 2019 05:56:33 -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-164-AA8LJuWiPsixCjDFyEeqhQ-1; Sun, 20 Oct 2019 08:56:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6483D107AD35; Sun, 20 Oct 2019 12:56:18 +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 408FF9473; Sun, 20 Oct 2019 12:56:18 +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 0863F4EE70; Sun, 20 Oct 2019 12:56:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCttV3023485 for ; Sun, 20 Oct 2019 08:55:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 517FE3CC8; Sun, 20 Oct 2019 12:55:55 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1D309446 for ; Sun, 20 Oct 2019 12:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576192; 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=Uw6vlVp7KfPUbXL3muaiN36dfKs/QHInKzHesy8ZweI=; b=OlNEQz7lpu9XBhGbNuXceSq6uVNrwFj19+A5csFqLN1SbTWWH7oG3mqcimvHdP03Pq7E9q agv8azcUXPfHMjDCU0KwsXvdbv2dagiChiOfZ4E/GJHg5erARUGSftB6qBkBCHvNDHc3FG GhNYMwNNuei5kHPWxaMShbl2JtYunow= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:36 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 18/34] lxc: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: AA8LJuWiPsixCjDFyEeqhQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/lxc/lxc_conf.c | 21 ++++---------- src/lxc/lxc_container.c | 20 +++++-------- src/lxc/lxc_controller.c | 12 +++----- src/lxc/lxc_driver.c | 3 +- src/lxc/lxc_native.c | 63 +++++++++++++++------------------------- src/lxc/lxc_process.c | 13 +++------ 6 files changed, 46 insertions(+), 86 deletions(-) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 4d8314045e..de9793e523 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -150,10 +150,8 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) if (VIR_ALLOC(caps->host.secModels) < 0) goto error; caps->host.nsecModels =3D 1; - if (VIR_STRDUP(caps->host.secModels[0].model, model) < 0) - goto error; - if (VIR_STRDUP(caps->host.secModels[0].doi, doi) < 0) - goto error; + caps->host.secModels[0].model =3D g_strdup(model); + caps->host.secModels[0].doi =3D g_strdup(doi); if (label && virCapabilitiesHostSecModelAddBaseLabel(&caps->host.secModels[= 0], type, @@ -233,19 +231,12 @@ virLXCDriverConfigNew(void) cfg->securityRequireConfined =3D false; =20 /* Set the container configuration directory */ - if (VIR_STRDUP(cfg->configDir, LXC_CONFIG_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->stateDir, LXC_STATE_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->logDir, LXC_LOG_DIR) < 0) - goto error; - if (VIR_STRDUP(cfg->autostartDir, LXC_AUTOSTART_DIR) < 0) - goto error; + cfg->configDir =3D g_strdup(LXC_CONFIG_DIR); + cfg->stateDir =3D g_strdup(LXC_STATE_DIR); + cfg->logDir =3D g_strdup(LXC_LOG_DIR); + cfg->autostartDir =3D g_strdup(LXC_AUTOSTART_DIR); =20 return cfg; - error: - virObjectUnref(cfg); - return NULL; } =20 int diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 5002356fe7..88dc2e2bdf 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -856,8 +856,9 @@ static int lxcContainerSetReadOnly(void) lxcIsBasicMountLocation(mntent.mnt_dir)) continue; =20 - if (VIR_STRDUP(tmp, mntent.mnt_dir) < 0 || - VIR_APPEND_ELEMENT(mounts, nmounts, tmp) < 0) { + tmp =3D g_strdup(mntent.mnt_dir); + + if (VIR_APPEND_ELEMENT(mounts, nmounts, tmp) < 0) { VIR_FREE(tmp); goto cleanup; } @@ -910,12 +911,10 @@ static int lxcContainerMountBasicFS(bool userns_enabl= ed, */ if (userns_enabled && netns_disabled && STREQ(mnt->src, "sysfs")) { - if (VIR_STRDUP(mnt_src, "/sys") < 0) - goto cleanup; + mnt_src =3D g_strdup("/sys"); mnt_mflags =3D MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY|MS_BIND; } else { - if (VIR_STRDUP(mnt_src, mnt->src) < 0) - goto cleanup; + mnt_src =3D g_strdup(mnt->src); mnt_mflags =3D mnt->mflags; } =20 @@ -1292,8 +1291,7 @@ lxcContainerMountDetectFilesystem(const char *src, ch= ar **type) goto cleanup; } =20 - if (VIR_STRDUP(*type, data) < 0) - goto cleanup; + *type =3D g_strdup(data); =20 done: ret =3D 0; @@ -1633,8 +1631,7 @@ int lxcContainerSetupHostdevCapsMakePath(const char *= dev) int ret =3D -1; char *dir, *tmp; =20 - if (VIR_STRDUP(dir, dev) < 0) - return -1; + dir =3D g_strdup(dev); =20 if ((tmp =3D strrchr(dir, '/'))) { *tmp =3D '\0'; @@ -2166,8 +2163,7 @@ static int lxcContainerSetHostname(virDomainDefPtr de= f) char *hostname =3D NULL; =20 /* Filter the VM name to get a valid hostname */ - if (VIR_STRDUP(name, def->name) < 0) - goto cleanup; + name =3D g_strdup(def->name); =20 /* RFC 1123 allows 0-9 digits as a first character in hostname */ virStringFilterChars(name, hostname_validchars); diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 3c4e68524c..0c5b9e713d 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -172,8 +172,7 @@ static virLXCControllerPtr virLXCControllerNew(const ch= ar *name) ctrl->timerShutdown =3D -1; ctrl->firstClient =3D true; =20 - if (VIR_STRDUP(ctrl->name, name) < 0) - goto error; + ctrl->name =3D g_strdup(name); =20 if (!(caps =3D virLXCDriverCapsInit(NULL))) goto error; @@ -1643,8 +1642,7 @@ virLXCControllerSetupHostdevCapsStorage(virDomainDefP= tr vmDef, goto cleanup; } =20 - if (VIR_STRDUP(path, dev) < 0) - goto cleanup; + path =3D g_strdup(dev); =20 while (*(path + len) =3D=3D '/') len++; @@ -1722,8 +1720,7 @@ virLXCControllerSetupHostdevCapsMisc(virDomainDefPtr = vmDef, goto cleanup; } =20 - if (VIR_STRDUP(path, dev) < 0) - goto cleanup; + path =3D g_strdup(dev); =20 while (*(path + len) =3D=3D '/') len++; @@ -2534,8 +2531,7 @@ int main(int argc, char *argv[]) case 'v': if (VIR_REALLOC_N(veths, nveths+1) < 0) goto cleanup; - if (VIR_STRDUP(veths[nveths++], optarg) < 0) - goto cleanup; + veths[nveths++] =3D g_strdup(optarg); break; =20 case 'c': diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 65d17aba8e..41a6a446bd 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -617,8 +617,7 @@ static char *lxcDomainGetOSType(virDomainPtr dom) if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)) < 0) - goto cleanup; + ret =3D g_strdup(virDomainOSTypeToString(vm->def->os.type)); =20 cleanup: virDomainObjEndAPI(&vm); diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 8ae3c7b006..5df09a849e 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -64,18 +64,13 @@ lxcCreateFSDef(int type, =20 def->type =3D type; def->accessmode =3D VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH; - if (src && VIR_STRDUP(def->src->path, src) < 0) - goto error; - if (VIR_STRDUP(def->dst, dst) < 0) - goto error; + if (src) + def->src->path =3D g_strdup(src); + def->dst =3D g_strdup(dst); def->readonly =3D readonly; def->usage =3D usage; =20 return def; - - error: - virDomainFSDefFree(def); - return NULL; } =20 typedef struct _lxcFstab lxcFstab; @@ -113,8 +108,7 @@ static char ** lxcStringSplit(const char *string) char **parts; char **result =3D NULL; =20 - if (VIR_STRDUP(tmp, string) < 0) - return NULL; + tmp =3D g_strdup(string); =20 /* Replace potential \t by a space */ for (i =3D 0; tmp[i]; i++) { @@ -136,8 +130,7 @@ static char ** lxcStringSplit(const char *string) if (VIR_EXPAND_N(result, ntokens, 1) < 0) goto error; =20 - if (VIR_STRDUP(result[ntokens-2], parts[i]) < 0) - goto error; + result[ntokens - 2] =3D g_strdup(parts[i]); } =20 VIR_FREE(tmp); @@ -166,11 +159,10 @@ lxcParseFstabLine(char *fstabLine) if (!parts[0] || !parts[1] || !parts[2] || !parts[3]) goto error; =20 - if (VIR_STRDUP(fstab->src, parts[0]) < 0 || - VIR_STRDUP(fstab->dst, parts[1]) < 0 || - VIR_STRDUP(fstab->type, parts[2]) < 0 || - VIR_STRDUP(fstab->options, parts[3]) < 0) - goto error; + fstab->src =3D g_strdup(parts[0]); + fstab->dst =3D g_strdup(parts[1]); + fstab->type =3D g_strdup(parts[2]); + fstab->options =3D g_strdup(parts[3]); =20 virStringListFree(parts); =20 @@ -276,8 +268,7 @@ lxcAddFstabLine(virDomainDefPtr def, lxcFstabPtr fstab) if (virAsprintf(&dst, "/%s", fstab->dst) < 0) goto cleanup; } else { - if (VIR_STRDUP(dst, fstab->dst) < 0) - goto cleanup; + dst =3D g_strdup(fstab->dst); } =20 /* Check that we don't add basic mounts */ @@ -367,8 +358,7 @@ lxcCreateNetDef(const char *type, else net->linkstate =3D VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN; =20 - if (VIR_STRDUP(net->ifname_guest, name) < 0) - goto error; + net->ifname_guest =3D g_strdup(name); =20 if (mac && virMacAddrParse(mac, &macAddr) =3D=3D 0) net->mac =3D macAddr; @@ -376,17 +366,18 @@ lxcCreateNetDef(const char *type, if (STREQ(type, "veth")) { if (linkdev) { net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; - if (VIR_STRDUP(net->data.bridge.brname, linkdev) < 0) - goto error; + net->data.bridge.brname =3D g_strdup(linkdev); } else { net->type =3D VIR_DOMAIN_NET_TYPE_ETHERNET; } } else if (STREQ(type, "macvlan")) { net->type =3D VIR_DOMAIN_NET_TYPE_DIRECT; =20 - if (!linkdev || VIR_STRDUP(net->data.direct.linkdev, linkdev) < 0) + if (!linkdev) goto error; =20 + net->data.direct.linkdev =3D g_strdup(linkdev); + if (!macvlanmode || STREQ(macvlanmode, "private")) net->data.direct.mode =3D VIR_NETDEV_MACVLAN_MODE_PRIVATE; else if (STREQ(macvlanmode, "vepa")) @@ -415,11 +406,8 @@ lxcCreateHostdevDef(int mode, int type, const char *da= ta) hostdev->mode =3D mode; hostdev->source.caps.type =3D type; =20 - if (type =3D=3D VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET && - VIR_STRDUP(hostdev->source.caps.u.net.ifname, data) < 0) { - virDomainHostdevDefFree(hostdev); - hostdev =3D NULL; - } + if (type =3D=3D VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) + hostdev->source.caps.u.net.ifname =3D g_strdup(data); =20 return hostdev; } @@ -451,12 +439,9 @@ lxcAddNetworkRouteDefinition(const char *address, char *familyStr =3D NULL; char *zero =3D NULL; =20 - if (VIR_STRDUP(zero, family =3D=3D AF_INET ? VIR_SOCKET_ADDR_IPV4_ALL - : VIR_SOCKET_ADDR_IPV6_ALL) < 0) - goto error; + zero =3D g_strdup(family =3D=3D AF_INET ? VIR_SOCKET_ADDR_IPV4_ALL : V= IR_SOCKET_ADDR_IPV6_ALL); =20 - if (VIR_STRDUP(familyStr, family =3D=3D AF_INET ? "ipv4" : "ipv6") < 0) - goto error; + familyStr =3D g_strdup(family =3D=3D AF_INET ? "ipv4" : "ipv6"); =20 if (!(route =3D virNetDevIPRouteCreate(_("Domain interface"), familySt= r, zero, NULL, address, 0, false, @@ -1123,8 +1108,7 @@ lxcParseConfigString(const char *config, VIR_FREE(value); } =20 - if (VIR_STRDUP(vmdef->os.init, "/sbin/init") < 0) - goto error; + vmdef->os.init =3D g_strdup("/sbin/init"); =20 if (virConfGetValueString(properties, "lxc.uts.name", &value) <=3D 0) { virResetLastError(); @@ -1134,11 +1118,10 @@ lxcParseConfigString(const char *config, goto error; } =20 - if (VIR_STRDUP(vmdef->name, value) < 0) - goto error; + vmdef->name =3D g_strdup(value); =20 - if (!vmdef->name && (VIR_STRDUP(vmdef->name, "unnamed") < 0)) - goto error; + if (!vmdef->name) + vmdef->name =3D g_strdup("unnamed"); =20 if (lxcSetRootfs(vmdef, properties) < 0) goto error; diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index d9939f102d..450053d163 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -628,8 +628,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, =20 (*veths)[i] =3D veth; =20 - if (VIR_STRDUP(def->nets[i]->ifname_guest_actual, veth) < 0) - goto cleanup; + def->nets[i]->ifname_guest_actual =3D g_strdup(veth); =20 /* Make sure all net definitions will have a name in the container= */ if (!net->ifname_guest) { @@ -1156,9 +1155,8 @@ virLXCProcessEnsureRootFS(virDomainObjPtr vm) =20 root->type =3D VIR_DOMAIN_FS_TYPE_MOUNT; =20 - if (VIR_STRDUP(root->src->path, "/") < 0 || - VIR_STRDUP(root->dst, "/") < 0) - goto error; + root->src->path =3D g_strdup("/"); + root->dst =3D g_strdup("/"); =20 if (VIR_INSERT_ELEMENT(vm->def->fss, 0, @@ -1266,10 +1264,7 @@ int virLXCProcessStart(virConnectPtr conn, if (VIR_ALLOC(res) < 0) goto cleanup; =20 - if (VIR_STRDUP(res->partition, "/machine") < 0) { - VIR_FREE(res); - goto cleanup; - } + res->partition =3D g_strdup("/machine"); =20 vm->def->resource =3D res; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576208; cv=none; d=zoho.com; s=zohoarc; b=QLxPd/aVytXSbWhLALtA1DFUTaUHJbwRpBda0pLkfe0eeUVHdD6SzYnIQqapEj4tAOj3as1A2/KPTm5nacktnSFQUj56PaYF21tvCgKrd0vZTBeRosFiN7Kd/AGydXjBJ3iAlnYbdO6OIvkkLHsUn+3zQKjh3+jZmIUcWqVlMAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576208; 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=G2sqoZUiM8OIyVjSMDynZtxkWlOoaccQaGzvES1goUQ=; b=KutZQ19vc9cxRpleUAPY4aIh4rU62A91bNU9Rr4UlgQaMVfE5R8pKrVBjGDL/c5O/RQLzzkbPPsqlv+EKv36k6VNgMrSYHG3+7eFodbI134e36Kt3gG1Td2mWOWgoyMiUq/YStj2zFP++8ZPIxTmCCLJGIRu/ojXJ/7eQVBtulc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576208017845.6144334284418; Sun, 20 Oct 2019 05:56: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-148-th02_J51OQ-3q5cRPwZTzg-1; Sun, 20 Oct 2019 08:56:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B97001800E10; Sun, 20 Oct 2019 12:56: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 8DD4D60619; Sun, 20 Oct 2019 12:56: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 4F8801803B57; Sun, 20 Oct 2019 12:56:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtuU7023493 for ; Sun, 20 Oct 2019 08:55:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 819BC3CC8; Sun, 20 Oct 2019 12:55:56 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id E530B194B9 for ; Sun, 20 Oct 2019 12:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576206; 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=G2sqoZUiM8OIyVjSMDynZtxkWlOoaccQaGzvES1goUQ=; b=Q+wqfGIXJG36VYt2sRNPy7eG+HB/+LlE0ySImLqzArbKphHntk0Gw2K1WW/qQOFwAHaIV5 tgMwtLYmqOWskg9/n0sY2ax/xPikjGK911oC0GkGdsIyBjnVdQivoyq7O7vkTqpflXX+Wp PmHlJdjRaCM9lv9+tHhkWJA1b88k+Nk= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:37 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/34] network: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: th02_J51OQ-3q5cRPwZTzg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/network/bridge_driver.c | 49 ++++++++++++------------------------- src/network/leaseshelper.c | 6 ++--- 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 9dce161937..fcaa6a48ae 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -739,19 +739,12 @@ networkStateInitialize(bool privileged, * /etc/libvirt/... && /var/(run|lib)/libvirt/... (system/privileged). */ if (privileged) { - if (VIR_STRDUP(network_driver->networkConfigDir, - SYSCONFDIR "/libvirt/qemu/networks") < 0 || - VIR_STRDUP(network_driver->networkAutostartDir, - SYSCONFDIR "/libvirt/qemu/networks/autostart") < 0 = || - VIR_STRDUP(network_driver->stateDir, - RUNSTATEDIR "/libvirt/network") < 0 || - VIR_STRDUP(network_driver->pidDir, - RUNSTATEDIR "/libvirt/network") < 0 || - VIR_STRDUP(network_driver->dnsmasqStateDir, - LOCALSTATEDIR "/lib/libvirt/dnsmasq") < 0 || - VIR_STRDUP(network_driver->radvdStateDir, - LOCALSTATEDIR "/lib/libvirt/radvd") < 0) - goto error; + network_driver->networkConfigDir =3D g_strdup(SYSCONFDIR "/libvirt= /qemu/networks"); + network_driver->networkAutostartDir =3D g_strdup(SYSCONFDIR "/libv= irt/qemu/networks/autostart"); + network_driver->stateDir =3D g_strdup(RUNSTATEDIR "/libvirt/networ= k"); + network_driver->pidDir =3D g_strdup(RUNSTATEDIR "/libvirt/network"= ); + network_driver->dnsmasqStateDir =3D g_strdup(LOCALSTATEDIR "/lib/l= ibvirt/dnsmasq"); + network_driver->radvdStateDir =3D g_strdup(LOCALSTATEDIR "/lib/lib= virt/radvd"); } else { configdir =3D virGetUserConfigDirectory(); rundir =3D virGetUserRuntimeDirectory(); @@ -2817,8 +2810,7 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) case VIR_NETWORK_FORWARD_VEPA: case VIR_NETWORK_FORWARD_PASSTHROUGH: if (thisName) { - if (VIR_STRDUP(thisIf->device.dev, thisName) < 0) - goto cleanup; + thisIf->device.dev =3D g_strdup(thisName); thisIf->type =3D VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV; netdef->forward.nifs++; } else { @@ -4437,19 +4429,14 @@ networkGetDHCPLeases(virNetworkPtr net, } } =20 - if ((VIR_STRDUP(lease->mac, mac_tmp) < 0) || - (VIR_STRDUP(lease->ipaddr, ip_tmp) < 0) || - (VIR_STRDUP(lease->iface, def->bridge) < 0)) - goto error; + lease->mac =3D g_strdup(mac_tmp); + lease->ipaddr =3D g_strdup(ip_tmp); + lease->iface =3D g_strdup(def->bridge); =20 /* Fields that can be NULL */ - if ((VIR_STRDUP(lease->iaid, - virJSONValueObjectGetString(lease_tmp, "iaid")= ) < 0) || - (VIR_STRDUP(lease->clientid, - virJSONValueObjectGetString(lease_tmp, "client= -id")) < 0) || - (VIR_STRDUP(lease->hostname, - virJSONValueObjectGetString(lease_tmp, "hostna= me")) < 0)) - goto error; + lease->iaid =3D g_strdup(virJSONValueObjectGetString(lease_tmp= , "iaid")); + lease->clientid =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "client-id")); + lease->hostname =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "hostname")); =20 if (VIR_INSERT_ELEMENT(leases_ret, nleases, nleases, lease) < = 0) goto error; @@ -4622,8 +4609,7 @@ networkAllocatePort(virNetworkObjPtr obj, */ port->plugtype =3D VIR_NETWORK_PORT_PLUG_TYPE_NETWORK; =20 - if (VIR_STRDUP(port->plug.bridge.brname, netdef->bridge) < 0) - goto cleanup; + port->plug.bridge.brname =3D g_strdup(netdef->bridge); port->plug.bridge.macTableManager =3D netdef->macTableManager; =20 if (port->virtPortProfile) { @@ -4686,8 +4672,7 @@ networkAllocatePort(virNetworkObjPtr obj, */ =20 port->plugtype =3D VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE; - if (VIR_STRDUP(port->plug.bridge.brname, netdef->bridge) < 0) - goto cleanup; + port->plug.bridge.brname =3D g_strdup(netdef->bridge); port->plug.bridge.macTableManager =3D netdef->macTableManager; =20 if (port->virtPortProfile) { @@ -4791,9 +4776,7 @@ networkAllocatePort(virNetworkObjPtr obj, netdef->name); goto cleanup; } - if (VIR_STRDUP(port->plug.direct.linkdev, - dev->device.dev) < 0) - goto cleanup; + port->plug.direct.linkdev =3D g_strdup(dev->device.dev); } break; =20 diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 959162b814..93dd2ca48a 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -151,16 +151,14 @@ main(int argc, char **argv) clientid =3D argv[2]; } =20 - if (VIR_STRDUP(server_duid, getenv("DNSMASQ_SERVER_DUID")) < 0) - goto cleanup; + server_duid =3D g_strdup(getenv("DNSMASQ_SERVER_DUID")); =20 if (virAsprintf(&custom_lease_file, LOCALSTATEDIR "/lib/libvirt/dnsmasq/%s.status", interface) < 0) goto cleanup; =20 - if (VIR_STRDUP(pid_file, RUNSTATEDIR "/leaseshelper.pid") < 0) - goto cleanup; + pid_file =3D g_strdup(RUNSTATEDIR "/leaseshelper.pid"); =20 /* Try to claim the pidfile, exiting if we can't */ if ((pid_file_fd =3D virPidFileAcquirePath(pid_file, false, getpid()))= < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576284; cv=none; d=zoho.com; s=zohoarc; b=ohIGJ9aA3kY2j50vqzVkakNZkg6vDkKXuXboE1EIdWI0wOD9UvomI3Vn/O1zJstuMROBUBIv+DgyiTW0o9iVzRVH+HiBkbOh56HjCjziF2RxSww0f1Uepctq3hW8RUKizZJvHj33VXTKFolJ77CWYuBmbTGIrUNtZ9EegTLbAJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576284; 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=zzw80SUyY5mGrN1Eclrwy2VqkSuCAwGF34fZV16atDk=; b=gQbJcbfkKVJ5w83yzZXylDTmxX2X6CVtuwFyy3L1IuTqPmNYKw0QNtQZ+TJ0+7XQiixwzGpRd4VZaXltAtdwgxkpT7pmzVmOmcU5MzwZVCnEqLSRJm5gIpb6FFPB5KROyAJ6yNCcy1D8TwCHc8EnYg2Gylo2s6WlqWTFuCTmiU8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576284461157.52507535574364; Sun, 20 Oct 2019 05:58:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-3nm8WswJOre7rHgvVcixJg-1; Sun, 20 Oct 2019 08:56:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3AA581005533; Sun, 20 Oct 2019 12:56:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10C31100EBD7; Sun, 20 Oct 2019 12:56:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C6433180BAA6; Sun, 20 Oct 2019 12:56:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtvbx023502 for ; Sun, 20 Oct 2019 08:55:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CD293CC8; Sun, 20 Oct 2019 12:55:57 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3046194B9 for ; Sun, 20 Oct 2019 12:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576283; 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=zzw80SUyY5mGrN1Eclrwy2VqkSuCAwGF34fZV16atDk=; b=A4EpwR3XpIkxY0TSA/y2oSiUZkj0ea/fgOxIsmgMzy8rnDHby7kso7Ns+W1V6p4SmXZEvt nOyglO7N0/4OyhsMaBm67GDr9YMPSPnoVMtvEzYt/GT8drZCJfU3fujD+hYCmzrXEY+nWn e0918HB0957d3ZI1XSQ07axSncNlkJY= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:38 +0200 Message-Id: <1f36cef44381218d138d9af31b9669f1e9f6d45a.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 20/34] node_device: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 3nm8WswJOre7rHgvVcixJg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/node_device/node_device_driver.c | 32 ++++++----------- src/node_device/node_device_hal.c | 8 ++--- src/node_device/node_device_udev.c | 51 ++++++++++------------------ 3 files changed, 29 insertions(+), 62 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index f95eacf6a2..7ef55f45e9 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -130,8 +130,8 @@ nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def) } =20 p =3D strrchr(devpath, '/'); - if (p && VIR_STRDUP(def->driver, p + 1) < 0) - goto cleanup; + if (p) + def->driver =3D g_strdup(p + 1); ret =3D 0; =20 cleanup: @@ -242,12 +242,8 @@ nodeDeviceLookupByName(virConnectPtr conn, if (virNodeDeviceLookupByNameEnsureACL(conn, def) < 0) goto cleanup; =20 - if ((device =3D virGetNodeDevice(conn, name))) { - if (VIR_STRDUP(device->parentName, def->parent) < 0) { - virObjectUnref(device); - device =3D NULL; - } - } + if ((device =3D virGetNodeDevice(conn, name))) + device->parentName =3D g_strdup(def->parent); =20 cleanup: virNodeDeviceObjEndAPI(&obj); @@ -276,12 +272,8 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, if (virNodeDeviceLookupSCSIHostByWWNEnsureACL(conn, def) < 0) goto cleanup; =20 - if ((device =3D virGetNodeDevice(conn, def->name))) { - if (VIR_STRDUP(device->parentName, def->parent) < 0) { - virObjectUnref(device); - device =3D NULL; - } - } + if ((device =3D virGetNodeDevice(conn, def->name))) + device->parentName =3D g_strdup(def->parent); =20 cleanup: virNodeDeviceObjEndAPI(&obj); @@ -335,8 +327,7 @@ nodeDeviceGetParent(virNodeDevicePtr device) goto cleanup; =20 if (def->parent) { - if (VIR_STRDUP(ret, def->parent) < 0) - goto cleanup; + ret =3D g_strdup(def->parent); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no parent for this device")); @@ -396,10 +387,8 @@ nodeDeviceListCaps(virNodeDevicePtr device, if (ncaps > maxnames) ncaps =3D maxnames; =20 - for (i =3D 0; i < ncaps; i++) { - if (VIR_STRDUP(names[i], virNodeDevCapTypeToString(list[i])) < 0) - goto cleanup; - } + for (i =3D 0; i < ncaps; i++) + names[i] =3D g_strdup(virNodeDevCapTypeToString(list[i])); =20 ret =3D ncaps; =20 @@ -546,8 +535,7 @@ nodeDeviceDestroy(virNodeDevicePtr device) * event which would essentially free the existing @def (obj->def) and * replace it with something new, we need to grab the parent field * and then find the parent obj in order to manage the vport */ - if (VIR_STRDUP(parent, def->parent) < 0) - goto cleanup; + parent =3D g_strdup(def->parent); =20 virNodeDeviceObjEndAPI(&obj); =20 diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_devic= e_hal.c index 4b5d806fa6..688a0e0f06 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -461,14 +461,10 @@ dev_create(const char *udi) if (VIR_ALLOC(def) < 0) goto failure; =20 - if (VIR_STRDUP(def->name, name) < 0) - goto failure; + def->name =3D g_strdup(name); =20 if (get_str_prop(ctx, udi, "info.parent", &parent_key) =3D=3D 0) { - if (VIR_STRDUP(def->parent, hal_name(parent_key)) < 0) { - VIR_FREE(parent_key); - goto failure; - } + def->parent =3D g_strdup(hal_name(parent_key)); VIR_FREE(parent_key); } =20 diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 84f69da8de..525e71f80c 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -154,9 +154,7 @@ udevGetStringProperty(struct udev_device *udev_device, const char *property_key, char **value) { - if (VIR_STRDUP(*value, - udevGetDeviceProperty(udev_device, property_key)) < 0) - return -1; + *value =3D g_strdup(udevGetDeviceProperty(udev_device, property_key)); =20 return 0; } @@ -221,8 +219,7 @@ udevGetStringSysfsAttr(struct udev_device *udev_device, const char *attr_name, char **value) { - if (VIR_STRDUP(*value, udevGetDeviceSysfsAttr(udev_device, attr_name))= < 0) - return -1; + *value =3D g_strdup(udevGetDeviceSysfsAttr(udev_device, attr_name)); =20 virStringStripControlChars(*value); =20 @@ -345,9 +342,8 @@ udevTranslatePCIIds(unsigned int vendor, NULL, NULL); =20 - if (VIR_STRDUP(*vendor_string, vendor_name) < 0 || - VIR_STRDUP(*product_string, device_name) < 0) - return -1; + *vendor_string =3D g_strdup(vendor_name); + *product_string =3D g_strdup(device_name); =20 return 0; } @@ -641,8 +637,7 @@ udevProcessSCSITarget(struct udev_device *device, =20 sysname =3D udev_device_get_sysname(device); =20 - if (VIR_STRDUP(scsi_target->name, sysname) < 0) - return -1; + scsi_target->name =3D g_strdup(sysname); =20 virNodeDeviceGetSCSITargetCaps(def->sysfs_path, &def->caps->data.scsi_= target); =20 @@ -830,8 +825,7 @@ udevProcessCDROM(struct udev_device *device, * change it to cdrom to preserve compatibility with earlier * versions of libvirt. */ VIR_FREE(def->caps->data.storage.drive_type); - if (VIR_STRDUP(def->caps->data.storage.drive_type, "cdrom") < 0) - return -1; + def->caps->data.storage.drive_type =3D g_strdup("cdrom"); =20 if (udevHasDeviceProperty(device, "ID_CDROM_MEDIA") && udevGetIntProperty(device, "ID_CDROM_MEDIA", &has_media, 0) < 0) @@ -892,8 +886,8 @@ udevKludgeStorageType(virNodeDeviceDefPtr def) def->sysfs_path); =20 /* virtio disk */ - if (STRPREFIX(def->caps->data.storage.block, "/dev/vd") && - VIR_STRDUP(def->caps->data.storage.drive_type, "disk") > 0) { + if (STRPREFIX(def->caps->data.storage.block, "/dev/vd")) { + def->caps->data.storage.drive_type =3D g_strdup("disk"); VIR_DEBUG("Found storage type '%s' for device " "with sysfs path '%s'", def->caps->data.storage.drive_type, @@ -920,8 +914,7 @@ udevProcessStorage(struct udev_device *device, goto cleanup; } =20 - if (VIR_STRDUP(storage->block, devnode) < 0) - goto cleanup; + storage->block =3D g_strdup(devnode); =20 if (udevGetStringProperty(device, "ID_BUS", &storage->bus) < 0) goto cleanup; @@ -972,8 +965,7 @@ udevProcessStorage(struct udev_device *device, } =20 if (str) { - if (VIR_STRDUP(storage->drive_type, str) < 0) - goto cleanup; + storage->drive_type =3D g_strdup(str); } else { /* If udev doesn't have it, perhaps we can guess it. */ if (udevKludgeStorageType(def) !=3D 0) @@ -1052,8 +1044,7 @@ udevProcessMediatedDevice(struct udev_device *dev, goto cleanup; } =20 - if (VIR_STRDUP(data->type, last_component(canonicalpath)) < 0) - goto cleanup; + data->type =3D g_strdup(last_component(canonicalpath)); =20 uuidstr =3D udev_device_get_sysname(dev); if ((iommugrp =3D virMediatedDeviceGetIOMMUGroupNum(uuidstr)) < 0) @@ -1111,8 +1102,7 @@ udevGetDeviceNodes(struct udev_device *device, =20 devnode =3D udev_device_get_devnode(device); =20 - if (VIR_STRDUP(def->devnode, devnode) < 0) - return -1; + def->devnode =3D g_strdup(devnode); =20 udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entr= y(device)) n++; @@ -1122,8 +1112,7 @@ udevGetDeviceNodes(struct udev_device *device, =20 n =3D 0; udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entr= y(device)) { - if (VIR_STRDUP(def->devlinks[n++], udev_list_entry_get_name(list_e= ntry)) < 0) - return -1; + def->devlinks[n++] =3D g_strdup(udev_list_entry_get_name(list_entr= y)); } =20 return 0; @@ -1295,14 +1284,10 @@ udevSetParent(struct udev_device *device, if ((obj =3D virNodeDeviceObjListFindBySysfsPath(driver->devs, parent_sysfs_path))= ) { objdef =3D virNodeDeviceObjGetDef(obj); - if (VIR_STRDUP(def->parent, objdef->name) < 0) { - virNodeDeviceObjEndAPI(&obj); - goto cleanup; - } + def->parent =3D g_strdup(objdef->name); virNodeDeviceObjEndAPI(&obj); =20 - if (VIR_STRDUP(def->parent_sysfs_path, parent_sysfs_path) < 0) - goto cleanup; + def->parent_sysfs_path =3D g_strdup(parent_sysfs_path); } =20 } while (def->parent =3D=3D NULL && parent_device !=3D NULL); @@ -1330,8 +1315,7 @@ udevAddOneDevice(struct udev_device *device) if (VIR_ALLOC(def) !=3D 0) goto cleanup; =20 - if (VIR_STRDUP(def->sysfs_path, udev_device_get_syspath(device)) < 0) - goto cleanup; + def->sysfs_path =3D g_strdup(udev_device_get_syspath(device)); =20 if (udevGetStringProperty(device, "DRIVER", &def->driver) < 0) goto cleanup; @@ -1735,8 +1719,7 @@ udevSetupSystemDev(void) if (VIR_ALLOC(def) < 0) return -1; =20 - if (VIR_STRDUP(def->name, "computer") < 0) - goto cleanup; + def->name =3D g_strdup("computer"); =20 if (VIR_ALLOC(def->caps) !=3D 0) goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576225; cv=none; d=zoho.com; s=zohoarc; b=SQK2/0rgPkw3KObCaXO/7puqh20A4/1JB3z1YaEIORtVC28sQFCG57WrfSmdNRehcMt6QLCIGS3EaN4W+UqoZNzzDQLzdyAa+IMplEjySda7VpWhkWTlNc+2ysfPv9nJVktmqUF66RaM+q2bbaULJyZn6OvYJhKkcMD5agqwkhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576225; 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=g/F/xrErg372GAm/EEvDjExo9niylZutFk3bXbImNeA=; b=D3wimyuTvD439a1M1cCcOTJELavEBM44KQJSCS7fGUwRQo0Atr5DI/8o2LMy2KEzh12ruMx6MUyptaIY6Jt7csm6PyEzHeq1GYJTnL407UR8pnepKQN6pwY6Vt8Amhar3c9xlCCNq6Xrrmq7Y4FH595r60W+0/q/Tmf3QPt51Io= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576225812923.3517383480444; Sun, 20 Oct 2019 05:57:05 -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-64-ryVBR440Mtid5YrsnaqqSA-1; Sun, 20 Oct 2019 08:56:30 -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 DA3B060D; Sun, 20 Oct 2019 12:56:18 +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 B3BCD60C4E; Sun, 20 Oct 2019 12:56:18 +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 796FF4EE7E; Sun, 20 Oct 2019 12:56:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCtwCE023514 for ; Sun, 20 Oct 2019 08:55:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id C0CEE3CC8; Sun, 20 Oct 2019 12:55:58 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 187339446 for ; Sun, 20 Oct 2019 12:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576224; 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=g/F/xrErg372GAm/EEvDjExo9niylZutFk3bXbImNeA=; b=WdQuwnsQbYvO+5db4luRvfoO0/bC0KH+bniVf5mnVpHAl0eYV3//XkVcB+o3UURqkorHr6 qdk3T15MI3J3BI5LeF6IcAvngdyb95Kpwd3IWEP2RX2h8/aZqhrMSEXbpmLWB+t2qizpjg zgHtg5jgFZgNEsRKsTsSIXGDi3sJocs= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:39 +0200 Message-Id: <76fdda81850a86f1a0c05a1551101c964bdb42d5.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 21/34] nwfilter: use g_strdup instead of VIR_STRDUP 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-MC-Unique: ryVBR440Mtid5YrsnaqqSA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/nwfilter/nwfilter_dhcpsnoop.c | 3 +-- src/nwfilter/nwfilter_driver.c | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 2c7a1a1522..bf25345e2c 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1093,8 +1093,7 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAd= dr *mac, * generate much more traffic than if we filtered by VM and * braodcast MAC as well */ - if (VIR_STRDUP(ext_filter, filter) < 0) - return NULL; + ext_filter =3D g_strdup(filter); } =20 handle =3D pcap_create(ifname, pcap_errbuf); diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index fbdf250934..41e0a1d5d9 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -205,8 +205,7 @@ nwfilterStateInitialize(bool privileged, =20 nwfilterDriverLock(); =20 - if (VIR_STRDUP(driver->stateDir, RUNSTATEDIR "/libvirt/nwfilter") < 0) - goto error; + driver->stateDir =3D g_strdup(RUNSTATEDIR "/libvirt/nwfilter"); =20 if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create state directory '%s'"= ), @@ -252,8 +251,7 @@ nwfilterStateInitialize(bool privileged, goto error; } =20 - if (VIR_STRDUP(driver->configDir, SYSCONFDIR "/libvirt/nwfilter") < 0) - goto error; + driver->configDir =3D g_strdup(SYSCONFDIR "/libvirt/nwfilter"); =20 if (virFileMakePathWithMode(driver->configDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create config directory '%s'= "), @@ -261,8 +259,7 @@ nwfilterStateInitialize(bool privileged, goto error; } =20 - if (VIR_STRDUP(driver->bindingDir, RUNSTATEDIR "/libvirt/nwfilter-bind= ing") < 0) - goto error; + driver->bindingDir =3D g_strdup(RUNSTATEDIR "/libvirt/nwfilter-binding= "); =20 if (virFileMakePathWithMode(driver->bindingDir, S_IRWXU) < 0) { virReportSystemError(errno, _("cannot create config directory '%s'= "), --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576232; cv=none; d=zoho.com; s=zohoarc; b=cq9Qj9/RnruHwq64NTf1xmoRAoMQ0rpY766LZtAK+Q/kHx2EAzCSqcMDfPB9LSsy1O1drgUD4JwMcfsR5proFJKJERGYtB11aBP8cs8xUDS70oyyWQGd88+KPQr3qbOQmvL3+gCiD/8ju47cEjQymhMfx6/V3jfSzwTt2dk+mqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576232; 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=oxibPV2NJxzyEhocB61CHTS1T3Fqe6STb0ft+q2YIGc=; b=Ldl+TmDR9heES9aNzhGP847vnBZkDNRCoNbipjLFBhwUvkGFaGApcm1wFTZW09Ao+tIGUySWE0w1mnvlT4HgddTQaYOZHjZoHI6oe+G0uOH343kMLz8Z3rg071fIbZ0qfRO4kbyH2Ycaopj3GdU5UHvthDxYLurDE2gXsdJ/5zA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576232531831.3676561249175; Sun, 20 Oct 2019 05:57:12 -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-363-3xAad6mKNry4zG_1KTj_PA-1; Sun, 20 Oct 2019 08:56:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3933C800D53; Sun, 20 Oct 2019 12:56:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FF9E5D71C; Sun, 20 Oct 2019 12:56:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C8EA7180BAAA; Sun, 20 Oct 2019 12:56:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCu0aW023527 for ; Sun, 20 Oct 2019 08:56:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 40AD73CC8; Sun, 20 Oct 2019 12:56:00 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F518194B9 for ; Sun, 20 Oct 2019 12:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576231; 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=oxibPV2NJxzyEhocB61CHTS1T3Fqe6STb0ft+q2YIGc=; b=Lxm4hymJkFSOyP8cxvbLmGEXuQbk/uZtVFGEHwE9AXGEaUHmd1i6fkKVq6DIJQ0e+a97ha PJZMer0cls7nUMBgKzcGkg3F65oat8ogg0m9yZegcVbgaV9y3l6Q1EeztG+lo2t4tfUK3Z 1Es4MUMMgseEYK6tqoVk/G1shNMPLcQ= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:40 +0200 Message-Id: <6bdb7485b3fcc99ad40ad93193ea41c6ec4e2262.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 22/34] qemu: use g_strdup instead of VIR_STRDUP 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.15 X-MC-Unique: 3xAad6mKNry4zG_1KTj_PA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/qemu/qemu_agent.c | 51 +++++-------- src/qemu/qemu_alias.c | 9 +-- src/qemu/qemu_block.c | 46 +++++------- src/qemu/qemu_blockjob.c | 9 +-- src/qemu/qemu_capabilities.c | 85 +++++++++------------- src/qemu/qemu_cgroup.c | 5 +- src/qemu/qemu_checkpoint.c | 12 ++-- src/qemu/qemu_command.c | 15 ++-- src/qemu/qemu_conf.c | 55 +++++--------- src/qemu/qemu_dbus.c | 7 +- src/qemu/qemu_domain.c | 50 +++++-------- src/qemu/qemu_driver.c | 72 +++++++------------ src/qemu/qemu_firmware.c | 44 +++++------- src/qemu/qemu_hotplug.c | 9 +-- src/qemu/qemu_interface.c | 6 +- src/qemu/qemu_interop_config.c | 6 +- src/qemu/qemu_migration.c | 26 +++---- src/qemu/qemu_migration_cookie.c | 21 ++---- src/qemu/qemu_migration_params.c | 10 +-- src/qemu/qemu_monitor.c | 14 ++-- src/qemu/qemu_monitor_json.c | 120 +++++++++++-------------------- src/qemu/qemu_process.c | 57 ++++++--------- src/qemu/qemu_vhost_user.c | 6 +- 23 files changed, 260 insertions(+), 475 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index bd5b8035ca..4b914e6d3b 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1750,8 +1750,7 @@ qemuAgentGetHostname(qemuAgentPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(*hostname, result) < 0) - goto cleanup; + *hostname =3D g_strdup(result); =20 ret =3D 0; =20 @@ -1911,22 +1910,21 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent) virDomainFSInfoPtr ret =3D NULL; size_t i; =20 - if (VIR_ALLOC(ret) < 0 || - VIR_STRDUP(ret->mountpoint, agent->mountpoint) < 0 || - VIR_STRDUP(ret->name, agent->name) < 0 || - VIR_STRDUP(ret->fstype, agent->fstype) < 0) + if (VIR_ALLOC(ret) < 0) goto error; =20 + ret->mountpoint =3D g_strdup(agent->mountpoint); + ret->name =3D g_strdup(agent->name); + ret->fstype =3D g_strdup(agent->fstype); + if (agent->disks && VIR_ALLOC_N(ret->devAlias, agent->ndisks) < 0) goto error; =20 ret->ndevAlias =3D agent->ndisks; =20 - for (i =3D 0; i < ret->ndevAlias; i++) { - if (VIR_STRDUP(ret->devAlias[i], agent->disks[i]->alias) < 0) - goto error; - } + for (i =3D 0; i < ret->ndevAlias; i++) + ret->devAlias[i] =3D g_strdup(agent->disks[i]->alias); =20 return ret; =20 @@ -1980,15 +1978,11 @@ qemuAgentGetFSInfoInternalDisk(virJSONValuePtr json= disks, return -1; disk =3D fsinfo->disks[i]; =20 - if ((val =3D virJSONValueObjectGetString(jsondisk, "serial"))) { - if (VIR_STRDUP(disk->serial, val) < 0) - return -1; - } + if ((val =3D virJSONValueObjectGetString(jsondisk, "serial"))) + disk->serial =3D g_strdup(val); =20 - if ((val =3D virJSONValueObjectGetString(jsondisk, "dev"))) { - if (VIR_STRDUP(disk->devnode, val) < 0) - return -1; - } + if ((val =3D virJSONValueObjectGetString(jsondisk, "dev"))) + disk->devnode =3D g_strdup(val); =20 #define GET_DISK_ADDR(jsonObject, var, name) \ do { \ @@ -2025,8 +2019,7 @@ qemuAgentGetFSInfoInternalDisk(virJSONValuePtr jsondi= sks, unit))) continue; =20 - if (VIR_STRDUP(disk->alias, diskDef->dst) < 0) - return -1; + disk->alias =3D g_strdup(diskDef->dst); } =20 return 0; @@ -2106,8 +2099,7 @@ qemuAgentGetFSInfoInternal(qemuAgentPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(info_ret[i]->mountpoint, result) < 0) - goto cleanup; + info_ret[i]->mountpoint =3D g_strdup(result); =20 if (!(result =3D virJSONValueObjectGetString(entry, "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2115,8 +2107,7 @@ qemuAgentGetFSInfoInternal(qemuAgentPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(info_ret[i]->name, result) < 0) - goto cleanup; + info_ret[i]->name =3D g_strdup(result); =20 if (!(result =3D virJSONValueObjectGetString(entry, "type"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2124,8 +2115,7 @@ qemuAgentGetFSInfoInternal(qemuAgentPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(info_ret[i]->fstype, result) < 0) - goto cleanup; + info_ret[i]->fstype =3D g_strdup(result); =20 =20 /* 'used-bytes' and 'total-bytes' were added in qemu-ga 3.0 */ @@ -2404,12 +2394,10 @@ qemuAgentGetInterfaces(qemuAgentPtr mon, iface =3D ifaces_ret[ifaces_count - 1]; iface->naddrs =3D 0; =20 - if (VIR_STRDUP(iface->name, ifname_s) < 0) - goto error; + iface->name =3D g_strdup(ifname_s); =20 hwaddr =3D virJSONValueObjectGetString(tmp_iface, "hardware-ad= dress"); - if (VIR_STRDUP(iface->hwaddr, hwaddr) < 0) - goto error; + iface->hwaddr =3D g_strdup(hwaddr); } =20 /* Has to be freed for each interface. */ @@ -2471,8 +2459,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon, " field for interface '%s'"), name); goto error; } - if (VIR_STRDUP(ip_addr->addr, addr) < 0) - goto error; + ip_addr->addr =3D g_strdup(addr); =20 if (virJSONValueObjectGetNumberUint(ip_addr_obj, "prefix", &ip_addr->prefix) < 0) { diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index d4d8eb4252..f11099ce90 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -231,8 +231,7 @@ qemuAssignDeviceDiskAlias(virDomainDefPtr def, case VIR_DOMAIN_DISK_BUS_IDE: case VIR_DOMAIN_DISK_BUS_SATA: case VIR_DOMAIN_DISK_BUS_SCSI: - if (VIR_STRDUP(diskPriv->qomName, disk->info.alias) < 0) - return -1; + diskPriv->qomName =3D g_strdup(disk->info.alias); break; =20 case VIR_DOMAIN_DISK_BUS_VIRTIO: @@ -543,8 +542,7 @@ qemuAssignDeviceWatchdogAlias(virDomainWatchdogDefPtr w= atchdog) if (watchdog->info.alias) return 0; =20 - if (VIR_STRDUP(watchdog->info.alias, "watchdog0") < 0) - return -1; + watchdog->info.alias =3D g_strdup("watchdog0"); =20 return 0; } @@ -579,8 +577,7 @@ qemuAssignDeviceVsockAlias(virDomainVsockDefPtr vsock) { if (vsock->info.alias) return 0; - if (VIR_STRDUP(vsock->info.alias, "vsock0") < 0) - return -1; + vsock->info.alias =3D g_strdup("vsock0"); =20 return 0; } diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 515bcd3d59..c584d56e13 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -172,12 +172,11 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValueP= tr next, if (VIR_ALLOC(data) < 0) return -1; =20 - if (VIR_STRDUP(data->nodeformat, nodename) < 0 || - VIR_STRDUP(data->nodestorage, parentnodename) < 0 || - VIR_STRDUP(data->qemufilename, filename) < 0 || - VIR_STRDUP(data->drvformat, drvname) < 0 || - VIR_STRDUP(data->drvstorage, drvparent) < 0) - return -1; + data->nodeformat =3D g_strdup(nodename); + data->nodestorage =3D g_strdup(parentnodename); + data->qemufilename =3D g_strdup(filename); + data->drvformat =3D g_strdup(drvname); + data->drvstorage =3D g_strdup(drvparent); =20 if (backing && qemuBlockNodeNameGetBackingChainBacking(backing, nodenamestable, @@ -302,9 +301,8 @@ qemuBlockDiskDetectNodes(virDomainDiskDefPtr disk, =20 break; } else { - if (VIR_STRDUP(src->nodeformat, entry->nodeformat) < 0 || - VIR_STRDUP(src->nodestorage, entry->nodestorage) < 0) - goto cleanup; + src->nodeformat =3D g_strdup(entry->nodeformat); + src->nodestorage =3D g_strdup(entry->nodestorage); } =20 entry =3D entry->backing; @@ -423,9 +421,7 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src) if (src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { uri->port =3D src->hosts->port; =20 - if (VIR_STRDUP(uri->scheme, - virStorageNetProtocolTypeToString(src->protocol)) <= 0) - return NULL; + uri->scheme =3D g_strdup(virStorageNetProtocolTypeToString(src->pr= otocol)); } else { if (virAsprintf(&uri->scheme, "%s+%s", virStorageNetProtocolTypeToString(src->protocol), @@ -446,8 +442,7 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src) } } =20 - if (VIR_STRDUP(uri->server, src->hosts->name) < 0) - return NULL; + uri->server =3D g_strdup(src->hosts->name); =20 return g_steal_pointer(&uri); } @@ -757,8 +752,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr= src, * } */ =20 - if (VIR_STRDUP(target, src->path) < 0) - return NULL; + target =3D g_strdup(src->path); =20 /* Separate the target and lun */ if ((lunStr =3D strchr(target, '/'))) { @@ -1685,23 +1679,17 @@ qemuBlockStorageSourceDetachPrepare(virStorageSourc= ePtr src, } =20 if (src->pr && - !virStoragePRDefIsManaged(src->pr) && - VIR_STRDUP(data->prmgrAlias, src->pr->mgralias) < 0) - goto cleanup; + !virStoragePRDefIsManaged(src->pr)) + data->prmgrAlias =3D g_strdup(src->pr->mgralias); =20 - if (VIR_STRDUP(data->tlsAlias, src->tlsAlias) < 0) - goto cleanup; + data->tlsAlias =3D g_strdup(src->tlsAlias); =20 if (srcpriv) { - if (srcpriv->secinfo && - srcpriv->secinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES = && - VIR_STRDUP(data->authsecretAlias, srcpriv->secinfo->s.aes.alia= s) < 0) - goto cleanup; + if (srcpriv->secinfo && srcpriv->secinfo->type =3D=3D VIR_DOMAIN_S= ECRET_INFO_TYPE_AES) + data->authsecretAlias =3D g_strdup(srcpriv->secinfo->s.aes.ali= as); =20 - if (srcpriv->encinfo && - srcpriv->encinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES = && - VIR_STRDUP(data->encryptsecretAlias, srcpriv->encinfo->s.aes.a= lias) < 0) - goto cleanup; + if (srcpriv->encinfo && srcpriv->encinfo->type =3D=3D VIR_DOMAIN_S= ECRET_INFO_TYPE_AES) + data->encryptsecretAlias =3D g_strdup(srcpriv->encinfo->s.aes.= alias); } =20 ret =3D g_steal_pointer(&data); diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 3506fa165b..6a7dd5a1d4 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -111,8 +111,7 @@ qemuBlockJobDataNew(qemuBlockJobType type, if (!(job =3D virObjectNew(qemuBlockJobDataClass))) return NULL; =20 - if (VIR_STRDUP(job->name, name) < 0) - return NULL; + job->name =3D g_strdup(name); =20 job->state =3D QEMU_BLOCKJOB_STATE_NEW; job->newstate =3D -1; @@ -483,8 +482,7 @@ qemuBlockJobRefreshJobs(virQEMUDriverPtr driver, * execute the finishing steps */ job->newstate =3D job->state; } else if (newstate =3D=3D QEMU_BLOCKJOB_STATE_CONCLUDED) { - if (VIR_STRDUP(job->errmsg, jobinfo[i]->error) < 0) - goto cleanup; + job->errmsg =3D g_strdup(jobinfo[i]->error); =20 if (job->errmsg) job->newstate =3D QEMU_BLOCKJOB_STATE_FAILED; @@ -1357,8 +1355,7 @@ qemuBlockJobEventProcessConcluded(qemuBlockJobDataPtr= job, if (STRNEQ_NULLABLE(job->name, jobinfo[i]->id)) continue; =20 - if (VIR_STRDUP(job->errmsg, jobinfo[i]->error) < 0) - rc =3D -1; + job->errmsg =3D g_strdup(jobinfo[i]->error); =20 if (job->errmsg) job->newstate =3D QEMU_BLOCKJOB_STATE_FAILED; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 0377cea51a..e8d7cb84e2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -793,10 +793,8 @@ virQEMUCapsInitGuest(virCapsPtr caps, =20 /* RHEL doesn't follow the usual naming for QEMU binaries and ships * a single binary named qemu-kvm outside of $PATH instead */ - if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) { - if (VIR_STRDUP(binary, "/usr/libexec/qemu-kvm") < 0) - return -1; - } + if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) + binary =3D g_strdup("/usr/libexec/qemu-kvm"); =20 /* Ignore binary if extracting version info fails */ if (binary) { @@ -1582,11 +1580,12 @@ virQEMUCapsSEVInfoCopy(virSEVCapabilityPtr *dst, { g_autoptr(virSEVCapability) tmp =3D NULL; =20 - if (VIR_ALLOC(tmp) < 0 || - VIR_STRDUP(tmp->pdh, src->pdh) < 0 || - VIR_STRDUP(tmp->cert_chain, src->cert_chain) < 0) + if (VIR_ALLOC(tmp) < 0) return -1; =20 + tmp->pdh =3D g_strdup(src->pdh); + tmp->cert_chain =3D g_strdup(src->cert_chain); + tmp->cbitpos =3D src->cbitpos; tmp->reduced_phys_bits =3D src->reduced_phys_bits; =20 @@ -1606,8 +1605,7 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemu= Caps) ret->usedQMP =3D qemuCaps->usedQMP; ret->kvmSupportsNesting =3D qemuCaps->kvmSupportsNesting; =20 - if (VIR_STRDUP(ret->binary, qemuCaps->binary) < 0) - goto error; + ret->binary =3D g_strdup(qemuCaps->binary); =20 ret->ctime =3D qemuCaps->ctime; =20 @@ -1617,11 +1615,8 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qem= uCaps) ret->kvmVersion =3D qemuCaps->kvmVersion; ret->microcodeVersion =3D qemuCaps->microcodeVersion; =20 - if (VIR_STRDUP(ret->package, qemuCaps->package) < 0) - goto error; - - if (VIR_STRDUP(ret->kernelVersion, qemuCaps->kernelVersion) < 0) - goto error; + ret->package =3D g_strdup(qemuCaps->package); + ret->kernelVersion =3D g_strdup(qemuCaps->kernelVersion); =20 ret->arch =3D qemuCaps->arch; =20 @@ -1645,9 +1640,8 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemu= Caps) goto error; ret->nmachineTypes =3D qemuCaps->nmachineTypes; for (i =3D 0; i < qemuCaps->nmachineTypes; i++) { - if (VIR_STRDUP(ret->machineTypes[i].name, qemuCaps->machineTypes[i= ].name) < 0 || - VIR_STRDUP(ret->machineTypes[i].alias, qemuCaps->machineTypes[= i].alias) < 0) - goto error; + ret->machineTypes[i].name =3D g_strdup(qemuCaps->machineTypes[i].n= ame); + ret->machineTypes[i].alias =3D g_strdup(qemuCaps->machineTypes[i].= alias); ret->machineTypes[i].maxCpus =3D qemuCaps->machineTypes[i].maxCpus; ret->machineTypes[i].hotplugCpus =3D qemuCaps->machineTypes[i].hot= plugCpus; ret->machineTypes[i].qemuDefault =3D qemuCaps->machineTypes[i].qem= uDefault; @@ -1999,12 +1993,10 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr q= emuCaps, goto error; (*machines)[i] =3D mach; if (qemuCaps->machineTypes[i].alias) { - if (VIR_STRDUP(mach->name, qemuCaps->machineTypes[i].alias) < = 0 || - VIR_STRDUP(mach->canonical, qemuCaps->machineTypes[i].name= ) < 0) - goto error; + mach->name =3D g_strdup(qemuCaps->machineTypes[i].alias); + mach->canonical =3D g_strdup(qemuCaps->machineTypes[i].name); } else { - if (VIR_STRDUP(mach->name, qemuCaps->machineTypes[i].name) < 0) - goto error; + mach->name =3D g_strdup(qemuCaps->machineTypes[i].name); } mach->maxCpus =3D qemuCaps->machineTypes[i].maxCpus; } @@ -2039,8 +2031,7 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qem= uCaps, VIR_FREE(mach); goto error; } - if (VIR_STRDUP(mach->name, machine->canonical) < 0) - goto error; + mach->name =3D g_strdup(machine->canonical); mach->maxCpus =3D machine->maxCpus; i++; } @@ -2358,9 +2349,8 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCa= ps, =20 mach =3D &(qemuCaps->machineTypes[qemuCaps->nmachineTypes++]); =20 - if (VIR_STRDUP(mach->alias, machines[i]->alias) < 0 || - VIR_STRDUP(mach->name, machines[i]->name) < 0) - goto cleanup; + mach->alias =3D g_strdup(machines[i]->alias); + mach->name =3D g_strdup(machines[i]->name); =20 mach->maxCpus =3D machines[i]->maxCpus; mach->hotplugCpus =3D machines[i]->hotplugCpus; @@ -2467,8 +2457,7 @@ virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon, continue; =20 VIR_FREE(cpus[i]->name); - if (VIR_STRDUP(cpus[i]->name, *name) < 0) - goto error; + cpus[i]->name =3D g_strdup(*name); } } } @@ -2550,9 +2539,11 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, model =3D "host"; } =20 - if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, model) < 0) + if (VIR_ALLOC(cpu) < 0) goto cleanup; =20 + cpu->model =3D g_strdup(model); + /* Some x86_64 features defined in cpu_map.xml use spelling which diff= er * from the one preferred by QEMU. Static expansion would give us only= the * preferred spelling. With new QEMU we always use the QEMU's canonical @@ -2661,9 +2652,7 @@ virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps, if (migratable && prop->migratable =3D=3D VIR_TRISTATE_BOOL_NO) continue; =20 - if (VIR_STRDUP(list[n++], - virQEMUCapsCPUFeatureFromQEMU(qemuCaps, prop->name)= ) < 0) - goto cleanup; + list[n++] =3D g_strdup(virQEMUCapsCPUFeatureFromQEMU(qemuCaps, pro= p->name)); } =20 *features =3D g_steal_pointer(&list); @@ -2672,7 +2661,6 @@ virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps, else ret =3D 0; =20 - cleanup: virStringListFree(list); return ret; } @@ -3022,8 +3010,8 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, return 2; } =20 - if (VIR_STRDUP(cpu->model, modelInfo->name) < 0 || - VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0) + cpu->model =3D g_strdup(modelInfo->name); + if (VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0) return -1; =20 cpu->nfeatures_max =3D modelInfo->nprops; @@ -3037,8 +3025,7 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, if (prop->type !=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN) continue; =20 - if (VIR_STRDUP(feature->name, name) < 0) - return -1; + feature->name =3D g_strdup(name); =20 if (!prop->value.boolean || (migratable && prop->migratable =3D=3D VIR_TRISTATE_BOOL_NO)) @@ -4715,8 +4702,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, if (!(qemuCaps =3D virQEMUCapsNew())) goto error; =20 - if (VIR_STRDUP(qemuCaps->binary, binary) < 0) - goto error; + qemuCaps->binary =3D g_strdup(binary); =20 /* We would also want to check faccessat if we cared about ACLs, * but we don't. */ @@ -4749,8 +4735,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { qemuCaps->microcodeVersion =3D microcodeVersion; =20 - if (VIR_STRDUP(qemuCaps->kernelVersion, kernelVersion) < 0) - goto error; + qemuCaps->kernelVersion =3D g_strdup(kernelVersion); =20 qemuCaps->kvmSupportsNesting =3D virQEMUCapsKVMSupportsNesting(); } @@ -4791,8 +4776,7 @@ virQEMUCapsLoadFile(const char *filename, if (!qemuCaps) return NULL; =20 - if (VIR_STRDUP(qemuCaps->binary, binary) < 0) - goto error; + qemuCaps->binary =3D g_strdup(binary); =20 if (virQEMUCapsLoadCache(priv->hostArch, qemuCaps, filename) < 0) goto error; @@ -4875,8 +4859,7 @@ virQEMUCapsCacheNew(const char *libDir, goto error; virFileCacheSetPriv(cache, priv); =20 - if (VIR_STRDUP(priv->libDir, libDir) < 0) - goto error; + priv->libDir =3D g_strdup(libDir); =20 priv->hostArch =3D virArchFromHost(); =20 @@ -5192,9 +5175,7 @@ virQEMUCapsFillDomainLoaderCaps(virDomainCapsLoaderPt= r capsLoader, if (j !=3D capsLoader->values.nvalues) continue; =20 - if (VIR_STRDUP(capsLoader->values.values[capsLoader->values.nvalue= s], - filename) < 0) - return -1; + capsLoader->values.values[capsLoader->values.nvalues] =3D g_strdup= (filename); capsLoader->values.nvalues++; } =20 @@ -5590,11 +5571,9 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr q= emuCaps, if (VIR_ALLOC(sev) < 0) return -1; =20 - if (VIR_STRDUP(sev->pdh, cap->pdh) < 0) - return -1; + sev->pdh =3D g_strdup(cap->pdh); =20 - if (VIR_STRDUP(sev->cert_chain, cap->cert_chain) < 0) - return -1; + sev->cert_chain =3D g_strdup(cap->cert_chain); =20 sev->cbitpos =3D cap->cbitpos; sev->reduced_phys_bits =3D cap->reduced_phys_bits; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 5a58e77fa4..e49bb8fb7e 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -933,10 +933,7 @@ qemuInitCgroup(virDomainObjPtr vm, if (VIR_ALLOC(res) < 0) goto cleanup; =20 - if (VIR_STRDUP(res->partition, "/machine") < 0) { - VIR_FREE(res); - goto cleanup; - } + res->partition =3D g_strdup("/machine"); =20 vm->def->resource =3D res; } diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 4b4ad8bb83..4a618f5236 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -409,9 +409,8 @@ qemuCheckpointCreateXML(virDomainPtr domain, =20 other =3D virDomainCheckpointGetCurrent(vm->checkpoints); if (other) { - if (!redefine && - VIR_STRDUP(chk->def->parent_name, other->def->name) < 0) - goto endjob; + if (!redefine) + chk->def->parent_name =3D g_strdup(other->def->name); } =20 /* actually do the checkpoint */ @@ -513,11 +512,8 @@ qemuCheckpointReparentChildren(void *payload, =20 VIR_FREE(moment->def->parent_name); =20 - if (rep->parent->def && - VIR_STRDUP(moment->def->parent_name, rep->parent->def->name) < 0) { - rep->err =3D -1; - return 0; - } + if (rep->parent->def) + moment->def->parent_name =3D g_strdup(rep->parent->def->name); =20 rep->err =3D qemuCheckpointWriteMetadata(rep->vm, moment, rep->caps, rep->xmlopt, rep->dir); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b579b994f3..f24013f9eb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -799,8 +799,7 @@ qemuBuildGeneralSecinfoURI(virURIPtr uri, secinfo->s.plain.secret) < 0) return -1; } else { - if (VIR_STRDUP(uri->user, secinfo->s.plain.username) < 0) - return -1; + uri->user =3D g_strdup(secinfo->s.plain.username); } break; =20 @@ -1135,8 +1134,7 @@ qemuGetDriveSourceString(virStorageSourcePtr src, case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: - if (VIR_STRDUP(*source, src->path) < 0) - return -1; + *source =3D g_strdup(src->path); =20 break; =20 @@ -2053,8 +2051,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, * ourselves especially for cases when -blockdev will be used = */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_DEVICE_ID)) { if (disk->serial) { - if (VIR_STRDUP(scsiVPDDeviceId, disk->serial) < 0) - goto error; + scsiVPDDeviceId =3D g_strdup(disk->serial); } else { if (!(scsiVPDDeviceId =3D qemuAliasDiskDriveFromDisk(d= isk))) goto error; @@ -3449,8 +3446,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendP= rops, def->mem.source =3D=3D VIR_DOMAIN_MEMORY_SOURCE_FILE) { =20 if (mem->nvdimmPath) { - if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0) - return -1; + memPath =3D g_strdup(mem->nvdimmPath); if (!priv->memPrealloc) prealloc =3D true; } else if (useHugepage) { @@ -7044,8 +7040,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, return -1; } =20 - if (VIR_STRDUP(cpu, default_model) < 0) - return -1; + cpu =3D g_strdup(default_model); } =20 if (cpu) { diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 65cd959cf8..fae697a2ef 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -138,8 +138,7 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged) "%s/log/swtpm/libvirt/qemu", LOCALSTATEDIR) < 0) return NULL; =20 - if (VIR_STRDUP(cfg->configBaseDir, SYSCONFDIR "/libvirt") < 0) - return NULL; + cfg->configBaseDir =3D g_strdup(SYSCONFDIR "/libvirt"); =20 if (virAsprintf(&cfg->stateDir, "%s/libvirt/qemu", RUNSTATEDIR) < 0) @@ -242,15 +241,10 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool pr= ivileged) * This will then be used as a fallback if the service specific * directory doesn't exist (although we don't check if this exists). */ - if (VIR_STRDUP(cfg->defaultTLSx509certdir, - SYSCONFDIR "/pki/qemu") < 0) - return NULL; + cfg->defaultTLSx509certdir =3D g_strdup(SYSCONFDIR "/pki/qemu"); =20 - if (VIR_STRDUP(cfg->vncListen, VIR_LOOPBACK_IPV4_ADDR) < 0) - return NULL; - - if (VIR_STRDUP(cfg->spiceListen, VIR_LOOPBACK_IPV4_ADDR) < 0) - return NULL; + cfg->vncListen =3D g_strdup(VIR_LOOPBACK_IPV4_ADDR); + cfg->spiceListen =3D g_strdup(VIR_LOOPBACK_IPV4_ADDR); =20 cfg->remotePortMin =3D QEMU_REMOTE_PORT_MIN; cfg->remotePortMax =3D QEMU_REMOTE_PORT_MAX; @@ -271,10 +265,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool pri= vileged) return NULL; } =20 - if (VIR_STRDUP(cfg->bridgeHelperName, QEMU_BRIDGE_HELPER) < 0 || - VIR_STRDUP(cfg->prHelperName, QEMU_PR_HELPER) < 0 || - VIR_STRDUP(cfg->slirpHelperName, QEMU_SLIRP_HELPER) < 0) - return NULL; + cfg->bridgeHelperName =3D g_strdup(QEMU_BRIDGE_HELPER); + cfg->prHelperName =3D g_strdup(QEMU_PR_HELPER); + cfg->slirpHelperName =3D g_strdup(QEMU_SLIRP_HELPER); =20 cfg->clearEmulatorCapabilities =3D true; =20 @@ -386,10 +379,9 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr huget= lbfs, const char *path, bool deflt) { - if (VIR_STRDUP(hugetlbfs->mnt_dir, path) < 0 || - virFileGetHugepageSize(path, &hugetlbfs->size) < 0) { + hugetlbfs->mnt_dir =3D g_strdup(path); + if (virFileGetHugepageSize(path, &hugetlbfs->size) < 0) return -1; - } =20 hugetlbfs->deflt =3D deflt; return 0; @@ -1151,10 +1143,7 @@ virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPt= r cfg) if (!cfg->val## TLSx509certdir && \ !cfg->val## TLSx509secretUUID && \ cfg->defaultTLSx509secretUUID) { \ - if (VIR_STRDUP(cfg->val## TLSx509secretUUID, \ - cfg->defaultTLSx509secretUUID) < 0) { \ - return -1; \ - } \ + cfg->val## TLSx509secretUUID =3D g_strdup(cfg->defaultTLSx509s= ecretUUID); \ } \ } while (0) =20 @@ -1176,15 +1165,9 @@ virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPt= r cfg) if (cfg->val ## TLSx509certdir) \ break; \ if (virFileExists(SYSCONFDIR "/pki/libvirt-"#val)) { \ - if (VIR_STRDUP(cfg->val ## TLSx509certdir, \ - SYSCONFDIR "/pki/libvirt-"#val) < 0) { \ - return -1; \ - } \ + cfg->val ## TLSx509certdir =3D g_strdup(SYSCONFDIR "/pki/libvi= rt-"#val); \ } else { \ - if (VIR_STRDUP(cfg->val ## TLSx509certdir, \ - cfg->defaultTLSx509certdir) < 0) { \ - return -1; \ - } \ + cfg->val ## TLSx509certdir =3D g_strdup(cfg->defaultTLSx509cer= tdir); \ } \ } while (0) =20 @@ -1276,9 +1259,8 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDri= verPtr driver) virCapsHostSecModelPtr sm =3D &caps->host.secModels[i]; doi =3D qemuSecurityGetDOI(sec_managers[i]); model =3D qemuSecurityGetModel(sec_managers[i]); - if (VIR_STRDUP(sm->model, model) < 0 || - VIR_STRDUP(sm->doi, doi) < 0) - return NULL; + sm->model =3D g_strdup(model); + sm->doi =3D g_strdup(doi); =20 for (j =3D 0; j < G_N_ELEMENTS(virtTypes); j++) { lbl =3D qemuSecurityGetBaseLabel(sec_managers[i], virtTypes[j]= ); @@ -1587,19 +1569,20 @@ qemuSharedDeviceEntryInsert(virQEMUDriverPtr driver, * recorded in the table. */ if (!qemuSharedDeviceEntryDomainExists(entry, name, NULL)) { - if (VIR_EXPAND_N(entry->domains, entry->ref, 1) < 0 || - VIR_STRDUP(entry->domains[entry->ref - 1], name) < 0) { + if (VIR_EXPAND_N(entry->domains, entry->ref, 1) < 0) { /* entry is owned by the hash table here */ entry =3D NULL; goto error; } + entry->domains[entry->ref - 1] =3D g_strdup(name); } } else { if (VIR_ALLOC(entry) < 0 || - VIR_ALLOC_N(entry->domains, 1) < 0 || - VIR_STRDUP(entry->domains[0], name) < 0) + VIR_ALLOC_N(entry->domains, 1) < 0) goto error; =20 + entry->domains[0] =3D g_strdup(name); + entry->ref =3D 1; =20 if (virHashAddEntry(driver->sharedDevices, key, entry) < 0) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index f4205a74bb..faee122021 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -42,11 +42,8 @@ qemuDBusVMStateNew(const char *id, const char *addr) if (VIR_ALLOC(self) < 0) return NULL; =20 - if (VIR_STRDUP(self->id, id) < 0) - return NULL; - - if (VIR_STRDUP(self->addr, addr) < 0) - return NULL; + self->id =3D g_strdup(id); + self->addr =3D g_strdup(addr); =20 return g_steal_pointer(&self); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ab13eebd39..9b201a8259 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1407,14 +1407,12 @@ qemuDomainSecretPlainSetup(qemuDomainSecretInfoPtr = secinfo, return -1; =20 secinfo->type =3D VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN; - if (VIR_STRDUP(secinfo->s.plain.username, username) < 0) - goto cleanup; + secinfo->s.plain.username =3D g_strdup(username); =20 ret =3D virSecretGetSecretString(conn, seclookupdef, usageType, &secinfo->s.plain.secret, &secinfo->s.plain.secretlen); =20 - cleanup: virObjectUnref(conn); return ret; } @@ -1456,8 +1454,7 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv, return -1; =20 secinfo->type =3D VIR_DOMAIN_SECRET_INFO_TYPE_AES; - if (VIR_STRDUP(secinfo->s.aes.username, username) < 0) - goto cleanup; + secinfo->s.aes.username =3D g_strdup(username); =20 if (!(secinfo->s.aes.alias =3D qemuDomainGetSecretAESAlias(srcalias, i= sLuks))) goto cleanup; @@ -1865,8 +1862,7 @@ qemuDomainSecretGraphicsPrepare(virQEMUDriverConfigPt= r cfg, if (!cfg->vncTLS) return 0; =20 - if (VIR_STRDUP(gfxPriv->tlsAlias, "vnc-tls-creds0") < 0) - return -1; + gfxPriv->tlsAlias =3D g_strdup("vnc-tls-creds0"); =20 if (cfg->vncTLSx509secretUUID) { gfxPriv->secinfo =3D qemuDomainSecretInfoTLSNew(priv, gfxPriv->tls= Alias, @@ -4352,8 +4348,7 @@ qemuCanonicalizeMachine(virDomainDefPtr def, virQEMUC= apsPtr qemuCaps) =20 if (STRNEQ(canon, def->os.machine)) { char *tmp; - if (VIR_STRDUP(tmp, canon) < 0) - return -1; + tmp =3D g_strdup(canon); VIR_FREE(def->os.machine); def->os.machine =3D tmp; } @@ -10409,8 +10404,7 @@ qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr d= isk, else nodename =3D disk->src->nodeformat; =20 - if (VIR_STRDUP(*backendAlias, nodename) < 0) - return -1; + *backendAlias =3D g_strdup(nodename); =20 return 0; } @@ -12507,10 +12501,8 @@ qemuProcessPrepareStorageSourceTLSVxhs(virStorageS= ourcePtr src, src->tlsFromConfig =3D true; } =20 - if (src->haveTLS =3D=3D VIR_TRISTATE_BOOL_YES) { - if (VIR_STRDUP(src->tlsCertdir, cfg->vxhsTLSx509certdir) < 0) - return -1; - } + if (src->haveTLS =3D=3D VIR_TRISTATE_BOOL_YES) + src->tlsCertdir =3D g_strdup(cfg->vxhsTLSx509certdir); =20 return 0; } @@ -12536,8 +12528,7 @@ qemuProcessPrepareStorageSourceTLSNBD(virStorageSou= rcePtr src, return -1; } =20 - if (VIR_STRDUP(src->tlsCertdir, cfg->nbdTLSx509certdir) < 0) - return -1; + src->tlsCertdir =3D g_strdup(cfg->nbdTLSx509certdir); } =20 return 0; @@ -12876,15 +12867,14 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, toAlloc =3D 2; =20 if (VIR_ALLOC_N(tmpPaths, toAlloc) < 0 || - VIR_ALLOC_N(tmpPerms, toAlloc) < 0 || - VIR_STRDUP(tmpPaths[0], tmpPath) < 0) + VIR_ALLOC_N(tmpPerms, toAlloc) < 0) goto cleanup; + tmpPaths[0] =3D g_strdup(tmpPath); tmpNpaths =3D toAlloc; tmpPerms[0] =3D perm; =20 if (includeVFIO) { - if (VIR_STRDUP(tmpPaths[1], QEMU_DEV_VFIO) < 0) - goto cleanup; + tmpPaths[1] =3D g_strdup(QEMU_DEV_VFIO); tmpPerms[1] =3D VIR_CGROUP_DEVICE_RW; } } @@ -13174,8 +13164,7 @@ qemuDomainCreateDeviceRecursive(const char *device, if (IS_RELATIVE_FILE_NAME(target)) { char *c =3D NULL, *tmp =3D NULL, *devTmp =3D NULL; =20 - if (VIR_STRDUP(devTmp, device) < 0) - goto cleanup; + devTmp =3D g_strdup(device); =20 if ((c =3D strrchr(devTmp, '/'))) *(c + 1) =3D '\0'; @@ -14152,8 +14141,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverP= tr driver, if (IS_RELATIVE_FILE_NAME(target)) { char *c =3D NULL, *tmp =3D NULL, *fileTmp =3D NULL; =20 - if (VIR_STRDUP(fileTmp, file) < 0) - goto cleanup; + fileTmp =3D g_strdup(file); =20 if ((c =3D strrchr(fileTmp, '/'))) *(c + 1) =3D '\0'; @@ -14438,10 +14426,11 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, } =20 /* qemu-pr-helper might require access to /dev/mapper/control. */ - if (src->pr && - (VIR_STRDUP(dmPath, QEMU_DEVICE_MAPPER_CONTROL_PATH) < 0 || - VIR_APPEND_ELEMENT_COPY(paths, npaths, dmPath) < 0)) - goto cleanup; + if (src->pr) { + dmPath =3D g_strdup(QEMU_DEVICE_MAPPER_CONTROL_PATH); + if (VIR_APPEND_ELEMENT_COPY(paths, npaths, dmPath) < 0) + goto cleanup; + } =20 if (qemuDomainNamespaceMknodPaths(vm, paths, npaths) < 0) goto cleanup; @@ -15116,8 +15105,7 @@ qemuDomainPrepareStorageSourcePR(virStorageSourcePt= r src, VIR_FREE(src->pr->path); if (!(src->pr->path =3D qemuDomainGetManagedPRSocketPath(priv))) return -1; - if (VIR_STRDUP(src->pr->mgralias, qemuDomainGetManagedPRAlias()) <= 0) - return -1; + src->pr->mgralias =3D g_strdup(qemuDomainGetManagedPRAlias()); } else { if (!(src->pr->mgralias =3D qemuDomainGetUnmanagedPRAlias(parental= ias))) return -1; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 421a21818e..71947efa4e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1185,8 +1185,7 @@ qemuConnectURIProbe(char **uri) return 0; =20 cfg =3D virQEMUDriverGetConfig(qemu_driver); - if (VIR_STRDUP(*uri, cfg->uri) < 0) - return -1; + *uri =3D g_strdup(cfg->uri); =20 return 0; } @@ -7383,8 +7382,7 @@ static char *qemuConnectDomainXMLToNative(virConnectP= tr conn, virMacAddr mac =3D net->mac; char *script =3D net->script; =20 - if (VIR_STRDUP(model, virDomainNetGetModelString(net)) < 0) - goto cleanup; + model =3D g_strdup(virDomainNetGetModelString(net)); =20 net->script =3D NULL; =20 @@ -7761,9 +7759,8 @@ qemuDomainUndefineFlags(virDomainPtr dom, if (qemuDomainNVRAMPathFormat(cfg, vm->def, &nvram_path) < 0) goto endjob; } else { - if (vm->def->os.loader && - VIR_STRDUP(nvram_path, vm->def->os.loader->nvram) < 0) - goto endjob; + if (vm->def->os.loader) + nvram_path =3D g_strdup(vm->def->os.loader->nvram); } =20 if (nvram_path && virFileExists(nvram_path)) { @@ -14639,10 +14636,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDr= iverPtr driver, =20 if (snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNA= L) { VIR_FREE(defdisk->src->path); - if (VIR_STRDUP(defdisk->src->path, snapdisk->src->path) < 0) { - /* we cannot rollback here in a sane way */ - goto cleanup; - } + defdisk->src->path =3D g_strdup(snapdisk->src->path); defdisk->src->format =3D snapdisk->src->format; =20 if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def)= < 0) @@ -15968,9 +15962,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, =20 current =3D virDomainSnapshotGetCurrent(vm->snapshots); if (current) { - if (!redefine && - VIR_STRDUP(snap->def->parent_name, current->def->name) < 0) - goto endjob; + if (!redefine) + snap->def->parent_name =3D g_strdup(current->def->name); } =20 /* actually do the snapshot */ @@ -16902,11 +16895,8 @@ qemuDomainMomentReparentChildren(void *payload, =20 VIR_FREE(moment->def->parent_name); =20 - if (rep->parent->def && - VIR_STRDUP(moment->def->parent_name, rep->parent->def->name) < 0) { - rep->err =3D -1; - return 0; - } + if (rep->parent->def) + moment->def->parent_name =3D g_strdup(rep->parent->def->name); =20 rep->err =3D rep->writeMetadata(rep->vm, moment, rep->caps, rep->xmlop= t, rep->dir); @@ -18316,8 +18306,7 @@ qemuDomainBlockRebase(virDomainPtr dom, const char = *path, const char *base, goto cleanup; dest->type =3D (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_DEV) ? VIR_STORAGE_TYPE_BLOCK : VIR_STORAGE_TYPE_FILE; - if (VIR_STRDUP(dest->path, base) < 0) - goto cleanup; + dest->path =3D g_strdup(base); if (flags & VIR_DOMAIN_BLOCK_REBASE_COPY_RAW) dest->format =3D VIR_STORAGE_FILE_RAW; =20 @@ -18896,9 +18885,8 @@ qemuDomainSetBlockIoTuneDefaults(virDomainBlockIoTu= neInfoPtr newinfo, =20 if (!(set_fields & QEMU_BLOCK_IOTUNE_SET_SIZE_IOPS)) newinfo->size_iops_sec =3D oldinfo->size_iops_sec; - if (!(set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME) && - VIR_STRDUP(newinfo->group_name, oldinfo->group_name) < 0) - return -1; + if (!(set_fields & QEMU_BLOCK_IOTUNE_SET_GROUP_NAME)) + newinfo->group_name =3D g_strdup(oldinfo->group_name); =20 /* The length field is handled a bit differently. If not defined/set, * QEMU will default these to 0 or 1 depending on whether something in @@ -19076,8 +19064,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, =20 /* NB: Cannot use macro since this is a value.s not a value.ul */ if (STREQ(param->field, VIR_DOMAIN_BLOCK_IOTUNE_GROUP_NAME)) { - if (VIR_STRDUP(info.group_name, param->value.s) < 0) - goto endjob; + info.group_name =3D g_strdup(param->value.s); set_fields |=3D QEMU_BLOCK_IOTUNE_SET_GROUP_NAME; if (virTypedParamsAddString(&eventParams, &eventNparams, &eventMaxparams, @@ -19374,8 +19361,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, =20 /* Group name needs to be copied since qemuMonitorGetBlockIoThrott= le * allocates it as well */ - if (VIR_STRDUP(reply.group_name, disk->blkdeviotune.group_name) < = 0) - goto endjob; + reply.group_name =3D g_strdup(disk->blkdeviotune.group_name); } =20 #define BLOCK_IOTUNE_ASSIGN(name, var) \ @@ -19493,8 +19479,7 @@ qemuDomainGetDiskErrors(virDomainPtr dom, if (n =3D=3D nerrors) break; =20 - if (VIR_STRDUP(errors[n].disk, disk->dst) < 0) - goto endjob; + errors[n].disk =3D g_strdup(disk->dst); errors[n].error =3D info->io_status; n++; } @@ -20521,8 +20506,7 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, if (!(res->vcpus =3D virBitmapFormat(domresmon->vcpus))) goto error; =20 - if (VIR_STRDUP(res->name, virResctrlMonitorGetID(monitor)) < 0) - goto error; + res->name =3D g_strdup(virResctrlMonitorGetID(monitor)); =20 if (virResctrlMonitorGetStats(monitor, (const char **)features, &res->stats, &res->nstats) < 0) @@ -21667,19 +21651,16 @@ qemuGetDHCPInterfaces(virDomainPtr dom, if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) goto error; =20 - if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0) - goto error; + iface->name =3D g_strdup(vm->def->nets[i]->ifname); =20 - if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) - goto error; + iface->hwaddr =3D g_strdup(macaddr); } =20 for (j =3D 0; j < n_leases; j++) { virNetworkDHCPLeasePtr lease =3D leases[j]; virDomainIPAddressPtr ip_addr =3D &iface->addrs[j]; =20 - if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0) - goto error; + ip_addr->addr =3D g_strdup(lease->ipaddr); =20 ip_addr->type =3D lease->type; ip_addr->prefix =3D lease->prefix; @@ -21739,18 +21720,15 @@ qemuARPGetInterfaces(virDomainObjPtr vm, if (VIR_ALLOC(iface) < 0) goto cleanup; =20 - if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0) - goto cleanup; + iface->name =3D g_strdup(vm->def->nets[i]->ifname); =20 - if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) - goto cleanup; + iface->hwaddr =3D g_strdup(macaddr); =20 if (VIR_ALLOC(iface->addrs) < 0) goto cleanup; iface->naddrs =3D 1; =20 - if (VIR_STRDUP(iface->addrs->addr, entry.ipaddr) < 0) - goto cleanup; + iface->addrs->addr =3D g_strdup(entry.ipaddr); =20 if (VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface) < = 0) goto cleanup; @@ -21851,8 +21829,7 @@ qemuDomainRenameCallback(virDomainObjPtr vm, =20 cfg =3D virQEMUDriverGetConfig(driver); =20 - if (VIR_STRDUP(new_dom_name, new_name) < 0) - goto cleanup; + new_dom_name =3D g_strdup(new_name); =20 if (!(new_dom_cfg_file =3D virDomainConfigFile(cfg->configDir, new_dom_name)) || @@ -22324,8 +22301,7 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, goto endjob; } =20 - if (VIR_STRDUP(nodename, src->nodestorage) < 0) - goto endjob; + nodename =3D g_strdup(src->nodestorage); =20 qemuDomainObjEnterMonitor(driver, vm); rc =3D qemuMonitorSetBlockThreshold(priv->mon, nodename, threshold); diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index f614be6d14..670662fd4b 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -346,8 +346,7 @@ qemuFirmwareFlashFileParse(const char *path, return -1; } =20 - if (VIR_STRDUP(flash->filename, filename) < 0) - return -1; + flash->filename =3D g_strdup(filename); =20 if (!(format =3D virJSONValueObjectGetString(doc, "format"))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -356,8 +355,7 @@ qemuFirmwareFlashFileParse(const char *path, return -1; } =20 - if (VIR_STRDUP(flash->format, format) < 0) - return -1; + flash->format =3D g_strdup(format); =20 return 0; } @@ -408,8 +406,7 @@ qemuFirmwareMappingKernelParse(const char *path, path); } =20 - if (VIR_STRDUP(kernel->filename, filename) < 0) - return -1; + kernel->filename =3D g_strdup(filename); =20 return 0; } @@ -428,8 +425,7 @@ qemuFirmwareMappingMemoryParse(const char *path, path); } =20 - if (VIR_STRDUP(memory->filename, filename) < 0) - return -1; + memory->filename =3D g_strdup(filename); =20 return 0; } @@ -547,8 +543,7 @@ qemuFirmwareTargetParse(const char *path, virJSONValuePtr machine =3D virJSONValueArrayGet(machines, j); g_autofree char *machineStr =3D NULL; =20 - if (VIR_STRDUP(machineStr, virJSONValueGetString(machine)) < 0) - goto cleanup; + machineStr =3D g_strdup(virJSONValueGetString(machine)); =20 VIR_APPEND_ELEMENT_INPLACE(t->machines, t->nmachines, machineS= tr); } @@ -1051,9 +1046,7 @@ qemuFirmwareEnableFeatures(virQEMUDriverPtr driver, } =20 VIR_FREE(def->os.loader->path); - if (VIR_STRDUP(def->os.loader->path, - flash->executable.filename) < 0) - return -1; + def->os.loader->path =3D g_strdup(flash->executable.filename); =20 if (STRNEQ(flash->nvram_template.format, "raw")) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, @@ -1063,9 +1056,7 @@ qemuFirmwareEnableFeatures(virQEMUDriverPtr driver, } =20 VIR_FREE(def->os.loader->templt); - if (VIR_STRDUP(def->os.loader->templt, - flash->nvram_template.filename) < 0) - return -1; + def->os.loader->templt =3D g_strdup(flash->nvram_template.filename= ); =20 if (qemuDomainNVRAMPathGenerate(cfg, def) < 0) return -1; @@ -1077,8 +1068,7 @@ qemuFirmwareEnableFeatures(virQEMUDriverPtr driver, =20 case QEMU_FIRMWARE_DEVICE_KERNEL: VIR_FREE(def->os.kernel); - if (VIR_STRDUP(def->os.kernel, kernel->filename) < 0) - return -1; + def->os.kernel =3D g_strdup(kernel->filename); =20 VIR_DEBUG("decided on kernel '%s'", def->os.kernel); @@ -1090,8 +1080,7 @@ qemuFirmwareEnableFeatures(virQEMUDriverPtr driver, return -1; =20 def->os.loader->type =3D VIR_DOMAIN_LOADER_TYPE_ROM; - if (VIR_STRDUP(def->os.loader->path, memory->filename) < 0) - return -1; + def->os.loader->path =3D g_strdup(memory->filename); =20 VIR_DEBUG("decided on loader '%s'", def->os.loader->path); @@ -1400,12 +1389,15 @@ qemuFirmwareGetSupported(const char *machine, break; } =20 - if (j =3D=3D *nfws && - (VIR_ALLOC(tmp) < 0 || - VIR_STRDUP(tmp->name, fwpath) < 0 || - VIR_STRDUP(tmp->nvram, nvrampath) < 0 || - VIR_APPEND_ELEMENT(*fws, *nfws, tmp) < 0)) - return -1; + if (j =3D=3D *nfws) { + if (VIR_ALLOC(tmp) < 0) + return -1; + + tmp->name =3D g_strdup(fwpath); + tmp->nvram =3D g_strdup(nvrampath); + if (VIR_APPEND_ELEMENT(*fws, *nfws, tmp) < 0) + return -1; + } } } =20 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 5b42bbfd48..4da6457bdc 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4243,8 +4243,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, =20 =20 if (blockdev) { - if (VIR_STRDUP(corAlias, diskPriv->nodeCopyOnRead) < 0) - goto cleanup; + corAlias =3D g_strdup(diskPriv->nodeCopyOnRead); =20 if (diskPriv->blockjob) { /* the block job keeps reference to the disk chain */ @@ -4987,10 +4986,8 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, * save the alias to use when sending a DEVICE_REMOVED event after * all other teardown is complete */ - if ((info =3D virDomainDeviceGetInfo(dev)) && - VIR_STRDUP(alias, info->alias) < 0) { - return -1; - } + if ((info =3D virDomainDeviceGetInfo(dev))) + alias =3D g_strdup(info->alias); info =3D NULL; =20 switch ((virDomainDeviceType)dev->type) { diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index 6e3e634b30..70832e0c9a 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -457,8 +457,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def, STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) || strchr(net->ifname, '%')) { VIR_FREE(net->ifname); - if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d")= < 0) - goto cleanup; + net->ifname =3D g_strdup(VIR_NET_GENERATED_TAP_PREFIX "%d"); /* avoid exposing vnet%d in getXMLDesc or error outputs */ template_ifname =3D true; } @@ -563,8 +562,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) || strchr(net->ifname, '%')) { VIR_FREE(net->ifname); - if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0) - goto cleanup; + net->ifname =3D g_strdup(VIR_NET_GENERATED_TAP_PREFIX "%d"); /* avoid exposing vnet%d in getXMLDesc or error outputs */ template_ifname =3D true; } diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c index 7193d31dfd..d05ff56221 100644 --- a/src/qemu/qemu_interop_config.c +++ b/src/qemu/qemu_interop_config.c @@ -55,8 +55,7 @@ qemuBuildFileList(virHashTablePtr files, const char *dir) if (STRPREFIX(ent->d_name, ".")) continue; =20 - if (VIR_STRDUP(filename, ent->d_name) < 0) - goto cleanup; + filename =3D g_strdup(ent->d_name); =20 if (virAsprintf(&path, "%s/%s", dir, filename) < 0) goto cleanup; @@ -115,8 +114,7 @@ qemuInteropFetchConfigs(const char *name, * much sense to parse files in root's home directory. It * makes sense only for session daemon which runs under * regular user. */ - if (VIR_STRDUP(xdgConfig, getenv("XDG_CONFIG_HOME")) < 0) - return -1; + xdgConfig =3D g_strdup(getenv("XDG_CONFIG_HOME")); =20 if (!xdgConfig) { g_autofree char *home =3D virGetUserDirectory(); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index fed95a285a..471cb1c5a6 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -192,8 +192,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn, return 0; } =20 - if (VIR_STRDUP(basePath, disk->src->path) < 0) - goto cleanup; + basePath =3D g_strdup(disk->src->path); =20 if (!(volName =3D strrchr(basePath, '/'))) { virReportError(VIR_ERR_INVALID_ARG, @@ -808,8 +807,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr= driver, if (!(copysrc->backingStore =3D virStorageSourceNew())) return -1; =20 - if (VIR_STRDUP(copysrc->path, diskAlias) < 0) - return -1; + copysrc->path =3D g_strdup(diskAlias); =20 if (VIR_ALLOC_N(copysrc->hosts, 1) < 0) return -1; @@ -817,11 +815,9 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPt= r driver, copysrc->nhosts =3D 1; copysrc->hosts->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; copysrc->hosts->port =3D port; - if (VIR_STRDUP(copysrc->hosts->name, host) < 0) - return -1; + copysrc->hosts->name =3D g_strdup(host); =20 - if (VIR_STRDUP(copysrc->tlsAlias, tlsAlias) < 0) - return -1; + copysrc->tlsAlias =3D g_strdup(tlsAlias); =20 if (virAsprintf(©src->nodestorage, "migration-%s-storage", disk->d= st) < 0 || virAsprintf(©src->nodeformat, "migration-%s-format", disk->dst= ) < 0) @@ -2218,8 +2214,7 @@ qemuMigrationDstPrepare(virDomainObjPtr vm, char *migrateFrom =3D NULL; =20 if (tunnel) { - if (VIR_STRDUP(migrateFrom, "stdio") < 0) - goto cleanup; + migrateFrom =3D g_strdup("stdio"); } else { bool encloseAddress =3D false; bool hostIPv6Capable =3D false; @@ -2434,8 +2429,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, *def =3D NULL; =20 priv =3D vm->privateData; - if (VIR_STRDUP(priv->origname, origname) < 0) - goto cleanup; + priv->origname =3D g_strdup(origname); =20 if (taint_hook) { /* Domain XML has been altered by a hook script. */ @@ -2780,8 +2774,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver, if (virSocketAddrNumericFamily(migrateHost) =3D=3D AF_INET6) encloseAddress =3D true; =20 - if (VIR_STRDUP(hostname, migrateHost) < 0) - goto cleanup; + hostname =3D g_strdup(migrateHost); } else { if ((hostname =3D virGetHostname()) =3D=3D NULL) goto cleanup; @@ -2902,10 +2895,7 @@ qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver, =20 if (dname) { name =3D def->name; - if (VIR_STRDUP(def->name, dname) < 0) { - virDomainDefFree(def); - def =3D NULL; - } + def->name =3D g_strdup(dname); } =20 cleanup: diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 244ad4fdf3..f625c7086b 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -214,8 +214,7 @@ qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr = driver, !(mig->tlsSubject =3D qemuDomainExtractTLSSubject(cfg->spiceTLSx50= 9certdir))) goto error; =20 - if (VIR_STRDUP(mig->listen, listenAddr) < 0) - goto error; + mig->listen =3D g_strdup(listenAddr); =20 virObjectUnref(cfg); return mig; @@ -293,8 +292,7 @@ qemuMigrationCookieNew(const virDomainDef *def, name =3D origname; else name =3D def->name; - if (VIR_STRDUP(mig->name, name) < 0) - goto error; + mig->name =3D g_strdup(name); memcpy(mig->uuid, def->uuid, VIR_UUID_BUFLEN); =20 if (!(mig->localHostname =3D virGetHostname())) @@ -380,17 +378,13 @@ qemuMigrationCookieAddLockstate(qemuMigrationCookiePt= r mig, } =20 if (virDomainObjGetState(dom, NULL) =3D=3D VIR_DOMAIN_PAUSED) { - if (VIR_STRDUP(mig->lockState, priv->lockState) < 0) - return -1; + mig->lockState =3D g_strdup(priv->lockState); } else { if (virDomainLockProcessInquire(driver->lockManager, dom, &mig->lo= ckState) < 0) return -1; } =20 - if (VIR_STRDUP(mig->lockDriver, virLockManagerPluginGetName(driver->lo= ckManager)) < 0) { - VIR_FREE(mig->lockState); - return -1; - } + mig->lockDriver =3D g_strdup(virLockManagerPluginGetName(driver->lockM= anager)); =20 mig->flags |=3D QEMU_MIGRATION_COOKIE_LOCKSTATE; mig->flagsMandatory |=3D QEMU_MIGRATION_COOKIE_LOCKSTATE; @@ -498,9 +492,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, !(entry =3D virHashLookup(stats, disk->info.alias))) continue; =20 - if (VIR_STRDUP(mig->nbd->disks[mig->nbd->ndisks].target, - disk->dst) < 0) - goto cleanup; + mig->nbd->disks[mig->nbd->ndisks].target =3D g_strdup(disk->dst); mig->nbd->disks[mig->nbd->ndisks].capacity =3D entry->capacity; mig->nbd->ndisks++; } @@ -1516,8 +1508,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver, mig->persistent && STRNEQ(def->name, mig->persistent->name)) { VIR_FREE(mig->persistent->name); - if (VIR_STRDUP(mig->persistent->name, def->name) < 0) - goto error; + mig->persistent->name =3D g_strdup(def->name); } =20 if (mig->flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) { diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 65f533e451..dca12033c0 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -658,8 +658,7 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params) =20 case QEMU_MIGRATION_PARAM_TYPE_STRING: if ((str =3D virJSONValueObjectGetString(params, name))) { - if (VIR_STRDUP(pv->value.s, str) < 0) - goto error; + pv->value.s =3D g_strdup(str); pv->set =3D true; } break; @@ -667,10 +666,6 @@ qemuMigrationParamsFromJSON(virJSONValuePtr params) } =20 return migParams; - - error: - qemuMigrationParamsFree(migParams); - return NULL; } =20 =20 @@ -875,8 +870,7 @@ qemuMigrationParamsSetString(qemuMigrationParamsPtr mig= Params, if (qemuMigrationParamsCheckType(param, QEMU_MIGRATION_PARAM_TYPE_STRI= NG) < 0) return -1; =20 - if (VIR_STRDUP(migParams->params[param].value.s, value) < 0) - return -1; + migParams->params[param].value.s =3D g_strdup(value); =20 migParams->params[param].set =3D true; =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 86d3800108..7891d7e4c1 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2987,8 +2987,8 @@ qemuMonitorAddObject(qemuMonitorPtr mon, goto cleanup; } =20 - if (alias && VIR_STRDUP(tmp, id) < 0) - goto cleanup; + if (alias) + tmp =3D g_strdup(id); =20 ret =3D qemuMonitorJSONAddObject(mon, *props); *props =3D NULL; @@ -3635,15 +3635,13 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMod= elInfo *orig) if (VIR_ALLOC_N(copy->props, orig->nprops) < 0) goto error; =20 - if (VIR_STRDUP(copy->name, orig->name) < 0) - goto error; + copy->name =3D g_strdup(orig->name); =20 copy->migratability =3D orig->migratability; copy->nprops =3D orig->nprops; =20 for (i =3D 0; i < orig->nprops; i++) { - if (VIR_STRDUP(copy->props[i].name, orig->props[i].name) < 0) - goto error; + copy->props[i].name =3D g_strdup(orig->props[i].name); =20 copy->props[i].migratable =3D orig->props[i].migratable; copy->props[i].type =3D orig->props[i].type; @@ -3653,9 +3651,7 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModel= Info *orig) break; =20 case QEMU_MONITOR_CPU_PROPERTY_STRING: - if (VIR_STRDUP(copy->props[i].value.string, - orig->props[i].value.string) < 0) - goto error; + copy->props[i].value.string =3D g_strdup(orig->props[i].value.= string); break; =20 case QEMU_MONITOR_CPU_PROPERTY_NUMBER: diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 602a0380d7..58f84f1b96 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -823,8 +823,7 @@ qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValuePt= r data) ret->data.s390.psw_mask =3D psw_mask; ret->data.s390.psw_addr =3D psw_addr; =20 - if (VIR_STRDUP(ret->data.s390.reason, reason) < 0) - goto error; + ret->data.s390.reason =3D g_strdup(reason); =20 return ret; =20 @@ -1586,8 +1585,7 @@ qemuMonitorJSONHumanCommand(qemuMonitorPtr mon, const char *data; =20 data =3D virJSONValueGetString(obj); - if (VIR_STRDUP(*reply_str, NULLSTR_EMPTY(data)) < 0) - goto cleanup; + *reply_str =3D g_strdup(NULLSTR_EMPTY(data)); } =20 ret =3D 0; @@ -1932,8 +1930,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data, cpus[i].qemu_id =3D cpuid; cpus[i].tid =3D thread; cpus[i].halted =3D halted; - if (VIR_STRDUP(cpus[i].qom_path, qom_path) < 0) - goto cleanup; + cpus[i].qom_path =3D g_strdup(qom_path); =20 /* process optional architecture-specific data */ if (STREQ_NULLABLE(arch, "s390") || STREQ_NULLABLE(arch, "s390x")) @@ -2427,9 +2424,8 @@ qemuMonitorJSONBlockInfoAdd(virHashTablePtr table, *tmp =3D *info; tmp->nodename =3D NULL; =20 - if (info->nodename && - VIR_STRDUP(tmp->nodename, info->nodename) < 0) - goto cleanup; + if (info->nodename) + tmp->nodename =3D g_strdup(info->nodename); =20 if (virHashAddEntry(table, entryname, tmp) < 0) goto cleanup; @@ -3384,8 +3380,8 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr= reply, case QEMU_MONITOR_MIGRATION_STATUS_ERROR: if (error) { tmp =3D virJSONValueObjectGetString(ret, "error-desc"); - if (tmp && VIR_STRDUP(*error, tmp) < 0) - return -1; + if (tmp) + *error =3D g_strdup(tmp); } break; =20 @@ -3921,8 +3917,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg, "in query-rx-filter response")); goto cleanup; } - if (VIR_STRDUP(fil->name, tmp) < 0) - goto cleanup; + fil->name =3D g_strdup(tmp); if ((!(tmp =3D virJSONValueObjectGetString(entry, "main-mac"))) || virMacAddrParse(tmp, &fil->mac) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -4151,9 +4146,8 @@ qemuMonitorJSONExtractChardevInfo(virJSONValuePtr rep= ly, if (VIR_ALLOC(entry) < 0) goto cleanup; =20 - if (STRPREFIX(type, "pty:") && - VIR_STRDUP(entry->ptyPath, type + strlen("pty:")) < 0) - goto cleanup; + if (STRPREFIX(type, "pty:")) + entry->ptyPath =3D g_strdup(type + strlen("pty:")); =20 if (virJSONValueObjectGetBoolean(chardev, "frontend-open", &connec= ted) =3D=3D 0) { if (connected) @@ -4544,8 +4538,7 @@ qemuMonitorJSONDiskNameLookupOne(virJSONValuePtr imag= e, return qemuMonitorJSONDiskNameLookupOne(backing, top->backingStore, target); } - if (VIR_STRDUP(ret, virJSONValueObjectGetString(image, "filename")) < = 0) - return NULL; + ret =3D g_strdup(virJSONValueObjectGetString(image, "filename")); /* Sanity check - the name qemu gave us should resolve to the same file tracked by our target description. */ if (virStorageSourceIsLocalStorage(target) && @@ -5196,9 +5189,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr io= _throttle, GET_THROTTLE_STATS_OPTIONAL("iops_wr_max", write_iops_sec_max); GET_THROTTLE_STATS_OPTIONAL("iops_size", size_iops_sec); =20 - if (VIR_STRDUP(reply->group_name, - virJSONValueObjectGetString(inserted, "group")) < 0) - goto cleanup; + reply->group_name =3D g_strdup(virJSONValueObjectGetString(inserte= d, "group")); =20 GET_THROTTLE_STATS_OPTIONAL("bps_max_length", total_bytes_sec_max_= length); GET_THROTTLE_STATS_OPTIONAL("bps_rd_max_length", read_bytes_sec_ma= x_length); @@ -5418,8 +5409,7 @@ int qemuMonitorJSONGetVersion(qemuMonitorPtr mon, _("query-version reply was missing 'package' ve= rsion")); goto cleanup; } - if (VIR_STRDUP(*package, tmp) < 0) - goto cleanup; + *package =3D g_strdup(tmp); } =20 ret =3D 0; @@ -5476,8 +5466,7 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(info->name, tmp) < 0) - goto cleanup; + info->name =3D g_strdup(tmp); =20 if (virJSONValueObjectHasKey(child, "is-default") && virJSONValueObjectGetBoolean(child, "is-default", &info->isDef= ault) < 0) { @@ -5492,8 +5481,7 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon, _("query-machines reply has malformed 'alia= s' data")); goto cleanup; } - if (VIR_STRDUP(info->alias, tmp) < 0) - goto cleanup; + info->alias =3D g_strdup(tmp); } if (virJSONValueObjectHasKey(child, "cpu-max") && virJSONValueObjectGetNumberUint(child, "cpu-max", &info->maxCp= us) < 0) { @@ -5576,8 +5564,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(cpu->name, tmp) < 0) - goto cleanup; + cpu->name =3D g_strdup(tmp); =20 if (virJSONValueObjectHasKey(child, "unavailable-features")) { virJSONValuePtr blockers; @@ -5614,8 +5601,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(cpu->blockers[j], virJSONValueGetString(blo= cker)) < 0) - goto cleanup; + cpu->blockers[j] =3D g_strdup(virJSONValueGetString(blocke= r)); } } } @@ -5653,8 +5639,7 @@ qemuMonitorJSONParseCPUModelProperty(const char *key, =20 switch ((virJSONType)virJSONValueGetType(value)) { case VIR_JSON_TYPE_STRING: - if (VIR_STRDUP(prop->value.string, virJSONValueGetString(value)) <= 0) - return -1; + prop->value.string =3D g_strdup(virJSONValueGetString(value)); prop->type =3D QEMU_MONITOR_CPU_PROPERTY_STRING; break; =20 @@ -5677,8 +5662,7 @@ qemuMonitorJSONParseCPUModelProperty(const char *key, } =20 machine_model->nprops++; - if (VIR_STRDUP(prop->name, key) < 0) - return -1; + prop->name =3D g_strdup(key); =20 return 0; } @@ -5776,8 +5760,7 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, if (VIR_ALLOC(machine_model) < 0) goto cleanup; =20 - if (VIR_STRDUP(machine_model->name, cpu_name) < 0) - goto cleanup; + machine_model->name =3D g_strdup(cpu_name); =20 if (cpu_props) { size_t nprops =3D virJSONValueObjectKeysNumber(cpu_props); @@ -6001,8 +5984,7 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(commandlist[i], tmp) < 0) - goto cleanup; + commandlist[i] =3D g_strdup(tmp); } =20 ret =3D n; @@ -6062,8 +6044,7 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(eventlist[i], tmp) < 0) - goto cleanup; + eventlist[i] =3D g_strdup(tmp); } =20 ret =3D n; @@ -6179,8 +6160,7 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMon= itorPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(paramlist[i], tmp) < 0) - goto cleanup; + paramlist[i] =3D g_strdup(tmp); } =20 ret =3D n; @@ -6283,8 +6263,7 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(typelist[i], tmp) < 0) - goto cleanup; + typelist[i] =3D g_strdup(tmp); } =20 ret =3D n; @@ -6347,8 +6326,7 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr = mon, goto cleanup; } =20 - if (VIR_STRDUP(info->name, tmp) < 0) - goto cleanup; + info->name =3D g_strdup(tmp); =20 if (virJSONValueObjectHasKey(child, "type")) { if (!(tmp =3D virJSONValueObjectGetString(child, "type"))) { @@ -6356,8 +6334,7 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr = mon, _("qom-list reply has malformed 'type' data= ")); goto cleanup; } - if (VIR_STRDUP(info->type, tmp) < 0) - goto cleanup; + info->type =3D g_strdup(tmp); } } =20 @@ -6435,8 +6412,8 @@ int qemuMonitorJSONGetObjectProperty(qemuMonitorPtr m= on, break; case QEMU_MONITOR_OBJECT_PROPERTY_STRING: tmp =3D virJSONValueGetString(data); - if (tmp && VIR_STRDUP(prop->val.str, tmp) < 0) - goto cleanup; + if (tmp) + prop->val.str =3D g_strdup(tmp); if (tmp) ret =3D 0; break; @@ -6505,8 +6482,7 @@ qemuMonitorJSONGetStringListProperty(qemuMonitorPtr m= on, return -1; } =20 - if (VIR_STRDUP(list[i], virJSONValueGetString(item)) < 0) - return -1; + list[i] =3D g_strdup(virJSONValueGetString(item)); } =20 *strList =3D g_steal_pointer(&list); @@ -6617,8 +6593,7 @@ qemuMonitorJSONParsePropsList(virJSONValuePtr cmd, goto cleanup; } =20 - if (VIR_STRDUP(proplist[count++], tmp) < 0) - goto cleanup; + proplist[count++] =3D g_strdup(tmp); } =20 ret =3D count; @@ -6780,8 +6755,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPt= r mon, goto cleanup; } =20 - if (VIR_STRDUP(list[i], name) < 1) - goto cleanup; + list[i] =3D g_strdup(name); } =20 ret =3D n; @@ -7014,11 +6988,9 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon, if (VIR_ALLOC(capability) < 0) goto cleanup; =20 - if (VIR_STRDUP(capability->pdh, pdh) < 0) - goto cleanup; + capability->pdh =3D g_strdup(pdh); =20 - if (VIR_STRDUP(capability->cert_chain, cert_chain) < 0) - goto cleanup; + capability->cert_chain =3D g_strdup(cert_chain); =20 capability->cbitpos =3D cbitpos; capability->reduced_phys_bits =3D reduced_phys_bits; @@ -7224,8 +7196,7 @@ qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, con= st char *qmpCmd, goto cleanup; } =20 - if (VIR_STRDUP(list[i], tmp) < 0) - goto cleanup; + list[i] =3D g_strdup(tmp); } =20 ret =3D n; @@ -7458,8 +7429,7 @@ qemuMonitorJSONAttachCharDev(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_STRDUP(chr->data.file.path, path) < 0) - goto cleanup; + chr->data.file.path =3D g_strdup(path); } =20 ret =3D 0; @@ -8465,8 +8435,7 @@ qemuMonitorJSONProcessHotpluggableCpusReply(virJSONVa= luePtr vcpu, return -1; } =20 - if (VIR_STRDUP(entry->type, tmp) < 0) - return -1; + entry->type =3D g_strdup(tmp); =20 if (virJSONValueObjectGetNumberUint(vcpu, "vcpus-count", &entry->vcpus= ) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -8503,14 +8472,11 @@ qemuMonitorJSONProcessHotpluggableCpusReply(virJSON= ValuePtr vcpu, =20 /* qom path is not present unless the vCPU is online */ if ((tmp =3D virJSONValueObjectGetString(vcpu, "qom-path"))) { - if (VIR_STRDUP(entry->qom_path, tmp) < 0) - return -1; + entry->qom_path =3D g_strdup(tmp); =20 /* alias is the part after last slash having a "vcpu" prefix */ - if ((tmp =3D strrchr(tmp, '/')) && STRPREFIX(tmp + 1, "vcpu")) { - if (VIR_STRDUP(entry->alias, tmp + 1) < 0) - return -1; - } + if ((tmp =3D strrchr(tmp, '/')) && STRPREFIX(tmp + 1, "vcpu")) + entry->alias =3D g_strdup(tmp + 1); } =20 return 0; @@ -8921,8 +8887,7 @@ qemuMonitorJSONGetSEVMeasurement(qemuMonitorPtr mon) if (!(tmp =3D virJSONValueObjectGetString(data, "data"))) goto cleanup; =20 - if (VIR_STRDUP(measurement, tmp) < 0) - goto cleanup; + measurement =3D g_strdup(tmp); =20 cleanup: virJSONValueFree(cmd); @@ -9309,9 +9274,8 @@ qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data) =20 job->status =3D tmp; =20 - if (VIR_STRDUP(job->id, id) < 0 || - VIR_STRDUP(job->error, errmsg) < 0) - return NULL; + job->id =3D g_strdup(id); + job->error =3D g_strdup(errmsg); =20 ret =3D g_steal_pointer(&job); return ret; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 843e852591..7e0dc26658 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -967,8 +967,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon G_GNUC_UNU= SED, goto cleanup; =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_BLOCK_JOB; - if (VIR_STRDUP(data, diskAlias) < 0) - goto cleanup; + data =3D g_strdup(diskAlias); processEvent->data =3D data; processEvent->vm =3D virObjectRef(vm); processEvent->action =3D type; @@ -1076,16 +1075,14 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC= _UNUSED, if (VIR_ALLOC(localAddr) < 0) goto error; localAddr->family =3D localFamily; - if (VIR_STRDUP(localAddr->service, localService) < 0 || - VIR_STRDUP(localAddr->node, localNode) < 0) - goto error; + localAddr->service =3D g_strdup(localService); + localAddr->node =3D g_strdup(localNode); =20 if (VIR_ALLOC(remoteAddr) < 0) goto error; remoteAddr->family =3D remoteFamily; - if (VIR_STRDUP(remoteAddr->service, remoteService) < 0 || - VIR_STRDUP(remoteAddr->node, remoteNode) < 0) - goto error; + remoteAddr->service =3D g_strdup(remoteService); + remoteAddr->node =3D g_strdup(remoteNode); =20 if (VIR_ALLOC(subject) < 0) goto error; @@ -1093,17 +1090,15 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC= _UNUSED, if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0) goto error; subject->nidentity++; - if (VIR_STRDUP(subject->identities[subject->nidentity-1].type, "x5= 09dname") < 0 || - VIR_STRDUP(subject->identities[subject->nidentity-1].name, x50= 9dname) < 0) - goto error; + subject->identities[subject->nidentity - 1].type =3D g_strdup("x50= 9dname"); + subject->identities[subject->nidentity - 1].name =3D g_strdup(x509= dname); } if (saslUsername) { if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0) goto error; subject->nidentity++; - if (VIR_STRDUP(subject->identities[subject->nidentity-1].type, "sa= slUsername") < 0 || - VIR_STRDUP(subject->identities[subject->nidentity-1].name, sas= lUsername) < 0) - goto error; + subject->identities[subject->nidentity - 1].type =3D g_strdup("sas= lUsername"); + subject->identities[subject->nidentity - 1].name =3D g_strdup(sasl= Username); } =20 virObjectLock(vm); @@ -1385,8 +1380,7 @@ qemuProcessHandleDeviceDeleted(qemuMonitorPtr mon G_G= NUC_UNUSED, goto error; =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_DEVICE_DELETED; - if (VIR_STRDUP(data, devAlias) < 0) - goto error; + data =3D g_strdup(devAlias); processEvent->data =3D data; processEvent->vm =3D virObjectRef(vm); =20 @@ -1559,8 +1553,7 @@ qemuProcessHandleNicRxFilterChanged(qemuMonitorPtr mo= n G_GNUC_UNUSED, goto error; =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED; - if (VIR_STRDUP(data, devAlias) < 0) - goto error; + data =3D g_strdup(devAlias); processEvent->data =3D data; processEvent->vm =3D virObjectRef(vm); =20 @@ -1598,8 +1591,7 @@ qemuProcessHandleSerialChanged(qemuMonitorPtr mon G_G= NUC_UNUSED, goto error; =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_SERIAL_CHANGED; - if (VIR_STRDUP(data, devAlias) < 0) - goto error; + data =3D g_strdup(devAlias); processEvent->data =3D data; processEvent->action =3D connected; processEvent->vm =3D virObjectRef(vm); @@ -1839,10 +1831,11 @@ qemuProcessHandleRdmaGidStatusChanged(qemuMonitorPt= r mon G_GNUC_UNUSED, VIR_DEBUG("netdev=3D%s,gid_status=3D%d,subnet_prefix=3D0x%llx,interfac= e_id=3D0x%llx", netdev, gid_status, subnet_prefix, interface_id); =20 - if (VIR_ALLOC(info) < 0 || - VIR_STRDUP(info->netdev, netdev) < 0) + if (VIR_ALLOC(info) < 0) goto cleanup; =20 + info->netdev =3D g_strdup(netdev); + info->gid_status =3D gid_status; info->subnet_prefix =3D subnet_prefix; info->interface_id =3D interface_id; @@ -2133,8 +2126,7 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices, } =20 VIR_FREE(chr->source->data.file.path); - if (VIR_STRDUP(chr->source->data.file.path, entry->ptyPath) < = 0) - goto cleanup; + chr->source->data.file.path =3D g_strdup(entry->ptyPath); } } =20 @@ -4586,8 +4578,7 @@ qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps, if (VIR_ALLOC(inc) < 0) return NULL; =20 - if (VIR_STRDUP(inc->address, listenAddress) < 0) - goto error; + inc->address =3D g_strdup(listenAddress); =20 inc->launchURI =3D qemuMigrationDstGetURI(migrateFrom, fd); if (!inc->launchURI) @@ -4595,8 +4586,7 @@ qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps, =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_INCOMING_DEFER)) { inc->deferredURI =3D inc->launchURI; - if (VIR_STRDUP(inc->launchURI, "defer") < 0) - goto error; + inc->launchURI =3D g_strdup("defer"); } =20 inc->fd =3D fd; @@ -4865,8 +4855,7 @@ qemuProcessGraphicsSetupNetworkAddress(virDomainGraph= icsListenDefPtr glisten, =20 /* TODO: reject configuration without network specified for network li= sten */ if (!glisten->network) { - if (VIR_STRDUP(glisten->address, listenAddr) < 0) - return -1; + glisten->address =3D g_strdup(listenAddr); return 0; } =20 @@ -4933,8 +4922,7 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr drive= r, glisten->fromConfig =3D true; glisten->type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCK= ET; } else if (listenAddr) { - if (VIR_STRDUP(glisten->address, listenAddr) < 0) - goto cleanup; + glisten->address =3D g_strdup(listenAddr); glisten->fromConfig =3D true; } } @@ -8477,9 +8465,8 @@ qemuProcessQMPNew(const char *binary, if (VIR_ALLOC(proc) < 0) goto cleanup; =20 - if (VIR_STRDUP(proc->binary, binary) < 0 || - VIR_STRDUP(proc->libDir, libDir) < 0) - goto cleanup; + proc->binary =3D g_strdup(binary); + proc->libDir =3D g_strdup(libDir); =20 proc->runUid =3D runUid; proc->runGid =3D runGid; diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c index dfef6f20a3..789d29ce43 100644 --- a/src/qemu/qemu_vhost_user.c +++ b/src/qemu/qemu_vhost_user.c @@ -172,8 +172,7 @@ qemuVhostUserBinaryParse(const char *path, VIR_DEBUG("vhost-user description path '%s' binary : %s", path, binary); =20 - if (VIR_STRDUP(vu->binary, binary) < 0) - return -1; + vu->binary =3D g_strdup(binary); =20 return 0; } @@ -389,8 +388,7 @@ qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver, goto end; =20 VIR_FREE(video->driver->vhost_user_binary); - if (VIR_STRDUP(video->driver->vhost_user_binary, vu->binary) < 0) - goto end; + video->driver->vhost_user_binary =3D g_strdup(vu->binary); =20 break; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576211; cv=none; d=zoho.com; s=zohoarc; b=WdkEKkfFRlSznwFBuUMZ76/w0yZv2jh5CzEByv2EZ0E+JxWVASku5MnWSFoIUohli7LqOnFv8gqV2+RuPzptZl2knmNAfeeWPeh8MHH6OuY7Nm+Bo6At+Bw73RcGzMdTD9kTbhd8wc+XC1vQQJt0sVuD1iXdAjs4sjS/j8Of7hI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576211; 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=UGvF+edK9Y8UpNvDXeYdj860OJIBZv2EOPTKxwDe5qo=; b=kn8OaP4vk891TIWxzutqs8acx5RTPRlZzVZAQz8JJCrgXoN4ejRyB22PmhIVoswNMURA7NjtMWfaynOcynRDbVf63oc92KddkFSQYL95h0hUGNgldALYIpYs4X5Oo7bAdrDTNYcSj4sQ9aAwIInc2Np/JQpMNIOsA81JrknSP6E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576211374781.7557846968149; Sun, 20 Oct 2019 05:56:51 -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-373-tnyzh_kaOyGEM80chjuJlg-1; Sun, 20 Oct 2019 08:56:47 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D45E107AFC6; Sun, 20 Oct 2019 12:56:43 +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 EDA21194B9; Sun, 20 Oct 2019 12:56:42 +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 AE9A3180B536; Sun, 20 Oct 2019 12:56:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCu1kH023537 for ; Sun, 20 Oct 2019 08:56:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6DAEE3CC8; Sun, 20 Oct 2019 12:56:01 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC3B0194B9 for ; Sun, 20 Oct 2019 12:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576210; 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=UGvF+edK9Y8UpNvDXeYdj860OJIBZv2EOPTKxwDe5qo=; b=LwFLSAhcjYqmfQRa2E1NnCkkIuv0Tbe9jl3yuCzPscgcES5v3Q+sD7RfqQhOWLFx/A9Ahj 2Qw993Kq4HF/x1TxYw0eygTSQloapIu3SpLo51Alnj2Uexkwb3tGXCe2fUL96EiLCELbgr yRGixVKPqJcpW8W1vicnVC3zHk5u4bk= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:41 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 23/34] remote: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: tnyzh_kaOyGEM80chjuJlg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/remote/remote_daemon.c | 15 +- src/remote/remote_daemon_config.c | 24 +-- src/remote/remote_daemon_dispatch.c | 222 +++++++++++----------------- src/remote/remote_driver.c | 106 +++++-------- 4 files changed, 132 insertions(+), 235 deletions(-) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index e87ff12512..7e63e18034 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -1100,18 +1100,12 @@ int main(int argc, char **argv) { =20 case 'p': VIR_FREE(pid_file); - if (VIR_STRDUP_QUIET(pid_file, optarg) < 0) { - VIR_ERROR(_("Can't allocate memory")); - exit(EXIT_FAILURE); - } + pid_file =3D g_strdup(optarg); break; =20 case 'f': VIR_FREE(remote_config_file); - if (VIR_STRDUP_QUIET(remote_config_file, optarg) < 0) { - VIR_ERROR(_("Can't allocate memory")); - exit(EXIT_FAILURE); - } + remote_config_file =3D g_strdup(optarg); break; =20 case 'V': @@ -1222,10 +1216,7 @@ int main(int argc, char **argv) { =20 /* Ensure the rundir exists (on tmpfs on some systems) */ if (privileged) { - if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0) { - VIR_ERROR(_("Can't allocate memory")); - goto cleanup; - } + run_dir =3D g_strdup(RUNSTATEDIR "/libvirt"); } else { run_dir =3D virGetUserRuntimeDirectory(); =20 diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_c= onfig.c index 4c712bf2dc..3187c9acb1 100644 --- a/src/remote/remote_daemon_config.c +++ b/src/remote/remote_daemon_config.c @@ -77,9 +77,7 @@ int daemonConfigFilePath(bool privileged, char **configfile) { if (privileged) { - if (VIR_STRDUP(*configfile, - SYSCONFDIR "/libvirt/" DAEMON_NAME ".conf") < 0) - goto error; + *configfile =3D g_strdup(SYSCONFDIR "/libvirt/" DAEMON_NAME ".conf= "); } else { char *configdir =3D NULL; =20 @@ -115,9 +113,8 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED) # endif /* ! LIBVIRTD */ data->listen_tcp =3D 0; =20 - if (VIR_STRDUP(data->tls_port, LIBVIRTD_TLS_PORT) < 0 || - VIR_STRDUP(data->tcp_port, LIBVIRTD_TCP_PORT) < 0) - goto error; + data->tls_port =3D g_strdup(LIBVIRTD_TLS_PORT); + data->tcp_port =3D g_strdup(LIBVIRTD_TCP_PORT); #endif /* !WITH_IP */ =20 /* Only default to PolicyKit if running as root */ @@ -133,11 +130,9 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED) } #endif =20 - if (VIR_STRDUP(data->unix_sock_rw_perms, - data->auth_unix_rw =3D=3D REMOTE_AUTH_POLKIT ? "0777" := "0700") < 0 || - VIR_STRDUP(data->unix_sock_ro_perms, "0777") < 0 || - VIR_STRDUP(data->unix_sock_admin_perms, "0700") < 0) - goto error; + data->unix_sock_rw_perms =3D g_strdup(data->auth_unix_rw =3D=3D REMOTE= _AUTH_POLKIT ? "0777" : "0700"); + data->unix_sock_ro_perms =3D g_strdup("0777"); + data->unix_sock_admin_perms =3D g_strdup("0700"); =20 #ifdef WITH_IP # if WITH_SASL @@ -176,10 +171,6 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED) data->ovs_timeout =3D VIR_NETDEV_OVS_DEFAULT_TIMEOUT; =20 return data; - - error: - daemonConfigFree(data); - return NULL; } =20 void @@ -266,8 +257,7 @@ daemonConfigLoadOptions(struct daemonConfig *data, */ if (data->auth_unix_rw =3D=3D REMOTE_AUTH_POLKIT) { VIR_FREE(data->unix_sock_rw_perms); - if (VIR_STRDUP(data->unix_sock_rw_perms, "0777") < 0) - goto error; + data->unix_sock_rw_perms =3D g_strdup("0777"); } #endif if (remoteConfigGetAuth(conf, filename, "auth_unix_ro", &data->auth_un= ix_ro) < 0) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 56a46a13be..203aeff8c3 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -509,9 +509,8 @@ remoteRelayDomainEventIOError(virConnectPtr conn, =20 /* build return data */ memset(&data, 0, sizeof(data)); - if (VIR_STRDUP(data.srcPath, srcPath) < 0 || - VIR_STRDUP(data.devAlias, devAlias) < 0) - goto error; + data.srcPath =3D g_strdup(srcPath); + data.devAlias =3D g_strdup(devAlias); if (make_nonnull_domain(&data.dom, dom) < 0) goto error; data.action =3D action; @@ -559,10 +558,9 @@ remoteRelayDomainEventIOErrorReason(virConnectPtr conn, =20 /* build return data */ memset(&data, 0, sizeof(data)); - if (VIR_STRDUP(data.srcPath, srcPath) < 0 || - VIR_STRDUP(data.devAlias, devAlias) < 0 || - VIR_STRDUP(data.reason, reason) < 0) - goto error; + data.srcPath =3D g_strdup(srcPath); + data.devAlias =3D g_strdup(devAlias); + data.reason =3D g_strdup(reason); data.action =3D action; =20 if (make_nonnull_domain(&data.dom, dom) < 0) @@ -623,21 +621,23 @@ remoteRelayDomainEventGraphics(virConnectPtr conn, data.phase =3D phase; data.local.family =3D local->family; data.remote.family =3D remote->family; - if (VIR_STRDUP(data.authScheme, authScheme) < 0 || - VIR_STRDUP(data.local.node, local->node) < 0 || - VIR_STRDUP(data.local.service, local->service) < 0 || - VIR_STRDUP(data.remote.node, remote->node) < 0 || - VIR_STRDUP(data.remote.service, remote->service) < 0) - goto error; + data.authScheme =3D g_strdup(authScheme); + + data.local.node =3D g_strdup(local->node); + + data.local.service =3D g_strdup(local->service); + + data.remote.node =3D g_strdup(remote->node); + + data.remote.service =3D g_strdup(remote->service); =20 data.subject.subject_len =3D subject->nidentity; if (VIR_ALLOC_N(data.subject.subject_val, data.subject.subject_len) < = 0) goto error; =20 for (i =3D 0; i < data.subject.subject_len; i++) { - if (VIR_STRDUP(data.subject.subject_val[i].type, subject->identiti= es[i].type) < 0 || - VIR_STRDUP(data.subject.subject_val[i].name, subject->identiti= es[i].name) < 0) - goto error; + data.subject.subject_val[i].type =3D g_strdup(subject->identities[= i].type); + data.subject.subject_val[i].name =3D g_strdup(subject->identities[= i].name); } if (make_nonnull_domain(&data.dom, dom) < 0) goto error; @@ -683,8 +683,7 @@ remoteRelayDomainEventBlockJob(virConnectPtr conn, =20 /* build return data */ memset(&data, 0, sizeof(data)); - if (VIR_STRDUP(data.path, path) < 0) - return -1; + data.path =3D g_strdup(path); data.type =3D type; data.status =3D status; if (make_nonnull_domain(&data.dom, dom) < 0) @@ -776,18 +775,19 @@ remoteRelayDomainEventDiskChange(virConnectPtr conn, =20 /* build return data */ memset(&data, 0, sizeof(data)); - if (oldSrcPath && - ((VIR_ALLOC(data.oldSrcPath) < 0) || - VIR_STRDUP(*(data.oldSrcPath), oldSrcPath) < 0)) - goto error; + if (oldSrcPath) { + if (VIR_ALLOC(data.oldSrcPath) < 0) + goto error; + *(data.oldSrcPath) =3D g_strdup(oldSrcPath); + } =20 - if (newSrcPath && - ((VIR_ALLOC(data.newSrcPath) < 0) || - VIR_STRDUP(*(data.newSrcPath), newSrcPath) < 0)) - goto error; + if (newSrcPath) { + if (VIR_ALLOC(data.newSrcPath) < 0) + goto error; + *(data.newSrcPath) =3D g_strdup(newSrcPath); + } =20 - if (VIR_STRDUP(data.devAlias, devAlias) < 0) - goto error; + data.devAlias =3D g_strdup(devAlias); data.reason =3D reason; =20 if (make_nonnull_domain(&data.dom, dom) < 0) @@ -835,8 +835,7 @@ remoteRelayDomainEventTrayChange(virConnectPtr conn, /* build return data */ memset(&data, 0, sizeof(data)); =20 - if (VIR_STRDUP(data.devAlias, devAlias) < 0) - return -1; + data.devAlias =3D g_strdup(devAlias); data.reason =3D reason; =20 if (make_nonnull_domain(&data.dom, dom) < 0) @@ -1052,8 +1051,7 @@ remoteRelayDomainEventDeviceRemoved(virConnectPtr con= n, /* build return data */ memset(&data, 0, sizeof(data)); =20 - if (VIR_STRDUP(data.devAlias, devAlias) < 0) - return -1; + data.devAlias =3D g_strdup(devAlias); =20 if (make_nonnull_domain(&data.dom, dom) < 0) goto error; @@ -1103,8 +1101,7 @@ remoteRelayDomainEventBlockJob2(virConnectPtr conn, /* build return data */ memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; - if (VIR_STRDUP(data.dst, dst) < 0) - return -1; + data.dst =3D g_strdup(dst); data.type =3D type; data.status =3D status; if (make_nonnull_domain(&data.dom, dom) < 0) @@ -1228,8 +1225,7 @@ remoteRelayDomainEventDeviceAdded(virConnectPtr conn, /* build return data */ memset(&data, 0, sizeof(data)); =20 - if (VIR_STRDUP(data.devAlias, devAlias) < 0) - return -1; + data.devAlias =3D g_strdup(devAlias); =20 if (make_nonnull_domain(&data.dom, dom) < 0) goto error; @@ -1352,8 +1348,7 @@ remoteRelayDomainEventDeviceRemovalFailed(virConnectP= tr conn, /* build return data */ memset(&data, 0, sizeof(data)); =20 - if (VIR_STRDUP(data.devAlias, devAlias) < 0) - return -1; + data.devAlias =3D g_strdup(devAlias); =20 if (make_nonnull_domain(&data.dom, dom) < 0) goto error; @@ -1395,9 +1390,9 @@ remoteRelayDomainEventMetadataChange(virConnectPtr co= nn, =20 data.type =3D type; if (nsuri) { - if (VIR_ALLOC(data.nsuri) < 0 || - VIR_STRDUP(*(data.nsuri), nsuri) < 0) + if (VIR_ALLOC(data.nsuri) < 0) goto error; + *(data.nsuri) =3D g_strdup(nsuri); } =20 if (make_nonnull_domain(&data.dom, dom) < 0) @@ -1440,12 +1435,11 @@ remoteRelayDomainEventBlockThreshold(virConnectPtr = conn, /* build return data */ memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; - if (VIR_STRDUP(data.dev, dev) < 0) - goto error; + data.dev =3D g_strdup(dev); if (path) { - if (VIR_ALLOC(data.path) < 0 || - VIR_STRDUP(*(data.path), path) < 0) + if (VIR_ALLOC(data.path) < 0) goto error; + *(data.path) =3D g_strdup(path); } data.threshold =3D threshold; data.excess =3D excess; @@ -1798,14 +1792,14 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr con= n, /* build return data */ memset(&data, 0, sizeof(data)); data.callbackID =3D callback->callbackID; - if (VIR_STRDUP(data.event, event) < 0) - goto error; + data.event =3D g_strdup(event); data.seconds =3D seconds; data.micros =3D micros; - if (details && - ((VIR_ALLOC(data.details) < 0) || - VIR_STRDUP(*(data.details), details) < 0)) - goto error; + if (details) { + if (VIR_ALLOC(data.details) < 0) + goto error; + *(data.details) =3D g_strdup(details); + } if (make_nonnull_domain(&data.dom, dom) < 0) goto error; =20 @@ -2886,11 +2880,7 @@ remoteDispatchDomainGetSecurityLabelList(virNetServe= rPtr server G_GNUC_UNUSED, for (i =3D 0; i < len; i++) { size_t label_len =3D strlen(seclabels[i].label) + 1; remote_domain_get_security_label_ret *cur =3D &ret->labels.labels_= val[i]; - if (VIR_STRDUP(cur->label.label_val, seclabels[i].label) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to copy security label")); - goto cleanup; - } + cur->label.label_val =3D g_strdup(seclabels[i].label); cur->label.label_len =3D label_len; cur->enforcing =3D seclabels[i].enforcing; } @@ -3560,8 +3550,7 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server = G_GNUC_UNUSED, =20 for (i =3D 0; i < nparams; ++i) { /* remoteDispatchClientRequest will free this: */ - if (VIR_STRDUP(ret->params.params_val[i].field, params[i].field) <= 0) - goto cleanup; + ret->params.params_val[i].field =3D g_strdup(params[i].field); =20 ret->params.params_val[i].value =3D params[i].value; } @@ -3629,8 +3618,7 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr serv= er G_GNUC_UNUSED, =20 for (i =3D 0; i < nparams; ++i) { /* remoteDispatchClientRequest will free this: */ - if (VIR_STRDUP(ret->params.params_val[i].field, params[i].field) <= 0) - goto cleanup; + ret->params.params_val[i].field =3D g_strdup(params[i].field); =20 ret->params.params_val[i].value =3D params[i].value; } @@ -4365,9 +4353,9 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr ser= ver G_GNUC_UNUSED, ret->parentName =3D NULL; } else { /* remoteDispatchClientRequest will free this. */ - if (VIR_ALLOC(ret->parentName) < 0 || - VIR_STRDUP(*(ret->parentName), parent) < 0) + if (VIR_ALLOC(ret->parentName) < 0) goto cleanup; + *(ret->parentName) =3D g_strdup(parent); } =20 rv =3D 0; @@ -6907,29 +6895,28 @@ remoteSerializeDHCPLease(remote_network_dhcp_lease = *lease_dst, virNetworkDHCPLea lease_dst->type =3D lease_src->type; lease_dst->prefix =3D lease_src->prefix; =20 - if (VIR_STRDUP(lease_dst->iface, lease_src->iface) < 0 || - VIR_STRDUP(lease_dst->ipaddr, lease_src->ipaddr) < 0) - goto error; + lease_dst->iface =3D g_strdup(lease_src->iface); + lease_dst->ipaddr =3D g_strdup(lease_src->ipaddr); =20 if (lease_src->mac) { - if (VIR_ALLOC(mac_tmp) < 0 || - VIR_STRDUP(*mac_tmp, lease_src->mac) < 0) + if (VIR_ALLOC(mac_tmp) < 0) goto error; + *mac_tmp =3D g_strdup(lease_src->mac); } if (lease_src->iaid) { - if (VIR_ALLOC(iaid_tmp) < 0 || - VIR_STRDUP(*iaid_tmp, lease_src->iaid) < 0) + if (VIR_ALLOC(iaid_tmp) < 0) goto error; + *iaid_tmp =3D g_strdup(lease_src->iaid); } if (lease_src->hostname) { - if (VIR_ALLOC(hostname_tmp) < 0 || - VIR_STRDUP(*hostname_tmp, lease_src->hostname) < 0) + if (VIR_ALLOC(hostname_tmp) < 0) goto error; + *hostname_tmp =3D g_strdup(lease_src->hostname); } if (lease_src->clientid) { - if (VIR_ALLOC(clientid_tmp) < 0 || - VIR_STRDUP(*clientid_tmp, lease_src->clientid) < 0) + if (VIR_ALLOC(clientid_tmp) < 0) goto error; + *clientid_tmp =3D g_strdup(lease_src->clientid); } =20 lease_dst->mac =3D mac_tmp; @@ -7188,14 +7175,11 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr serve= r G_GNUC_UNUSED, =20 for (i =3D 0; i < ninfo; i++) { dst =3D &ret->info.info_val[i]; - if (VIR_STRDUP(dst->mountpoint, info[i]->mountpoint) < 0) - goto cleanup; + dst->mountpoint =3D g_strdup(info[i]->mountpoint); =20 - if (VIR_STRDUP(dst->name, info[i]->name) < 0) - goto cleanup; + dst->name =3D g_strdup(info[i]->name); =20 - if (VIR_STRDUP(dst->fstype, info[i]->fstype) < 0) - goto cleanup; + dst->fstype =3D g_strdup(info[i]->fstype); =20 ndisk =3D info[i]->ndevAlias; if (ndisk > REMOTE_DOMAIN_FSINFO_DISKS_MAX) { @@ -7209,11 +7193,8 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server= G_GNUC_UNUSED, if (VIR_ALLOC_N(dst->dev_aliases.dev_aliases_val, ndisk) <= 0) goto cleanup; =20 - for (j =3D 0; j < ndisk; j++) { - if (VIR_STRDUP(dst->dev_aliases.dev_aliases_val[j], - info[i]->devAlias[j]) < 0) - goto cleanup; - } + for (j =3D 0; j < ndisk; j++) + dst->dev_aliases.dev_aliases_val[j] =3D g_strdup(info[= i]->devAlias[j]); =20 dst->dev_aliases.dev_aliases_len =3D ndisk; } else { @@ -7281,13 +7262,13 @@ remoteSerializeDomainInterface(virDomainInterfacePt= r *ifaces, virDomainInterfacePtr iface =3D ifaces[i]; remote_domain_interface *iface_ret =3D &(ret->ifaces.ifaces_val[i]= ); =20 - if ((VIR_STRDUP(iface_ret->name, iface->name)) < 0) - goto cleanup; + iface_ret->name =3D g_strdup(iface->name); =20 - if (iface->hwaddr && - (VIR_ALLOC(iface_ret->hwaddr) < 0 || - VIR_STRDUP(*iface_ret->hwaddr, iface->hwaddr) < 0)) - goto cleanup; + if (iface->hwaddr) { + if (VIR_ALLOC(iface_ret->hwaddr) < 0) + goto cleanup; + *iface_ret->hwaddr =3D g_strdup(iface->hwaddr); + } =20 if (iface->naddrs > REMOTE_DOMAIN_IP_ADDR_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -7307,8 +7288,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr = *ifaces, remote_domain_ip_addr *ip_addr_ret =3D &(iface_ret->addrs.addrs_val[j]); =20 - if (VIR_STRDUP(ip_addr_ret->addr, ip_addr->addr) < 0) - goto cleanup; + ip_addr_ret->addr =3D g_strdup(ip_addr->addr); =20 ip_addr_ret->prefix =3D ip_addr->prefix; ip_addr_ret->type =3D ip_addr->type; @@ -7559,8 +7539,7 @@ static int make_nonnull_domain(remote_nonnull_domain *dom_dst, virDomainPtr dom_src) { dom_dst->id =3D dom_src->id; - if (VIR_STRDUP(dom_dst->name, dom_src->name) < 0) - return -1; + dom_dst->name =3D g_strdup(dom_src->name); memcpy(dom_dst->uuid, dom_src->uuid, VIR_UUID_BUFLEN); return 0; } @@ -7568,8 +7547,7 @@ make_nonnull_domain(remote_nonnull_domain *dom_dst, v= irDomainPtr dom_src) static int make_nonnull_network(remote_nonnull_network *net_dst, virNetworkPtr net_sr= c) { - if (VIR_STRDUP(net_dst->name, net_src->name) < 0) - return -1; + net_dst->name =3D g_strdup(net_src->name); memcpy(net_dst->uuid, net_src->uuid, VIR_UUID_BUFLEN); return 0; } @@ -7577,8 +7555,7 @@ make_nonnull_network(remote_nonnull_network *net_dst,= virNetworkPtr net_src) static int make_nonnull_network_port(remote_nonnull_network_port *port_dst, virNetwor= kPortPtr port_src) { - if (VIR_STRDUP(port_dst->net.name, port_src->net->name) < 0) - return -1; + port_dst->net.name =3D g_strdup(port_src->net->name); memcpy(port_dst->net.uuid, port_src->net->uuid, VIR_UUID_BUFLEN); memcpy(port_dst->uuid, port_src->uuid, VIR_UUID_BUFLEN); return 0; @@ -7588,20 +7565,15 @@ static int make_nonnull_interface(remote_nonnull_interface *interface_dst, virInterfacePtr interface_src) { - if (VIR_STRDUP(interface_dst->name, interface_src->name) < 0) - return -1; - if (VIR_STRDUP(interface_dst->mac, interface_src->mac) < 0) { - VIR_FREE(interface_dst->name); - return -1; - } + interface_dst->name =3D g_strdup(interface_src->name); + interface_dst->mac =3D g_strdup(interface_src->mac); return 0; } =20 static int make_nonnull_storage_pool(remote_nonnull_storage_pool *pool_dst, virStorag= ePoolPtr pool_src) { - if (VIR_STRDUP(pool_dst->name, pool_src->name) < 0) - return -1; + pool_dst->name =3D g_strdup(pool_src->name); memcpy(pool_dst->uuid, pool_src->uuid, VIR_UUID_BUFLEN); return 0; } @@ -7609,25 +7581,16 @@ make_nonnull_storage_pool(remote_nonnull_storage_po= ol *pool_dst, virStoragePoolP static int make_nonnull_storage_vol(remote_nonnull_storage_vol *vol_dst, virStorageVo= lPtr vol_src) { - if (VIR_STRDUP(vol_dst->pool, vol_src->pool) < 0) - return -1; - if (VIR_STRDUP(vol_dst->name, vol_src->name) < 0) { - VIR_FREE(vol_dst->pool); - return -1; - } - if (VIR_STRDUP(vol_dst->key, vol_src->key) < 0) { - VIR_FREE(vol_dst->pool); - VIR_FREE(vol_dst->name); - return -1; - } + vol_dst->pool =3D g_strdup(vol_src->pool); + vol_dst->name =3D g_strdup(vol_src->name); + vol_dst->key =3D g_strdup(vol_src->key); return 0; } =20 static int make_nonnull_node_device(remote_nonnull_node_device *dev_dst, virNodeDevic= ePtr dev_src) { - if (VIR_STRDUP(dev_dst->name, dev_src->name) < 0) - return -1; + dev_dst->name =3D g_strdup(dev_src->name); return 0; } =20 @@ -7636,16 +7599,14 @@ make_nonnull_secret(remote_nonnull_secret *secret_d= st, virSecretPtr secret_src) { memcpy(secret_dst->uuid, secret_src->uuid, VIR_UUID_BUFLEN); secret_dst->usageType =3D secret_src->usageType; - if (VIR_STRDUP(secret_dst->usageID, secret_src->usageID) < 0) - return -1; + secret_dst->usageID =3D g_strdup(secret_src->usageID); return 0; } =20 static int make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPt= r nwfilter_src) { - if (VIR_STRDUP(nwfilter_dst->name, nwfilter_src->name) < 0) - return -1; + nwfilter_dst->name =3D g_strdup(nwfilter_src->name); memcpy(nwfilter_dst->uuid, nwfilter_src->uuid, VIR_UUID_BUFLEN); return 0; } @@ -7653,20 +7614,15 @@ make_nonnull_nwfilter(remote_nonnull_nwfilter *nwfi= lter_dst, virNWFilterPtr nwfi static int make_nonnull_nwfilter_binding(remote_nonnull_nwfilter_binding *binding_dst= , virNWFilterBindingPtr binding_src) { - if (VIR_STRDUP(binding_dst->portdev, binding_src->portdev) < 0) - return -1; - if (VIR_STRDUP(binding_dst->filtername, binding_src->filtername) < 0) { - VIR_FREE(binding_dst->portdev); - return -1; - } + binding_dst->portdev =3D g_strdup(binding_src->portdev); + binding_dst->filtername =3D g_strdup(binding_src->filtername); return 0; } =20 static int make_nonnull_domain_checkpoint(remote_nonnull_domain_checkpoint *checkpoin= t_dst, virDomainCheckpointPtr checkpoint_src) { - if (VIR_STRDUP(checkpoint_dst->name, checkpoint_src->name) < 0) - return -1; + checkpoint_dst->name =3D g_strdup(checkpoint_src->name); if (make_nonnull_domain(&checkpoint_dst->dom, checkpoint_src->domain) = < 0) { VIR_FREE(checkpoint_dst->name); return -1; @@ -7677,8 +7633,7 @@ make_nonnull_domain_checkpoint(remote_nonnull_domain_= checkpoint *checkpoint_dst, static int make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapshot_dst,= virDomainSnapshotPtr snapshot_src) { - if (VIR_STRDUP(snapshot_dst->name, snapshot_src->name) < 0) - return -1; + snapshot_dst->name =3D g_strdup(snapshot_src->name); if (make_nonnull_domain(&snapshot_dst->dom, snapshot_src->domain) < 0)= { VIR_FREE(snapshot_dst->name); return -1; @@ -7699,8 +7654,7 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr= errors, goto error; =20 for (i =3D 0; i < nerrors; i++) { - if (VIR_STRDUP(val[i].disk, errors[i].disk) < 0) - goto error; + val[i].disk =3D g_strdup(errors[i].disk); val[i].error =3D errors[i].error; } =20 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index c22b257197..83477243fc 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -219,10 +219,7 @@ static int remoteSplitURIScheme(virURIPtr uri, return -1; =20 if (p) { - if (VIR_STRDUP(*transport, p + 1) < 0) { - VIR_FREE(*driver); - return -1; - } + *transport =3D g_strdup(p + 1); =20 p =3D *transport; while (*p) { @@ -744,8 +741,7 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr conn, #define EXTRACT_URI_ARG_STR(ARG_NAME, ARG_VAR) \ if (STRCASEEQ(var->name, ARG_NAME)) { \ VIR_FREE(ARG_VAR); \ - if (VIR_STRDUP(ARG_VAR, var->value) < 0) \ - goto failed; \ + ARG_VAR =3D g_strdup(var->value); \ var->ignore =3D 1; \ continue; \ } @@ -826,8 +822,7 @@ remoteGetUNIXSocket(remoteDriverTransport transport, virAsprintf(&direct_daemon, "virt%sd", driver) < 0) return NULL; =20 - if (VIR_STRDUP(legacy_daemon, "libvirtd") < 0) - return NULL; + legacy_daemon =3D g_strdup("libvirtd"); =20 if (driver && !(direct_sock_name =3D remoteGetUNIXSocketHelper(transport, direct= _daemon, flags))) @@ -1011,20 +1006,15 @@ doRemoteOpen(virConnectPtr conn, if (virAsprintf(&port, "%d", conn->uri->port) < 0) goto failed; } else if (transport =3D=3D REMOTE_DRIVER_TRANSPORT_TLS) { - if (VIR_STRDUP(port, LIBVIRTD_TLS_PORT) < 0) - goto failed; + port =3D g_strdup(LIBVIRTD_TLS_PORT); } else if (transport =3D=3D REMOTE_DRIVER_TRANSPORT_TCP) { - if (VIR_STRDUP(port, LIBVIRTD_TCP_PORT) < 0) - goto failed; + port =3D g_strdup(LIBVIRTD_TCP_PORT); } /* Port not used for unix, ext., default for ssh */ =20 - if (VIR_STRDUP(priv->hostname, - conn->uri && conn->uri->server ? - conn->uri->server : "localhost") < 0) - goto failed; + priv->hostname =3D g_strdup(conn->uri && conn->uri->server ? conn->uri= ->server : "localhost"); =20 - if (conn->uri && VIR_STRDUP(username, conn->uri->user) < 0) - goto failed; + if (conn->uri) + username =3D g_strdup(conn->uri->user); =20 /* Get the variables from the query string. * Then we need to reconstruct the query string (because @@ -1070,8 +1060,7 @@ doRemoteOpen(virConnectPtr conn, (STREQ(conn->uri->scheme, "remote") || STRPREFIX(conn->uri->scheme, "remote+"))) { /* Allow remote serve to probe */ - if (VIR_STRDUP(name, "") < 0) - goto failed; + name =3D g_strdup(""); } else { virURI tmpuri =3D { .scheme =3D (char *)driver_str, @@ -1090,8 +1079,7 @@ doRemoteOpen(virConnectPtr conn, } } else { /* Probe URI server side */ - if (VIR_STRDUP(name, "") < 0) - goto failed; + name =3D g_strdup(""); } =20 if (conf && !mode_str && @@ -1934,8 +1922,7 @@ remoteDeserializeDomainDiskErrors(remote_domain_disk_= error *ret_errors_val, } =20 for (i =3D 0; i < ret_errors_len; i++) { - if (VIR_STRDUP(errors[i].disk, ret_errors_val[i].disk) < 0) - goto error; + errors[i].disk =3D g_strdup(ret_errors_val[i].disk); errors[i].error =3D ret_errors_val[i].error; } =20 @@ -4924,16 +4911,14 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr = conn, if (VIR_ALLOC(localAddr) < 0) goto error; localAddr->family =3D msg->local.family; - if (VIR_STRDUP(localAddr->service, msg->local.service) < 0 || - VIR_STRDUP(localAddr->node, msg->local.node) < 0) - goto error; + localAddr->service =3D g_strdup(msg->local.service); + localAddr->node =3D g_strdup(msg->local.node); =20 if (VIR_ALLOC(remoteAddr) < 0) goto error; remoteAddr->family =3D msg->remote.family; - if (VIR_STRDUP(remoteAddr->service, msg->remote.service) < 0 || - VIR_STRDUP(remoteAddr->node, msg->remote.node) < 0) - goto error; + remoteAddr->service =3D g_strdup(msg->remote.service); + remoteAddr->node =3D g_strdup(msg->remote.node); =20 if (VIR_ALLOC(subject) < 0) goto error; @@ -4941,9 +4926,8 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr co= nn, goto error; subject->nidentity =3D msg->subject.subject_len; for (i =3D 0; i < subject->nidentity; i++) { - if (VIR_STRDUP(subject->identities[i].type, msg->subject.subject_v= al[i].type) < 0 || - VIR_STRDUP(subject->identities[i].name, msg->subject.subject_v= al[i].name) < 0) - goto error; + subject->identities[i].type =3D g_strdup(msg->subject.subject_val[= i].type); + subject->identities[i].name =3D g_strdup(msg->subject.subject_val[= i].name); } =20 event =3D virDomainEventGraphicsNewFromDom(dom, @@ -6158,12 +6142,10 @@ remoteDomainQemuMonitorCommand(virDomainPtr domain,= const char *cmd, (xdrproc_t) xdr_qemu_domain_monitor_command_ret, (char *) &re= t) =3D=3D -1) goto done; =20 - if (VIR_STRDUP(*result, ret.result) < 0) - goto cleanup; + *result =3D g_strdup(ret.result); =20 rv =3D 0; =20 - cleanup: xdr_free((xdrproc_t) xdr_qemu_domain_monitor_command_ret, (char *) &re= t); =20 done: @@ -7658,45 +7640,35 @@ remoteSerializeDHCPLease(virNetworkDHCPLeasePtr lea= se_dst, remote_network_dhcp_l lease_dst->type =3D lease_src->type; lease_dst->prefix =3D lease_src->prefix; =20 - if (VIR_STRDUP(lease_dst->iface, lease_src->iface) < 0) - goto error; + lease_dst->iface =3D g_strdup(lease_src->iface); =20 - if (VIR_STRDUP(lease_dst->ipaddr, lease_src->ipaddr) < 0) - goto error; + lease_dst->ipaddr =3D g_strdup(lease_src->ipaddr); =20 if (lease_src->mac) { - if (VIR_STRDUP(lease_dst->mac, *lease_src->mac) < 0) - goto error; + lease_dst->mac =3D g_strdup(*lease_src->mac); } else { lease_src->mac =3D NULL; } =20 if (lease_src->iaid) { - if (VIR_STRDUP(lease_dst->iaid, *lease_src->iaid) < 0) - goto error; + lease_dst->iaid =3D g_strdup(*lease_src->iaid); } else { lease_src->iaid =3D NULL; } =20 if (lease_src->hostname) { - if (VIR_STRDUP(lease_dst->hostname, *lease_src->hostname) < 0) - goto error; + lease_dst->hostname =3D g_strdup(*lease_src->hostname); } else { lease_src->hostname =3D NULL; } =20 if (lease_src->clientid) { - if (VIR_STRDUP(lease_dst->clientid, *lease_src->clientid) < 0) - goto error; + lease_dst->clientid =3D g_strdup(*lease_src->clientid); } else { lease_src->clientid =3D NULL; } =20 return 0; - - error: - virNetworkDHCPLeaseFree(lease_dst); - return -1; } =20 =20 @@ -7953,14 +7925,11 @@ remoteDomainGetFSInfo(virDomainPtr dom, if (VIR_ALLOC(info_ret[i]) < 0) goto cleanup; =20 - if (VIR_STRDUP(info_ret[i]->mountpoint, src->mountpoint) < 0) - goto cleanup; + info_ret[i]->mountpoint =3D g_strdup(src->mountpoint); =20 - if (VIR_STRDUP(info_ret[i]->name, src->name) < 0) - goto cleanup; + info_ret[i]->name =3D g_strdup(src->name); =20 - if (VIR_STRDUP(info_ret[i]->fstype, src->fstype) < 0) - goto cleanup; + info_ret[i]->fstype =3D g_strdup(src->fstype); =20 len =3D src->dev_aliases.dev_aliases_len; info_ret[i]->ndevAlias =3D len; @@ -7968,11 +7937,8 @@ remoteDomainGetFSInfo(virDomainPtr dom, VIR_ALLOC_N(info_ret[i]->devAlias, len) < 0) goto cleanup; =20 - for (j =3D 0; j < len; j++) { - if (VIR_STRDUP(info_ret[i]->devAlias[j], - src->dev_aliases.dev_aliases_val[j]) < 0) - goto cleanup; - } + for (j =3D 0; j < len; j++) + info_ret[i]->devAlias[j] =3D g_strdup(src->dev_aliases.dev= _aliases_val[j]); } =20 *info =3D info_ret; @@ -8047,12 +8013,10 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, =20 iface =3D ifaces_ret[i]; =20 - if (VIR_STRDUP(iface->name, iface_ret->name) < 0) - goto cleanup; + iface->name =3D g_strdup(iface_ret->name); =20 - if (iface_ret->hwaddr && - VIR_STRDUP(iface->hwaddr, *iface_ret->hwaddr) < 0) - goto cleanup; + if (iface_ret->hwaddr) + iface->hwaddr =3D g_strdup(*iface_ret->hwaddr); =20 if (iface_ret->addrs.addrs_len > REMOTE_DOMAIN_IP_ADDR_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -8072,8 +8036,7 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, remote_domain_ip_addr *ip_addr_ret =3D &(iface_ret->addrs.addrs_val[j]); =20 - if (VIR_STRDUP(ip_addr->addr, ip_addr_ret->addr) < 0) - goto cleanup; + ip_addr->addr =3D g_strdup(ip_addr_ret->addr); =20 ip_addr->prefix =3D ip_addr_ret->prefix; ip_addr->type =3D ip_addr_ret->type; @@ -8170,8 +8133,7 @@ remoteDomainRename(virDomainPtr dom, const char *new_= name, unsigned int flags) remote_domain_rename_ret ret; char *tmp =3D NULL; =20 - if (VIR_STRDUP(tmp, new_name) < 0) - return -1; + tmp =3D g_strdup(new_name); =20 remoteDriverLock(priv); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576237; cv=none; d=zoho.com; s=zohoarc; b=dju24YQvizHCE7nQUyIshk1xQa5pLA1mw2k9I9aHGzr8tOdm2nQL8N0Oh/yEFVNLQEXAK81HMEX/HoY3H7e5KHo3Dfj2/rZzDuqOt9uHpwmqlfEH29wcVlqkdSkfHqqoXdn3vhlclws/Mi/ruS88Ts8qtFRfjn7a3+Pg31RBhfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576237; 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=4BdE/w3S/uZB3R4jXvw52woYZRFyT+WsRa6zCXR8DFs=; b=fc9MNRzFju/dMYp3NMnmRvshCoqn3cv9/hoLw0tzB6t/goYNpMaurR6OluYnk2osPywSJcYla8/PR0cOVV75j4FARacYAA6AhRje7H6/6DIWiLqNYouNAH0C2kR14EcSQYn7iAilb+gX03na7hhZwWw/+9KZmMJ1kPcfzhxKj8U= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576237938940.2844301731656; Sun, 20 Oct 2019 05:57: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-282-aLyMpjldOTOPfoyvGwjf5Q-1; Sun, 20 Oct 2019 08:56:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89D82107AFB2; Sun, 20 Oct 2019 12:56:25 +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 658869446; Sun, 20 Oct 2019 12:56:25 +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 2A1AD1806B11; Sun, 20 Oct 2019 12:56:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCu2Lc023552 for ; Sun, 20 Oct 2019 08:56:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6473C3CC8; Sun, 20 Oct 2019 12:56:02 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE4A49446 for ; Sun, 20 Oct 2019 12:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576236; 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=4BdE/w3S/uZB3R4jXvw52woYZRFyT+WsRa6zCXR8DFs=; b=QKaepw63Vga0VfBwy1nR7OOLzb3uZCi5NKyYqnN3sED+YK4Q1La0xzTGLgnwgdB8pEEAS+ h5MxXzbGx36WT7HgSpw/kx9AY9iCg89rXwSfN1ZKTB13ugm5J/cEVYFjrMM8nNHVAmfnZP NwbGC4GCIZd/dZfkk8+/Z0J3qWIsQJ8= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:42 +0200 Message-Id: <06a4ec218e90c9ee0a378c4060b59f5b2eea2e7d.1571575890.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 24/34] rpc: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: aLyMpjldOTOPfoyvGwjf5Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/rpc/gendispatch.pl | 20 ++++++-------------- src/rpc/virnetclient.c | 15 +++++---------- src/rpc/virnetlibsshsession.c | 19 ++++++------------- src/rpc/virnetmessage.c | 26 ++++++++++---------------- src/rpc/virnetserver.c | 3 +-- src/rpc/virnetserverclient.c | 3 +-- src/rpc/virnetsocket.c | 9 +++------ src/rpc/virnetsshsession.c | 30 ++++++++++-------------------- src/rpc/virnettlscontext.c | 21 +++++++-------------- 9 files changed, 49 insertions(+), 97 deletions(-) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 6d9838c398..fab4513fd1 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -773,10 +773,9 @@ elsif ($mode eq "server") { # SPECIAL: virConnectGetType returns a constant st= ring that must # not be freed. Therefore, duplicate the = string here. push(@vars_list, "const char *$1"); - push(@ret_list, "/* We have to VIR_STRDUP because = remoteDispatchClientRequest will"); + push(@ret_list, "/* We have to g_strdup because re= moteDispatchClientRequest will"); push(@ret_list, " * free this string after it's be= en serialised. */"); - push(@ret_list, "if (VIR_STRDUP(ret->type, type) <= 0)"); - push(@ret_list, " goto cleanup;"); + push(@ret_list, "ret->type =3D g_strdup(type);"); } else { push(@vars_list, "char *$1"); push(@ret_list, "ret->$1 =3D $1;"); @@ -795,8 +794,7 @@ elsif ($mode eq "server") { "if (VIR_ALLOC($1_p) < 0)\n" . " goto cleanup;\n" . "\n" . - " if (VIR_STRDUP(*$1_p, $1) < 0)\n". - " goto cleanup;\n"); + " *$1_p =3D g_strdup($1);\n"); =20 $single_ret_var =3D $1; $single_ret_by_ref =3D 0; @@ -1936,17 +1934,11 @@ elsif ($mode eq "client") { if ($single_ret_as_list) { print " /* This call is caller-frees (although that isn't c= lear from\n"; print " * the documentation). However xdr_free will free = up both the\n"; - print " * names and the list of pointers, so we have to VI= R_STRDUP the\n"; + print " * names and the list of pointers, so we have to g_= strdup the\n"; print " * names here. */\n"; print " for (i =3D 0; i < ret.$single_ret_list_name.${singl= e_ret_list_name}_len; ++i) {\n"; - print " if (VIR_STRDUP(${single_ret_list_name}[i],\n"; - print " ret.$single_ret_list_name.${sing= le_ret_list_name}_val[i]) < 0) {\n"; - print " size_t j;\n"; - print " for (j =3D 0; j < i; j++)\n"; - print " VIR_FREE(${single_ret_list_name}[j]);\n= "; - print "\n"; - print " goto cleanup;\n"; - print " }\n"; + print " ${single_ret_list_name}[i] =3D \n"; + print " g_strdup(ret.$single_ret_list_name.${single= _ret_list_name}_val[i]);\n"; print " }\n"; print "\n"; } elsif ($modern_ret_as_list) { diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 1d846cd131..678e6f7815 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -316,8 +316,7 @@ static virNetClientPtr virNetClientNew(virNetSocketPtr = sock, client->wakeupSendFD =3D wakeupFD[1]; wakeupFD[0] =3D wakeupFD[1] =3D -1; =20 - if (VIR_STRDUP(client->hostname, hostname) < 0) - goto error; + client->hostname =3D g_strdup(hostname); =20 PROBE(RPC_CLIENT_NEW, "client=3D%p sock=3D%p", @@ -454,8 +453,7 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host, =20 /* Use default paths for known hosts an public keys if not provided */ if (knownHostsPath) { - if (VIR_STRDUP(knownhosts, knownHostsPath) < 0) - goto cleanup; + knownhosts =3D g_strdup(knownHostsPath); } else { confdir =3D virGetUserConfigDirectory(); if (confdir) { @@ -466,8 +464,7 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host, } =20 if (privkeyPath) { - if (VIR_STRDUP(privkey, privkeyPath) < 0) - goto cleanup; + privkey =3D g_strdup(privkeyPath); } else { homedir =3D virGetUserDirectory(); if (homedir) { @@ -565,8 +562,7 @@ virNetClientPtr virNetClientNewLibssh(const char *host, =20 /* Use default paths for known hosts an public keys if not provided */ if (knownHostsPath) { - if (VIR_STRDUP(knownhosts, knownHostsPath) < 0) - goto cleanup; + knownhosts =3D g_strdup(knownHostsPath); } else { confdir =3D virGetUserConfigDirectory(); if (confdir) { @@ -576,8 +572,7 @@ virNetClientPtr virNetClientNewLibssh(const char *host, } =20 if (privkeyPath) { - if (VIR_STRDUP(privkey, privkeyPath) < 0) - goto cleanup; + privkey =3D g_strdup(privkeyPath); } else { homedir =3D virGetUserDirectory(); if (homedir) { diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index cd92329230..0b98236f38 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -1052,11 +1052,8 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSe= ssionPtr sess, =20 virObjectLock(sess); =20 - if (VIR_STRDUP(file, keyfile) < 0 || - VIR_STRDUP(pass, password) < 0) { - ret =3D -1; - goto error; - } + file =3D g_strdup(keyfile); + pass =3D g_strdup(password); =20 if (!(auth =3D virNetLibsshSessionAuthMethodNew(sess))) { ret =3D -1; @@ -1114,8 +1111,7 @@ virNetLibsshSessionSetChannelCommand(virNetLibsshSess= ionPtr sess, =20 VIR_FREE(sess->channelCommand); =20 - if (VIR_STRDUP(sess->channelCommand, command) < 0) - ret =3D -1; + sess->channelCommand =3D g_strdup(command); =20 virObjectUnlock(sess); return ret; @@ -1135,8 +1131,7 @@ virNetLibsshSessionSetHostKeyVerification(virNetLibss= hSessionPtr sess, =20 VIR_FREE(sess->hostname); =20 - if (VIR_STRDUP(sess->hostname, hostname) < 0) - goto error; + sess->hostname =3D g_strdup(hostname); =20 /* set the hostname */ if (ssh_options_set(sess->session, SSH_OPTIONS_HOST, sess->hostname) <= 0) @@ -1156,8 +1151,7 @@ virNetLibsshSessionSetHostKeyVerification(virNetLibss= hSessionPtr sess, goto error; =20 VIR_FREE(sess->knownHostsFile); - if (VIR_STRDUP(sess->knownHostsFile, hostsfile) < 0) - goto error; + sess->knownHostsFile =3D g_strdup(hostsfile); } else { /* libssh does not support trying no known_host file at all: * hence use /dev/null here, without storing it as file */ @@ -1191,8 +1185,7 @@ virNetLibsshSessionPtr virNetLibsshSessionNew(const c= har *username) goto error; } =20 - if (VIR_STRDUP(sess->username, username) < 0) - goto error; + sess->username =3D g_strdup(username); =20 VIR_DEBUG("virNetLibsshSessionPtr: %p, ssh_session: %p", sess, sess->session); diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c index bb6ef9a9ae..9d2a8a6d7d 100644 --- a/src/rpc/virnetmessage.c +++ b/src/rpc/virnetmessage.c @@ -523,28 +523,22 @@ void virNetMessageSaveError(virNetMessageErrorPtr rer= r) if (verr) { rerr->code =3D verr->code; rerr->domain =3D verr->domain; - if (verr->message && VIR_ALLOC(rerr->message) =3D=3D 0 && - VIR_STRDUP_QUIET(*rerr->message, verr->message) < 0) - VIR_FREE(rerr->message); + if (verr->message && VIR_ALLOC(rerr->message) =3D=3D 0) + *rerr->message =3D g_strdup(verr->message); rerr->level =3D verr->level; - if (verr->str1 && VIR_ALLOC(rerr->str1) =3D=3D 0 && - VIR_STRDUP_QUIET(*rerr->str1, verr->str1) < 0) - VIR_FREE(rerr->str1); - if (verr->str2 && VIR_ALLOC(rerr->str2) =3D=3D 0 && - VIR_STRDUP_QUIET(*rerr->str2, verr->str2) < 0) - VIR_FREE(rerr->str2); - if (verr->str3 && VIR_ALLOC(rerr->str3) =3D=3D 0 && - VIR_STRDUP_QUIET(*rerr->str3, verr->str3) < 0) - VIR_FREE(rerr->str3); + if (verr->str1 && VIR_ALLOC(rerr->str1) =3D=3D 0) + *rerr->str1 =3D g_strdup(verr->str1); + if (verr->str2 && VIR_ALLOC(rerr->str2) =3D=3D 0) + *rerr->str2 =3D g_strdup(verr->str2); + if (verr->str3 && VIR_ALLOC(rerr->str3) =3D=3D 0) + *rerr->str3 =3D g_strdup(verr->str3); rerr->int1 =3D verr->int1; rerr->int2 =3D verr->int2; } else { rerr->code =3D VIR_ERR_INTERNAL_ERROR; rerr->domain =3D VIR_FROM_RPC; - if (VIR_ALLOC_QUIET(rerr->message) =3D=3D 0 && - VIR_STRDUP_QUIET(*rerr->message, - _("Library function returned error but did no= t set virError")) < 0) - VIR_FREE(rerr->message); + if (VIR_ALLOC_QUIET(rerr->message) =3D=3D 0) + *rerr->message =3D g_strdup(_("Library function returned error= but did not set virError")); rerr->level =3D VIR_ERR_ERROR; } } diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index e229f57bab..042661ffa5 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -365,8 +365,7 @@ virNetServerPtr virNetServerNew(const char *name, srv))) goto error; =20 - if (VIR_STRDUP(srv->name, name) < 0) - goto error; + srv->name =3D g_strdup(name); =20 srv->next_client_id =3D next_client_id; srv->nclients_max =3D max_clients; diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 8482c5c29c..67b3bf9531 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -1665,8 +1665,7 @@ virNetServerClientGetInfo(virNetServerClientPtr clien= t, goto cleanup; } =20 - if (VIR_STRDUP(*sock_addr, addr) < 0) - goto cleanup; + *sock_addr =3D g_strdup(addr); =20 if (!client->identity) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 15791ceb35..6574ee0d16 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -999,8 +999,7 @@ virNetSocketNewConnectLibSSH2(const char *host, if (virNetSSHSessionSetChannelCommand(sess, command) !=3D 0) goto error; =20 - if (VIR_STRDUP(authMethodsCopy, authMethods) < 0) - goto error; + authMethodsCopy =3D g_strdup(authMethods); =20 authMethodNext =3D authMethodsCopy; =20 @@ -1134,8 +1133,7 @@ virNetSocketNewConnectLibssh(const char *host, if (virNetLibsshSessionSetChannelCommand(sess, command) !=3D 0) goto error; =20 - if (VIR_STRDUP(authMethodsCopy, authMethods) < 0) - goto error; + authMethodsCopy =3D g_strdup(authMethods); =20 authMethodNext =3D authMethodsCopy; =20 @@ -1635,8 +1633,7 @@ int virNetSocketGetSELinuxContext(virNetSocketPtr soc= k, goto cleanup; } =20 - if (VIR_STRDUP(*context, seccon) < 0) - goto cleanup; + *context =3D g_strdup(seccon); =20 ret =3D 0; cleanup: diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index de39ba31dc..931c7091cc 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -232,10 +232,7 @@ virNetSSHKbIntCb(const char *name G_GNUC_UNUSED, /* fill data structures for auth callback */ for (i =3D 0; i < num_prompts; i++) { char *prompt; - if (VIR_STRDUP(prompt, prompts[i].text) < 0) { - priv->authCbErr =3D VIR_NET_SSH_AUTHCB_OOM; - goto cleanup; - } + prompt =3D g_strdup(prompts[i].text); askcred[i].prompt =3D prompt; =20 /* remove colon and trailing spaces from prompts, as default behav= ior @@ -1018,8 +1015,7 @@ virNetSSHSessionAuthAddPasswordAuth(virNetSSHSessionP= tr sess, "ssh", NULL, sess->hostname))) goto error; } else { - if (VIR_STRDUP(user, username) < 0) - goto error; + user =3D g_strdup(username); } =20 virObjectLock(sess); @@ -1055,8 +1051,7 @@ virNetSSHSessionAuthAddAgentAuth(virNetSSHSessionPtr = sess, =20 virObjectLock(sess); =20 - if (VIR_STRDUP(user, username) < 0) - goto error; + user =3D g_strdup(username); =20 if (!(auth =3D virNetSSHSessionAuthMethodNew(sess))) goto error; @@ -1094,10 +1089,9 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSessionP= tr sess, =20 virObjectLock(sess); =20 - if (VIR_STRDUP(user, username) < 0 || - VIR_STRDUP(file, keyfile) < 0 || - VIR_STRDUP(pass, password) < 0) - goto error; + user =3D g_strdup(username); + file =3D g_strdup(keyfile); + pass =3D g_strdup(password); =20 if (!(auth =3D virNetSSHSessionAuthMethodNew(sess))) goto error; @@ -1135,8 +1129,7 @@ virNetSSHSessionAuthAddKeyboardAuth(virNetSSHSessionP= tr sess, =20 virObjectLock(sess); =20 - if (VIR_STRDUP(user, username) < 0) - goto error; + user =3D g_strdup(username); =20 if (!(auth =3D virNetSSHSessionAuthMethodNew(sess))) goto error; @@ -1164,8 +1157,7 @@ virNetSSHSessionSetChannelCommand(virNetSSHSessionPtr= sess, =20 VIR_FREE(sess->channelCommand); =20 - if (VIR_STRDUP(sess->channelCommand, command) < 0) - ret =3D -1; + sess->channelCommand =3D g_strdup(command); =20 virObjectUnlock(sess); return ret; @@ -1188,8 +1180,7 @@ virNetSSHSessionSetHostKeyVerification(virNetSSHSessi= onPtr sess, =20 VIR_FREE(sess->hostname); =20 - if (VIR_STRDUP(sess->hostname, hostname) < 0) - goto error; + sess->hostname =3D g_strdup(hostname); =20 /* load the known hosts file */ if (hostsfile) { @@ -1213,8 +1204,7 @@ virNetSSHSessionSetHostKeyVerification(virNetSSHSessi= onPtr sess, /* set filename only if writing to the known hosts file is request= ed */ if (!(flags & VIR_NET_SSH_HOSTKEY_FILE_READONLY)) { VIR_FREE(sess->knownHostsFile); - if (VIR_STRDUP(sess->knownHostsFile, hostsfile) < 0) - goto error; + sess->knownHostsFile =3D g_strdup(hostsfile); } } =20 diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index e4fbe6e59a..2420ad8681 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -702,8 +702,7 @@ static virNetTLSContextPtr virNetTLSContextNew(const ch= ar *cacert, if (!(ctxt =3D virObjectLockableNew(virNetTLSContextClass))) return NULL; =20 - if (VIR_STRDUP(ctxt->priority, priority) < 0) - goto error; + ctxt->priority =3D g_strdup(priority); =20 err =3D gnutls_certificate_allocate_credentials(&ctxt->x509cred); if (err) { @@ -863,23 +862,19 @@ static int virNetTLSContextLocateCredentials(const ch= ar *pkipath, */ if (!*cacert) { VIR_DEBUG("Using default TLS CA certificate path"); - if (VIR_STRDUP(*cacert, LIBVIRT_CACERT) < 0) - goto error; + *cacert =3D g_strdup(LIBVIRT_CACERT); } =20 if (!*cacrl) { VIR_DEBUG("Using default TLS CA revocation list path"); - if (VIR_STRDUP(*cacrl, LIBVIRT_CACRL) < 0) - goto error; + *cacrl =3D g_strdup(LIBVIRT_CACRL); } =20 if (!*key && !*cert) { VIR_DEBUG("Using default TLS key/certificate path"); - if (VIR_STRDUP(*key, isServer ? LIBVIRT_SERVERKEY : LIBVIRT_CLIENT= KEY) < 0) - goto error; + *key =3D g_strdup(isServer ? LIBVIRT_SERVERKEY : LIBVIRT_CLIENTKEY= ); =20 - if (VIR_STRDUP(*cert, isServer ? LIBVIRT_SERVERCERT : LIBVIRT_CLIE= NTCERT) < 0) - goto error; + *cert =3D g_strdup(isServer ? LIBVIRT_SERVERCERT : LIBVIRT_CLIENTC= ERT); } =20 VIR_FREE(user_pki_path); @@ -1058,8 +1053,7 @@ static int virNetTLSContextValidCertificate(virNetTLS= ContextPtr ctxt, "[session]", gnutls_strerror(ret)); goto authfail; } - if (VIR_STRDUP(sess->x509dname, dname) < 0) - goto authfail; + sess->x509dname =3D g_strdup(dname); VIR_DEBUG("Peer DN is %s", dname); =20 if (virNetTLSContextCheckCertDN(cert, "[session]", sess->hostn= ame, dname, @@ -1195,8 +1189,7 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSCont= extPtr ctxt, if (!(sess =3D virObjectLockableNew(virNetTLSSessionClass))) return NULL; =20 - if (VIR_STRDUP(sess->hostname, hostname) < 0) - goto error; + sess->hostname =3D g_strdup(hostname); =20 if ((err =3D gnutls_init(&sess->session, ctxt->isServer ? GNUTLS_SERVER : GNUTLS_CLIENT)= ) !=3D 0) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576229; cv=none; d=zoho.com; s=zohoarc; b=ED6zXZWsRLbTtHs15OKLmK3o62733FRSmBjt9MlUxi5WdmvoeUgwAY/Zl6s1GncZ3zAvPWnA3SZSSaaWhVmrVqyH/GSE92SsmrhBDuFIgqnojhYNMG5WBvcEOAL3GJ1LMnSgGkQVrvE6cXCOuIypj410ly71uU9cg5PE26XQRPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576229; 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=wNEutdq3twecgfxLlsb0UWSgvEHpnZeR91TzKZwPoxQ=; b=YrLqARTvDVczXIFC+O2RIqI3YjYxq5NkXhAZ5qLvhJUxqlbWCCgsQwQ1oWDZwKb1YtVx66u46SSp42ESOEI3QewPho0Sbtqp0+Bsy6wEtmb0rLnTM2sVg4FXNEAD/kbMOF251AG/Y4Io6hZhjFPamXfhWzl+rJ4zYgaUYUOd/2A= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 15715762292529.050854817202776; Sun, 20 Oct 2019 05:57:09 -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-226-ENoC311MM9mzukZnu39Z8w-1; Sun, 20 Oct 2019 08:56:35 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D4985FB; Sun, 20 Oct 2019 12:56:26 +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 E90AC600CE; Sun, 20 Oct 2019 12:56:25 +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 8454D4EEBA; Sun, 20 Oct 2019 12:56:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCu3JY023559 for ; Sun, 20 Oct 2019 08:56:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D5D33CC8; Sun, 20 Oct 2019 12:56:03 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF141194B9 for ; Sun, 20 Oct 2019 12:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576228; 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=wNEutdq3twecgfxLlsb0UWSgvEHpnZeR91TzKZwPoxQ=; b=a9WKkNrFdwIe58x5s+DEhAiA25Ucfm9RyF7hO2pdBXhXSdgAOMjQyrGepbVFDfnZoYGNHL FlzY4WA6L+ZtgLSx0HbQHZE/uJ/FiIoVhnDUoQEGe0neg1ckU4UugDONT68J2xKCozDDbC FmLio59PYD4ixziOPbOFCryHWbREJ5E= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:43 +0200 Message-Id: <2a5d1c450aee2ba6eecac23b97b4fd670e7b59f6.1571575890.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 25/34] security: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: ENoC311MM9mzukZnu39Z8w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/security/security_apparmor.c | 6 ++---- src/security/security_dac.c | 10 +++------ src/security/security_selinux.c | 37 +++++++++++--------------------- src/security/virt-aa-helper.c | 15 +++++-------- 4 files changed, 23 insertions(+), 45 deletions(-) diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index 82826d193c..9ad218b383 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -452,12 +452,10 @@ AppArmorGenSecurityLabel(virSecurityManagerPtr mgr G_= GNUC_UNUSED, if ((profile_name =3D get_profile_name(def)) =3D=3D NULL) return rc; =20 - if (VIR_STRDUP(secdef->label, profile_name) < 0) - goto cleanup; + secdef->label =3D g_strdup(profile_name); =20 /* set imagelabel the same as label (but we won't use it) */ - if (VIR_STRDUP(secdef->imagelabel, profile_name) < 0) - goto err; + secdef->imagelabel =3D g_strdup(profile_name); =20 if (!secdef->model) secdef->model =3D g_strdup(SECURITY_APPARMOR_NAME); diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 5d975f5903..4f646bc3b7 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -111,8 +111,7 @@ virSecurityDACChownListAppend(virSecurityDACChownListPt= r list, if (VIR_ALLOC(item) < 0) return -1; =20 - if (VIR_STRDUP(tmp, path) < 0) - goto cleanup; + tmp =3D g_strdup(path); =20 item->path =3D tmp; item->src =3D src; @@ -2311,11 +2310,8 @@ virSecurityDACGenLabel(virSecurityManagerPtr mgr, return rc; } =20 - if (seclabel->relabel && !seclabel->imagelabel && - VIR_STRDUP(seclabel->imagelabel, seclabel->label) < 0) { - VIR_FREE(seclabel->label); - return rc; - } + if (seclabel->relabel && !seclabel->imagelabel) + seclabel->imagelabel =3D g_strdup(seclabel->label); =20 return 0; } diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index c24a63afd6..d80ec01c5d 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -130,8 +130,8 @@ virSecuritySELinuxContextListAppend(virSecuritySELinuxC= ontextListPtr list, if (VIR_ALLOC(item) < 0) return -1; =20 - if (VIR_STRDUP(item->path, path) < 0 || VIR_STRDUP(item->tcon, tcon) <= 0) - goto cleanup; + item->path =3D g_strdup(path); + item->tcon =3D g_strdup(tcon); =20 item->remember =3D remember; item->restore =3D restore; @@ -444,8 +444,7 @@ virSecuritySELinuxMCSGetProcessRange(char **sens, if (!(contextRange =3D context_range_get(ourContext))) contextRange =3D "s0"; =20 - if (VIR_STRDUP(*sens, contextRange) < 0) - goto cleanup; + *sens =3D g_strdup(contextRange); =20 /* Find and blank out the category part (if any) */ tmp =3D strchr(*sens, ':'); @@ -622,8 +621,7 @@ virSecuritySELinuxGenNewContext(const char *basecontext, _("Unable to format SELinux context")); goto cleanup; } - if (VIR_STRDUP(ret, str) < 0) - goto cleanup; + ret =3D g_strdup(str); VIR_DEBUG("Generated context '%s'", ret); cleanup: freecon(ourSecContext); @@ -740,8 +738,7 @@ virSecuritySELinuxQEMUInitialize(virSecurityManagerPtr = mgr) *ptr =3D '\0'; ptr++; if (*ptr !=3D '\0') { - if (VIR_STRDUP(data->alt_domain_context, ptr) < 0) - goto error; + data->alt_domain_context =3D g_strdup(ptr); ptr =3D strchrnul(data->alt_domain_context, '\n'); if (ptr && *ptr =3D=3D '\n') *ptr =3D '\0'; @@ -761,8 +758,7 @@ virSecuritySELinuxQEMUInitialize(virSecurityManagerPtr = mgr) ptr =3D strchrnul(data->file_context, '\n'); if (ptr && *ptr =3D=3D '\n') { *ptr =3D '\0'; - if (VIR_STRDUP(data->content_context, ptr + 1) < 0) - goto error; + data->content_context =3D g_strdup(ptr + 1); ptr =3D strchrnul(data->content_context, '\n'); if (ptr && *ptr =3D=3D '\n') *ptr =3D '\0'; @@ -868,8 +864,7 @@ virSecuritySELinuxGenLabel(virSecurityManagerPtr mgr, virReportSystemError(errno, "%s", _("unable to get selinux con= text range")); goto cleanup; } - if (VIR_STRDUP(mcs, range) < 0) - goto cleanup; + mcs =3D g_strdup(range); break; =20 case VIR_DOMAIN_SECLABEL_DYNAMIC: @@ -919,8 +914,7 @@ virSecuritySELinuxGenLabel(virSecurityManagerPtr mgr, &catMax) < 0) goto cleanup; =20 - if (VIR_STRDUP(mcs, sens) < 0) - goto cleanup; + mcs =3D g_strdup(sens); =20 break; =20 @@ -2214,8 +2208,7 @@ virSecuritySELinuxSetHostdevCapsLabel(virSecurityMana= gerPtr mgr, dev->source.caps.u.storage.block) < 0) return -1; } else { - if (VIR_STRDUP(path, dev->source.caps.u.storage.block) < 0) - return -1; + path =3D g_strdup(dev->source.caps.u.storage.block); } ret =3D virSecuritySELinuxSetFilecon(mgr, path, secdef->imagelabel= , true); VIR_FREE(path); @@ -2228,8 +2221,7 @@ virSecuritySELinuxSetHostdevCapsLabel(virSecurityMana= gerPtr mgr, dev->source.caps.u.misc.chardev) < 0) return -1; } else { - if (VIR_STRDUP(path, dev->source.caps.u.misc.chardev) < 0) - return -1; + path =3D g_strdup(dev->source.caps.u.misc.chardev); } ret =3D virSecuritySELinuxSetFilecon(mgr, path, secdef->imagelabel= , true); VIR_FREE(path); @@ -2449,8 +2441,7 @@ virSecuritySELinuxRestoreHostdevCapsLabel(virSecurity= ManagerPtr mgr, dev->source.caps.u.storage.block) < 0) return -1; } else { - if (VIR_STRDUP(path, dev->source.caps.u.storage.block) < 0) - return -1; + path =3D g_strdup(dev->source.caps.u.storage.block); } ret =3D virSecuritySELinuxRestoreFileLabel(mgr, path, true); VIR_FREE(path); @@ -2463,8 +2454,7 @@ virSecuritySELinuxRestoreHostdevCapsLabel(virSecurity= ManagerPtr mgr, dev->source.caps.u.misc.chardev) < 0) return -1; } else { - if (VIR_STRDUP(path, dev->source.caps.u.misc.chardev) < 0) - return -1; + path =3D g_strdup(dev->source.caps.u.misc.chardev); } ret =3D virSecuritySELinuxRestoreFileLabel(mgr, path, true); VIR_FREE(path); @@ -3335,8 +3325,7 @@ virSecuritySELinuxGenImageLabel(virSecurityManagerPtr= mgr, } range =3D context_range_get(ctx); if (range) { - if (VIR_STRDUP(mcs, range) < 0) - goto cleanup; + mcs =3D g_strdup(range); if (!(label =3D virSecuritySELinuxGenNewContext(data->file_con= text, mcs, true))) goto cleanup; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 9157411133..7d7262ca39 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -772,8 +772,7 @@ vah_add_path(virBufferPtr buf, const char *path, const = char *perms, bool recursi * 3. re-combine the realpath with the remaining suffix * Note: A totally non existent path is used as-is */ - if (VIR_STRDUP_QUIET(pathdir, path) < 0) - goto cleanup; + pathdir =3D g_strdup(path); while (!virFileExists(pathdir)) { if ((pathtmp =3D mdir_name(pathdir)) =3D=3D NULL) goto cleanup; @@ -783,11 +782,9 @@ vah_add_path(virBufferPtr buf, const char *path, const= char *perms, bool recursi =20 if (strlen(pathdir) =3D=3D 1) { /* nothing of the path does exist yet */ - if (VIR_STRDUP_QUIET(tmp, path) < 0) - goto cleanup; + tmp =3D g_strdup(path); } else { - if (VIR_STRDUP_QUIET(pathtmp, path+strlen(pathdir)) < 0) - goto cleanup; + pathtmp =3D g_strdup(path + strlen(pathdir)); if ((pathreal =3D realpath(pathdir, NULL)) =3D=3D NULL) { vah_error(NULL, 0, pathdir); vah_error(NULL, 0, _("could not find realpath")); @@ -797,8 +794,7 @@ vah_add_path(virBufferPtr buf, const char *path, const = char *perms, bool recursi goto cleanup; } =20 - if (VIR_STRDUP_QUIET(perms_new, perms) < 0) - goto cleanup; + perms_new =3D g_strdup(perms); =20 if (strchr(perms_new, 'w') !=3D NULL) { readonly =3D false; @@ -1367,8 +1363,7 @@ vahParseArgv(vahControl * ctl, int argc, char **argv) break; case 'f': case 'F': - if (VIR_STRDUP_QUIET(ctl->newfile, optarg) < 0) - vah_error(ctl, 1, _("could not allocate memory for dis= k")); + ctl->newfile =3D g_strdup(optarg); ctl->append =3D arg =3D=3D 'F'; break; case 'h': --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576295; cv=none; d=zoho.com; s=zohoarc; b=ZoA0JhhbZ8ByPyOdQ/QSOWbMfrN+7nb82FyIywynXt0I/s5nlEpmexkhDwrrmH6GECWa9MFDhebacouPpVVctGwgHSO3yejrXXqyal/qLxqLRWVs6o+33IB6rDb55Ct8WGBNev9dKqcy9dSzDUdFMEaQgd6/myZkukepG+NXG7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576295; 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=CLms3YXn0rOfZ2yL3H8gJ5RysvaCg8ZrPff9QzslBdc=; b=n/l0DkIB9vPx2U8dxB8tFIpxtAKHa4kh1eKPXIT52/Uuwdo63E0MD0O1QDN0bC+zQKfKmnrIvGK6KkcNzpHASwBAzkdQ8HHUGFmJekXprDPmpCk9RUUXa6trvPyh29slq6bWGiNxCvFculJoqWCs1BDFIcdF5qglbn+Bsm+LteQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576294998689.9231989477624; Sun, 20 Oct 2019 05:58:14 -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-346-dujeko8rNcuEDw3Y0cSbLQ-1; Sun, 20 Oct 2019 08:56:35 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D36C1800E18; Sun, 20 Oct 2019 12:56:29 +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 340A46060D; Sun, 20 Oct 2019 12:56:29 +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 C31FC1804760; Sun, 20 Oct 2019 12:56:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCu73c023586 for ; Sun, 20 Oct 2019 08:56:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7BCCD3CC8; Sun, 20 Oct 2019 12:56:07 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id D77D69446 for ; Sun, 20 Oct 2019 12:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576293; 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=CLms3YXn0rOfZ2yL3H8gJ5RysvaCg8ZrPff9QzslBdc=; b=KLHq9iFU/8rca95gzw+1PRnJyr8kfJDLJdUXRTkd2aLglXg1w/OEtEI4lEizxXbEAopte8 AJsXY3gB6zgWcf/Ykb8ywDf/NBaiBS23e7eYmw/chZgfnCYSnMhIfdHPaIDrCNQLBpVFy+ Xyy2lcxpX5n61SjoVd4OcX4KRi94/r0= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 26/34] storage: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: dujeko8rNcuEDw3Y0cSbLQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/storage/parthelper.c | 3 +- src/storage/storage_backend_disk.c | 19 ++++--------- src/storage/storage_backend_fs.c | 5 ++-- src/storage/storage_backend_gluster.c | 15 ++++------ src/storage/storage_backend_iscsi_direct.c | 3 +- src/storage/storage_backend_logical.c | 8 ++---- src/storage/storage_backend_mpath.c | 3 +- src/storage/storage_backend_rbd.c | 3 +- src/storage/storage_backend_sheepdog.c | 7 +++-- src/storage/storage_backend_zfs.c | 6 ++-- src/storage/storage_driver.c | 19 +++++-------- src/storage/storage_util.c | 32 +++++++--------------- 12 files changed, 43 insertions(+), 80 deletions(-) diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c index 4a404ddfa6..f1a8cc01ea 100644 --- a/src/storage/parthelper.c +++ b/src/storage/parthelper.c @@ -91,8 +91,7 @@ int main(int argc, char **argv) partsep =3D "p"; else partsep =3D ""; - if (VIR_STRDUP_QUIET(canonical_path, path) < 0) - return 2; + canonical_path =3D g_strdup(path); } else { if (virFileResolveLink(path, &canonical_path) !=3D 0) return 2; diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index 49590019c5..f37bcd2b15 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -75,13 +75,11 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr p= ool, addVol =3D true; if (VIR_ALLOC(vol) < 0) return -1; - if (VIR_STRDUP(vol->name, partname) < 0) - goto error; + vol->name =3D g_strdup(partname); } =20 if (vol->target.path =3D=3D NULL) { - if (VIR_STRDUP(devpath, groups[0]) < 0) - goto error; + devpath =3D g_strdup(groups[0]); =20 /* Now figure out the stable path * @@ -129,8 +127,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr p= ool, =20 if (vol->key =3D=3D NULL) { /* XXX base off a unique key of the underlying disk */ - if (VIR_STRDUP(vol->key, vol->target.path) < 0) - goto error; + vol->key =3D g_strdup(vol->target.path); } =20 if (vol->source.extents =3D=3D NULL) { @@ -152,9 +149,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr p= ool, goto error; } =20 - if (VIR_STRDUP(vol->source.extents[0].path, - def->source.devices[0].path) < 0) - goto error; + vol->source.extents[0].path =3D g_strdup(def->source.devices[0].pa= th); } =20 /* set partition type */ @@ -602,8 +597,7 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr po= ol, _("extended partition already exists")); return -1; } - if (VIR_STRDUP(*partFormat, partedFormat) < 0) - return -1; + *partFormat =3D g_strdup(partedFormat); } else { /* create primary partition as long as it is possible and after that check if an extended partition exists @@ -636,8 +630,7 @@ virStorageBackendDiskPartFormat(virStoragePoolObjPtr po= ol, } } } else { - if (VIR_STRDUP(*partFormat, "primary") < 0) - return -1; + *partFormat =3D g_strdup("primary"); } return 0; } diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index ad993c656f..02b824867a 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -81,9 +81,8 @@ virStorageBackendFileSystemNetFindPoolSourcesFunc(char **= const groups, goto cleanup; src->nhost =3D 1; =20 - if (VIR_STRDUP(src->hosts[0].name, state->host) < 0 || - VIR_STRDUP(src->dir, path) < 0) - goto cleanup; + src->hosts[0].name =3D g_strdup(state->host); + src->dir =3D g_strdup(path); src->format =3D VIR_STORAGE_POOL_NETFS_NFS; =20 ret =3D 0; diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 23fe0dc226..69de95a9ed 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -100,8 +100,7 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool) if (VIR_ALLOC(ret) < 0) return NULL; =20 - if (VIR_STRDUP(ret->volname, name) < 0) - goto error; + ret->volname =3D g_strdup(name); if (virAsprintf(&ret->dir, "%s%s", dir ? dir : "/", trailing_slash ? "" : "/") < 0) goto error; @@ -110,10 +109,8 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool) * extended to allow alternate transport */ if (VIR_ALLOC(ret->uri) < 0) goto error; - if (VIR_STRDUP(ret->uri->scheme, "gluster") < 0) - goto error; - if (VIR_STRDUP(ret->uri->server, def->source.hosts[0].name) < 0) - goto error; + ret->uri->scheme =3D g_strdup("gluster"); + ret->uri->server =3D g_strdup(def->source.hosts[0].name); if (virAsprintf(&ret->uri->path, "/%s%s", ret->volname, ret->dir) < 0) goto error; ret->uri->port =3D def->source.hosts[0].port; @@ -196,8 +193,7 @@ virStorageBackendGlusterSetMetadata(virStorageBackendGl= usterStatePtr state, =20 if (name) { VIR_FREE(vol->name); - if (VIR_STRDUP(vol->name, name) < 0) - return -1; + vol->name =3D g_strdup(name); } =20 if (virAsprintf(&path, "%s%s%s", state->volname, state->dir, @@ -218,8 +214,7 @@ virStorageBackendGlusterSetMetadata(virStorageBackendGl= usterStatePtr state, state->uri->path =3D tmp; =20 /* the path is unique enough to serve as a volume key */ - if (VIR_STRDUP(vol->key, vol->target.path) < 0) - return -1; + vol->key =3D g_strdup(vol->target.path); =20 return 0; } diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/stora= ge_backend_iscsi_direct.c index 7492566099..e8bf42d0d0 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -425,8 +425,7 @@ virISCSIDirectUpdateTargets(struct iscsi_context *iscsi, for (tmp_addr =3D addr; tmp_addr; tmp_addr =3D tmp_addr->next) { g_autofree char *target =3D NULL; =20 - if (VIR_STRDUP(target, tmp_addr->target_name) < 0) - goto cleanup; + target =3D g_strdup(tmp_addr->target_name); =20 if (VIR_APPEND_ELEMENT(tmp_targets, tmp_ntargets, target) < 0) goto cleanup; diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 80d2dfd0b4..208ca0792f 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -286,8 +286,7 @@ virStorageBackendLogicalMakeVol(char **const groups, is_new_vol =3D true; vol->type =3D VIR_STORAGE_VOL_BLOCK; =20 - if (VIR_STRDUP(vol->name, groups[0]) < 0) - goto cleanup; + vol->name =3D g_strdup(groups[0]); =20 } =20 @@ -466,9 +465,8 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **cons= t groups, g_autofree char *pvname =3D NULL; g_autofree char *vgname =3D NULL; =20 - if (VIR_STRDUP(pvname, groups[0]) < 0 || - VIR_STRDUP(vgname, groups[1]) < 0) - return -1; + pvname =3D g_strdup(groups[0]); + vgname =3D g_strdup(groups[1]); =20 thisSource =3D NULL; for (i =3D 0; i < sourceList->nsources; i++) { diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index 2d9ebf3ba3..fd3ee76371 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -65,8 +65,7 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, } =20 /* XXX should use logical unit's UUID instead */ - if (VIR_STRDUP(vol->key, vol->target.path) < 0) - return -1; + vol->key =3D g_strdup(vol->target.path); =20 if (virStoragePoolObjAddVol(pool, vol) < 0) return -1; diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index e4154479c2..1c59c18b0d 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -660,8 +660,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSta= tePtr ptr) if (STREQ(name, "")) break; =20 - if (VIR_STRDUP(namedup, name) < 0) - goto error; + namedup =3D g_strdup(name); =20 if (VIR_APPEND_ELEMENT(names, nnames, namedup) < 0) goto error; diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index 443c224222..e481eea816 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -118,9 +118,11 @@ virStorageBackendSheepdogAddVolume(virStoragePoolObjPt= r pool, const char *diskIn return -1; } =20 - if (VIR_ALLOC(vol) < 0 || VIR_STRDUP(vol->name, diskInfo) < 0) + if (VIR_ALLOC(vol) < 0) return -1; =20 + vol->name =3D g_strdup(diskInfo); + vol->type =3D VIR_STORAGE_VOL_NETWORK; =20 if (virStorageBackendSheepdogRefreshVol(pool, vol) < 0) @@ -229,8 +231,7 @@ virStorageBackendSheepdogCreateVol(virStoragePoolObjPtr= pool, return -1; =20 VIR_FREE(vol->target.path); - if (VIR_STRDUP(vol->target.path, vol->name) < 0) - return -1; + vol->target.path =3D g_strdup(vol->name); =20 return 0; } diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 75edab4b26..c3057fede6 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -132,8 +132,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, is_new_vol =3D true; volume->type =3D VIR_STORAGE_VOL_BLOCK; =20 - if (VIR_STRDUP(volume->name, vol_name) < 0) - goto cleanup; + volume->name =3D g_strdup(vol_name); } =20 if (!volume->key) @@ -313,8 +312,7 @@ virStorageBackendZFSCreateVol(virStoragePoolObjPtr pool, def->target.path, vol->name) < 0) return -1; =20 - if (VIR_STRDUP(vol->key, vol->target.path) < 0) - goto cleanup; + vol->key =3D g_strdup(vol->target.path); =20 volmode_needed =3D virStorageBackendZFSVolModeNeeded(); if (volmode_needed < 0) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index ac215c7036..3b8332af01 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -272,13 +272,9 @@ storageStateInitialize(bool privileged, goto error; =20 if (privileged) { - if (VIR_STRDUP(driver->configDir, - SYSCONFDIR "/libvirt/storage") < 0 || - VIR_STRDUP(driver->autostartDir, - SYSCONFDIR "/libvirt/storage/autostart") < 0 || - VIR_STRDUP(driver->stateDir, - RUNSTATEDIR "/libvirt/storage") < 0) - goto error; + driver->configDir =3D g_strdup(SYSCONFDIR "/libvirt/storage"); + driver->autostartDir =3D g_strdup(SYSCONFDIR "/libvirt/storage/aut= ostart"); + driver->stateDir =3D g_strdup(RUNSTATEDIR "/libvirt/storage"); } else { configdir =3D virGetUserConfigDirectory(); rundir =3D virGetUserRuntimeDirectory(); @@ -2442,12 +2438,11 @@ storageVolUpload(virStorageVolPtr vol, * interaction and we can just lookup the backend in the callback * routine in order to call the refresh API. */ - if (VIR_ALLOC(cbdata) < 0 || - VIR_STRDUP(cbdata->pool_name, def->name) < 0) - goto cleanup; - if (voldef->type =3D=3D VIR_STORAGE_VOL_PLOOP && - VIR_STRDUP(cbdata->vol_path, voldef->target.path) < 0) + if (VIR_ALLOC(cbdata) < 0) goto cleanup; + cbdata->pool_name =3D g_strdup(def->name); + if (voldef->type =3D=3D VIR_STORAGE_VOL_PLOOP) + cbdata->vol_path =3D g_strdup(voldef->target.path); =20 virStoragePoolObjIncrAsyncjobs(obj); voldef->in_use++; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 692b3e7a9d..7b934b61e0 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1874,10 +1874,7 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageSou= rcePtr target, return -1; } } else { - if (VIR_STRDUP(target->perms->label, filecon) < 0) { - freecon(filecon); - return -1; - } + target->perms->label =3D g_strdup(filecon); freecon(filecon); } } @@ -2758,8 +2755,7 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool) unsigned int dir_create_flags; g_autofree char *parent =3D NULL; =20 - if (VIR_STRDUP(parent, def->target.path) < 0) - return -1; + parent =3D g_strdup(def->target.path); if (!(p =3D strrchr(parent, '/'))) { virReportError(VIR_ERR_INVALID_ARG, _("path '%s' is not absolute"), @@ -2865,8 +2861,7 @@ virStorageUtilGlusterExtractPoolSources(const char *h= ost, src->format =3D VIR_STORAGE_POOL_NETFS_GLUSTERFS; src->dir =3D g_steal_pointer(&volname); } else if (pooltype =3D=3D VIR_STORAGE_POOL_GLUSTER) { - if (VIR_STRDUP(src->dir, "/") < 0) - goto cleanup; + src->dir =3D g_strdup("/"); src->name =3D g_steal_pointer(&volname); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2878,8 +2873,7 @@ virStorageUtilGlusterExtractPoolSources(const char *h= ost, goto cleanup; src->nhost =3D 1; =20 - if (VIR_STRDUP(src->hosts[0].name, host) < 0) - goto cleanup; + src->hosts[0].name =3D g_strdup(host); } =20 ret =3D nnodes; @@ -3547,16 +3541,14 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr = pool) if (VIR_ALLOC(vol) < 0) goto cleanup; =20 - if (VIR_STRDUP(vol->name, ent->d_name) < 0) - goto cleanup; + vol->name =3D g_strdup(ent->d_name); =20 vol->type =3D VIR_STORAGE_VOL_FILE; if (virAsprintf(&vol->target.path, "%s/%s", def->target.path, vol->name) < 0) goto cleanup; =20 - if (VIR_STRDUP(vol->key, vol->target.path) < 0) - goto cleanup; + vol->key =3D g_strdup(vol->target.path); =20 if ((err =3D virStorageBackendRefreshVolTargetUpdate(vol)) < 0) { if (err =3D=3D -2) { @@ -3615,8 +3607,7 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr po= ol) def->target.perms.uid =3D target->perms->uid; def->target.perms.gid =3D target->perms->gid; VIR_FREE(def->target.perms.label); - if (VIR_STRDUP(def->target.perms.label, target->perms->label) < 0) - goto cleanup; + def->target.perms.label =3D g_strdup(target->perms->label); =20 ret =3D 0; cleanup: @@ -3769,8 +3760,7 @@ getNewStyleBlockDevice(const char *lun_path, goto cleanup; =20 while ((direrr =3D virDirRead(block_dir, &block_dirent, block_path)) >= 0) { - if (VIR_STRDUP(*block_device, block_dirent->d_name) < 0) - goto cleanup; + *block_device =3D g_strdup(block_dirent->d_name); =20 VIR_DEBUG("Block device is '%s'", *block_device); =20 @@ -3805,8 +3795,7 @@ getOldStyleBlockDevice(const char *lun_path G_GNUC_UN= USED, goto cleanup; } else { blockp++; - if (VIR_STRDUP(*block_device, blockp) < 0) - goto cleanup; + *block_device =3D g_strdup(blockp); =20 VIR_DEBUG("Block device is '%s'", *block_device); } @@ -4096,8 +4085,7 @@ virStorageBackendFileSystemGetPoolSource(virStoragePo= olObjPtr pool) return NULL; } } else { - if (VIR_STRDUP(src, def->source.devices[0].path) < 0) - return NULL; + src =3D g_strdup(def->source.devices[0].path); } return src; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576298; cv=none; d=zoho.com; s=zohoarc; b=RlxgIjRmIHg1ByZq39L4UobAJVgAhyuzX3aeee1sQQoUm0mZa/K16aFTnQ9MwtNh5SJEP/YgQjUO7+jVpEv5ur0pgMqDK2qjPG/smkilKz507RGYvNLu40ipgwzEaMW0BvV7R+8Nb3BlEr9trYF6Lvm6eNiRH4llELAqsMJMw5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576298; 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=ZS3c7NR/Tg7zg1+BRu3831nhuFU5Zar900tXYtZB1bU=; b=laeui6axJqwvDlxzFXTdVynWJNleV7x15deEI3fTA7zomLj9gSwABKUGG8g8udtfSrNjcyC6x3KEpBf1N4XkKoO+QuQaZbeVCfKYUUJvUHIbnScQd9kWPM6+LlrzT4fcSXL65scI34zroZ0kvcozdywkKFplC8r4OZ/CuhduQWQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571576298534137.53235497862556; Sun, 20 Oct 2019 05:58:18 -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-344-mGEPCY1rPRWR0VvE4lCTDg-1; Sun, 20 Oct 2019 08:56:35 -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 89DC4835BFE; Sun, 20 Oct 2019 12:56:29 +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 5F9B260C63; Sun, 20 Oct 2019 12:56:29 +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 214853FC60; Sun, 20 Oct 2019 12:56:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCu8an023592 for ; Sun, 20 Oct 2019 08:56:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C8AD90B3; Sun, 20 Oct 2019 12:56:08 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF7533DA3 for ; Sun, 20 Oct 2019 12:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576297; 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=ZS3c7NR/Tg7zg1+BRu3831nhuFU5Zar900tXYtZB1bU=; b=dYmrN5MH8qwgcWY/nYccjr1konXs4Jfa5WYVHKyaK4BscVfV+wbBJZWzr90Ws8bxJNV3Pi XFs8mK/KCDgTI4JyFTu6/LoTnBw9N1XJm95coS67A7ZcqbJOvep+ZsyrDKkOP3aGEN0QQO jX0nmBm62CKOMA0fe9hJ3H+AsmqXR9w= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 27/34] test: use g_strdup instead of VIR_STRDUP 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-MC-Unique: mGEPCY1rPRWR0VvE4lCTDg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/test/test_driver.c | 111 +++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 70 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6af40ee35c..e00a65d8bb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -359,11 +359,9 @@ testBuildCapabilities(virConnectPtr conn) caps->host.nsecModels =3D 1; if (VIR_ALLOC_N(caps->host.secModels, caps->host.nsecModels) < 0) goto error; - if (VIR_STRDUP(caps->host.secModels[0].model, "testSecurity") < 0) - goto error; + caps->host.secModels[0].model =3D g_strdup("testSecurity"); =20 - if (VIR_STRDUP(caps->host.secModels[0].doi, "") < 0) - goto error; + caps->host.secModels[0].doi =3D g_strdup(""); =20 return caps; =20 @@ -3105,8 +3103,7 @@ testDomainRenameCallback(virDomainObjPtr privdom, return -1; } =20 - if (VIR_STRDUP(new_dom_name, new_name) < 0) - goto cleanup; + new_dom_name =3D g_strdup(new_name); =20 event_old =3D virDomainEventLifecycleNewFromObj(privdom, VIR_DOMAIN_EVENT_UNDEFIN= ED, @@ -3121,7 +3118,6 @@ testDomainRenameCallback(virDomainObjPtr privdom, VIR_DOMAIN_EVENT_DEFINED= _RENAMED); ret =3D 0; =20 - cleanup: virObjectEventStateQueue(driver->eventState, event_old); virObjectEventStateQueue(driver->eventState, event_new); return ret; @@ -3692,8 +3688,7 @@ testDomainSetBlockIoTune(virDomainPtr dom, } =20 info =3D conf_disk->blkdeviotune; - if (VIR_STRDUP(info.group_name, conf_disk->blkdeviotune.group_name) < = 0) - goto cleanup; + info.group_name =3D g_strdup(conf_disk->blkdeviotune.group_name); =20 if (virTypedParamsAddString(&eventParams, &eventNparams, &eventMaxpara= ms, VIR_DOMAIN_TUNABLE_BLKDEV_DISK, path) < 0) @@ -3763,8 +3758,7 @@ testDomainSetBlockIoTune(virDomainPtr dom, =20 if (STREQ(param->field, VIR_DOMAIN_BLOCK_IOTUNE_GROUP_NAME)) { VIR_FREE(info.group_name); - if (VIR_STRDUP(info.group_name, param->value.s) < 0) - goto cleanup; + info.group_name =3D g_strdup(param->value.s); if (virTypedParamsAddString(&eventParams, &eventNparams, &eventMaxparams, @@ -3899,8 +3893,7 @@ testDomainGetBlockIoTune(virDomainPtr dom, } =20 reply =3D disk->blkdeviotune; - if (VIR_STRDUP(reply.group_name, disk->blkdeviotune.group_name) < 0) - goto cleanup; + reply.group_name =3D g_strdup(disk->blkdeviotune.group_name); =20 TEST_SET_PARAM(0, VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC, VIR_TYPED_PARAM_ULLONG, reply.total_bytes_sec); @@ -4689,8 +4682,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom, memset(errors, 0, sizeof(virDomainDiskError) * nerrors); =20 for (i =3D 0; i < nerrors; i++) { - if (VIR_STRDUP(errors[i].disk, vm->def->disks[i]->dst) < 0) - goto cleanup; + errors[i].disk =3D g_strdup(vm->def->disks[i]->dst); errors[i].error =3D (i % (VIR_DOMAIN_DISK_ERROR_LAST - 1)) + 1; } ret =3D i; @@ -4737,19 +4729,23 @@ testDomainGetFSInfo(virDomainPtr dom, goto cleanup; =20 if (VIR_ALLOC(info_ret[0]) < 0 || - VIR_ALLOC(info_ret[0]->devAlias) < 0 || - VIR_STRDUP(info_ret[0]->mountpoint, "/") < 0 || - VIR_STRDUP(info_ret[0]->fstype, "ext4") < 0 || - VIR_STRDUP(info_ret[0]->devAlias[0], name) < 0 || - virAsprintf(&info_ret[0]->name, "%s1", name) < 0) + VIR_ALLOC(info_ret[0]->devAlias) < 0) + goto cleanup; + + info_ret[0]->mountpoint =3D g_strdup("/"); + info_ret[0]->fstype =3D g_strdup("ext4"); + info_ret[0]->devAlias[0] =3D g_strdup(name); + if (virAsprintf(&info_ret[0]->name, "%s1", name) < 0) goto cleanup; =20 if (VIR_ALLOC(info_ret[1]) < 0 || - VIR_ALLOC(info_ret[1]->devAlias) < 0 || - VIR_STRDUP(info_ret[1]->mountpoint, "/boot") < 0 || - VIR_STRDUP(info_ret[1]->fstype, "ext4") < 0 || - VIR_STRDUP(info_ret[1]->devAlias[0], name) < 0 || - virAsprintf(&info_ret[1]->name, "%s2", name) < 0) + VIR_ALLOC(info_ret[1]->devAlias) < 0) + goto cleanup; + + info_ret[1]->mountpoint =3D g_strdup("/boot"); + info_ret[1]->fstype =3D g_strdup("ext4"); + info_ret[1]->devAlias[0] =3D g_strdup(name); + if (virAsprintf(&info_ret[1]->name, "%s2", name) < 0) goto cleanup; =20 info_ret[0]->ndevAlias =3D info_ret[1]->ndevAlias =3D 1; @@ -5101,12 +5097,10 @@ testDomainInterfaceAddresses(virDomainPtr dom, if (VIR_ALLOC(iface) < 0) goto cleanup; =20 - if (VIR_STRDUP(iface->name, net->ifname) < 0) - goto cleanup; + iface->name =3D g_strdup(net->ifname); =20 virMacAddrFormat(&net->mac, macaddr); - if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) - goto cleanup; + iface->hwaddr =3D g_strdup(macaddr); =20 if (VIR_ALLOC(iface->addrs) < 0) goto cleanup; @@ -6059,8 +6053,7 @@ testStoragePoolObjSetDefaults(virStoragePoolObjPtr ob= j) def->allocation =3D defaultPoolAlloc; def->available =3D defaultPoolCap - defaultPoolAlloc; =20 - if (VIR_STRDUP(configFile, "") < 0) - return -1; + configFile =3D g_strdup(""); =20 virStoragePoolObjSetConfigFile(obj, configFile); return 0; @@ -7025,8 +7018,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool, def->target.path, privvol->name) < 0) goto cleanup; =20 - if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || - virStoragePoolObjAddVol(obj, privvol) < 0) + privvol->key =3D g_strdup(privvol->target.path); + if (virStoragePoolObjAddVol(obj, privvol) < 0) goto cleanup; =20 def->allocation +=3D privvol->target.allocation; @@ -7093,8 +7086,8 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool, def->target.path, privvol->name) < 0) goto cleanup; =20 - if (VIR_STRDUP(privvol->key, privvol->target.path) < 0 || - virStoragePoolObjAddVol(obj, privvol) < 0) + privvol->key =3D g_strdup(privvol->target.path); + if (virStoragePoolObjAddVol(obj, privvol) < 0) goto cleanup; =20 def->allocation +=3D privvol->target.allocation; @@ -7319,12 +7312,8 @@ testNodeDeviceLookupByName(virConnectPtr conn, const= char *name) return NULL; def =3D virNodeDeviceObjGetDef(obj); =20 - if ((ret =3D virGetNodeDevice(conn, name))) { - if (VIR_STRDUP(ret->parentName, def->parent) < 0) { - virObjectUnref(ret); - ret =3D NULL; - } - } + if ((ret =3D virGetNodeDevice(conn, name))) + ret->parentName =3D g_strdup(def->parent); =20 virNodeDeviceObjEndAPI(&obj); return ret; @@ -7408,20 +7397,12 @@ testNodeDeviceListCaps(virNodeDevicePtr dev, char *= *const names, int maxnames) def =3D virNodeDeviceObjGetDef(obj); =20 for (caps =3D def->caps; caps && ncaps < maxnames; caps =3D caps->next= ) { - if (VIR_STRDUP(names[ncaps], - virNodeDevCapTypeToString(caps->data.type)) < 0) - goto error; + names[ncaps] =3D g_strdup(virNodeDevCapTypeToString(caps->data.typ= e)); ncaps++; } =20 virNodeDeviceObjEndAPI(&obj); return ncaps; - - error: - while (--ncaps >=3D 0) - VIR_FREE(names[ncaps]); - virNodeDeviceObjEndAPI(&obj); - return -1; } =20 =20 @@ -7459,8 +7440,7 @@ testNodeDeviceMockCreateVport(testDriverPtr driver, goto cleanup; =20 VIR_FREE(def->name); - if (VIR_STRDUP(def->name, "scsi_host12") < 0) - goto cleanup; + def->name =3D g_strdup("scsi_host12"); =20 /* Find the 'scsi_host' cap and alter the host # and unique_id and * then for the 'fc_host' capability modify the wwnn/wwpn to be that @@ -7474,9 +7454,8 @@ testNodeDeviceMockCreateVport(testDriverPtr driver, if (caps->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST= ) { VIR_FREE(caps->data.scsi_host.wwnn); VIR_FREE(caps->data.scsi_host.wwpn); - if (VIR_STRDUP(caps->data.scsi_host.wwnn, wwnn) < 0 || - VIR_STRDUP(caps->data.scsi_host.wwpn, wwpn) < 0) - goto cleanup; + caps->data.scsi_host.wwnn =3D g_strdup(wwnn); + caps->data.scsi_host.wwpn =3D g_strdup(wwpn); } else { /* For the "scsi_host" cap, increment our host and unique_id to * give the appearance that something new was created - then a= dd @@ -7547,8 +7526,7 @@ testNodeDeviceCreateXML(virConnectPtr conn, goto cleanup; =20 VIR_FREE(dev->parentName); - if (VIR_STRDUP(dev->parentName, def->parent) < 0) - goto cleanup; + dev->parentName =3D g_strdup(def->parent); =20 ret =3D g_steal_pointer(&dev); =20 @@ -7819,8 +7797,7 @@ testDomainScreenshot(virDomainPtr dom G_GNUC_UNUSED, =20 virCheckFlags(0, NULL); =20 - if (VIR_STRDUP(ret, "image/png") < 0) - return NULL; + ret =3D g_strdup("image/png"); =20 if (virFDStreamOpenFile(st, PKGDATADIR "/test-screenshot.png", 0, 0, O= _RDONLY) < 0) VIR_FREE(ret); @@ -8635,9 +8612,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain, } =20 if (!redefine) { - if (VIR_STRDUP(snap->def->parent_name, - virDomainSnapshotGetCurrentName(vm->snapshots)) < 0) - goto cleanup; + snap->def->parent_name =3D g_strdup(virDomainSnapshotGetCurrentNam= e(vm->snapshots)); =20 if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) && virDomainObjIsActive(vm)) { @@ -8703,11 +8678,8 @@ testDomainMomentReparentChildren(void *payload, =20 VIR_FREE(moment->def->parent_name); =20 - if (rep->parent->def && - VIR_STRDUP(moment->def->parent_name, rep->parent->def->name) < 0) { - rep->err =3D -1; - return 0; - } + if (rep->parent->def) + moment->def->parent_name =3D g_strdup(rep->parent->def->name); =20 return 0; } @@ -9098,9 +9070,8 @@ testDomainCheckpointCreateXML(virDomainPtr domain, =20 current =3D virDomainCheckpointGetCurrent(vm->checkpoints); if (current) { - if (!redefine && - VIR_STRDUP(chk->def->parent_name, current->def->name) < 0) - goto cleanup; + if (!redefine) + chk->def->parent_name =3D g_strdup(current->def->name); if (update_current) virDomainCheckpointSetCurrent(vm->checkpoints, NULL); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576201; cv=none; d=zoho.com; s=zohoarc; b=e6FafUr8A2m03z7Dnj6uhWt31Nibt+i/TWzAaoRuBdx8JxrIxJbbUX4xl6AYL5Mk3ba4lm82AdHHsPwJ8GjLPGoI39QbJMZpEaFm14VGgJBFe7T/yCE/ajwsg0N1PPBeQGnc1RuFgSUli8MUrRukJfhSFtRnyQ/yKNQFkohNK8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576201; 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=i2gkWQk/o+JSGJXUrfr6abf9a2eTfwnRctOf9MmWih8=; b=L8n8XJ53IqeiysKweWSNihskQFvY0Cx3dAUMY7jafU+8ygkRpQFNGOslerDkqMFu4eaKA6l97jDmjAOlPw25mtTjiOVgLuEWZdJ1LfXB0AteLE9GuBHY/JMvVPaEWZExqyrgc7FA/w7IkYMJWvwAC++Nq+07sjKT/fj7A1DUfmg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576201813600.2178951890908; Sun, 20 Oct 2019 05:56:41 -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-82-MRWOMhQxMha6hClvHyh5AA-1; Sun, 20 Oct 2019 08:56:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBD875F2; Sun, 20 Oct 2019 12:56:32 +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 8E02F5B6A5; Sun, 20 Oct 2019 12:56:32 +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 4F2203FB43; Sun, 20 Oct 2019 12:56:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCu9Uv023605 for ; Sun, 20 Oct 2019 08:56:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F8793DA3; Sun, 20 Oct 2019 12:56:09 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F8CB9473 for ; Sun, 20 Oct 2019 12:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576200; 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=i2gkWQk/o+JSGJXUrfr6abf9a2eTfwnRctOf9MmWih8=; b=LRi7LaBOTRfKb1KsdPK0lulNPxWWrAP13nYVuLIJGA2ENCVV3SeuyJ2ep0xENJgmuRDHKi TjRM01rrJfhn74Z4CRum0MTpRpfdsPM8vEWaddwLciPTtRKMSO4h4iLjHLUdbSv+2ku0i9 NWmSmVW+jVG2uj94Cq48y7xOY6JimcY= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 28/34] virstorage: use g_strdup instead of VIR_STRDUP 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.15 X-MC-Unique: MRWOMhQxMha6hClvHyh5AA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virstorageencryption.c | 11 +- src/util/virstoragefile.c | 188 ++++++++++++-------------------- 2 files changed, 72 insertions(+), 127 deletions(-) diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryptio= n.c index 14d7dc26e2..74836d4a00 100644 --- a/src/util/virstorageencryption.c +++ b/src/util/virstorageencryption.c @@ -101,12 +101,11 @@ virStorageEncryptionInfoDefCopy(const virStorageEncry= ptionInfoDef *src, virStorageEncryptionInfoDefPtr dst) { dst->cipher_size =3D src->cipher_size; - if (VIR_STRDUP(dst->cipher_name, src->cipher_name) < 0 || - VIR_STRDUP(dst->cipher_mode, src->cipher_mode) < 0 || - VIR_STRDUP(dst->cipher_hash, src->cipher_hash) < 0 || - VIR_STRDUP(dst->ivgen_name, src->ivgen_name) < 0 || - VIR_STRDUP(dst->ivgen_hash, src->ivgen_hash) < 0) - return -1; + dst->cipher_name =3D g_strdup(src->cipher_name); + dst->cipher_mode =3D g_strdup(src->cipher_mode); + dst->cipher_hash =3D g_strdup(src->cipher_hash); + dst->ivgen_name =3D g_strdup(src->ivgen_name); + dst->ivgen_hash =3D g_strdup(src->ivgen_hash); =20 return 0; } diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c13ed9fee5..be2b5479bb 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -644,8 +644,7 @@ vmdk4GetBackingStore(char **res, goto cleanup; } *end =3D '\0'; - if (VIR_STRDUP(*res, start) < 0) - goto cleanup; + *res =3D g_strdup(start); =20 ret =3D BACKING_STORE_OK; =20 @@ -1068,9 +1067,8 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr= meta, } =20 VIR_FREE(meta->compat); - if (meta->format =3D=3D VIR_STORAGE_FILE_QCOW2 && meta->features && - VIR_STRDUP(meta->compat, "1.1") < 0) - return -1; + if (meta->format =3D=3D VIR_STORAGE_FILE_QCOW2 && meta->features) + meta->compat =3D g_strdup("1.1"); =20 return 0; } @@ -1138,8 +1136,7 @@ virStorageFileMetadataNew(const char *path, def->format =3D format; def->type =3D VIR_STORAGE_TYPE_FILE; =20 - if (VIR_STRDUP(def->path, path) < 0) - return NULL; + def->path =3D g_strdup(path); =20 ret =3D g_steal_pointer(&def); return ret; @@ -1290,8 +1287,7 @@ virStorageFileChainGetBroken(virStorageSourcePtr chai= n, /* Break when we hit end of chain; report error if we detected * a missing backing file, infinite loop, or other error */ if (!tmp->backingStore && tmp->backingStoreRaw) { - if (VIR_STRDUP(*brokenFile, tmp->backingStoreRaw) < 0) - return -1; + *brokenFile =3D g_strdup(tmp->backingStoreRaw); =20 return 0; } @@ -1591,9 +1587,8 @@ virStorageFileParseBackingStoreStr(const char *str, return -1; } =20 - if (target && - VIR_STRDUP(*target, strings[0]) < 0) - return -1; + if (target) + *target =3D g_strdup(strings[0]); =20 *chainIndex =3D idx; return 0; @@ -1820,11 +1815,8 @@ virStorageNetHostDefCopy(size_t nhosts, dst->transport =3D src->transport; dst->port =3D src->port; =20 - if (VIR_STRDUP(dst->name, src->name) < 0) - goto error; - - if (VIR_STRDUP(dst->socket, src->socket) < 0) - goto error; + dst->name =3D g_strdup(src->name); + dst->socket =3D g_strdup(src->socket); } =20 return ret; @@ -1857,11 +1849,9 @@ virStorageAuthDefCopy(const virStorageAuthDef *src) if (VIR_ALLOC(authdef) < 0) return NULL; =20 - if (VIR_STRDUP(authdef->username, src->username) < 0) - return NULL; + authdef->username =3D g_strdup(src->username); /* Not present for storage pool, but used for disk source */ - if (VIR_STRDUP(authdef->secrettype, src->secrettype) < 0) - return NULL; + authdef->secrettype =3D g_strdup(src->secrettype); authdef->authType =3D src->authType; =20 if (virSecretLookupDefCopy(&authdef->seclookupdef, &src->seclookupdef)= < 0) @@ -2109,13 +2099,11 @@ virStoragePRDefCopy(virStoragePRDefPtr src) =20 copy->managed =3D src->managed; =20 - if (VIR_STRDUP(copy->path, src->path) < 0 || - VIR_STRDUP(copy->mgralias, src->mgralias) < 0) - goto cleanup; + copy->path =3D g_strdup(src->path); + copy->mgralias =3D g_strdup(src->mgralias); =20 ret =3D g_steal_pointer(©); =20 - cleanup: virStoragePRDefFree(copy); return ret; } @@ -2201,14 +2189,9 @@ virStoragePermsCopy(const virStoragePerms *src) ret->uid =3D src->uid; ret->gid =3D src->gid; =20 - if (VIR_STRDUP(ret->label, src->label) < 0) - goto error; + ret->label =3D g_strdup(src->label); =20 return ret; - - error: - virStoragePermsFree(ret); - return NULL; } =20 =20 @@ -2225,15 +2208,10 @@ virStorageSourcePoolDefCopy(const virStorageSourceP= oolDef *src) ret->actualtype =3D src->actualtype; ret->mode =3D src->mode; =20 - if (VIR_STRDUP(ret->pool, src->pool) < 0 || - VIR_STRDUP(ret->volume, src->volume) < 0) - goto error; + ret->pool =3D g_strdup(src->pool); + ret->volume =3D g_strdup(src->volume); =20 return ret; - - error: - virStorageSourcePoolDefFree(ret); - return NULL; } =20 =20 @@ -2279,19 +2257,18 @@ virStorageSourceCopy(const virStorageSource *src, /* storage driver metadata are not copied */ def->drv =3D NULL; =20 - if (VIR_STRDUP(def->path, src->path) < 0 || - VIR_STRDUP(def->volume, src->volume) < 0 || - VIR_STRDUP(def->relPath, src->relPath) < 0 || - VIR_STRDUP(def->backingStoreRaw, src->backingStoreRaw) < 0 || - VIR_STRDUP(def->externalDataStoreRaw, src->externalDataStoreRaw) <= 0 || - VIR_STRDUP(def->snapshot, src->snapshot) < 0 || - VIR_STRDUP(def->configFile, src->configFile) < 0 || - VIR_STRDUP(def->nodeformat, src->nodeformat) < 0 || - VIR_STRDUP(def->nodestorage, src->nodestorage) < 0 || - VIR_STRDUP(def->compat, src->compat) < 0 || - VIR_STRDUP(def->tlsAlias, src->tlsAlias) < 0 || - VIR_STRDUP(def->tlsCertdir, src->tlsCertdir) < 0) - return NULL; + def->path =3D g_strdup(src->path); + def->volume =3D g_strdup(src->volume); + def->relPath =3D g_strdup(src->relPath); + def->backingStoreRaw =3D g_strdup(src->backingStoreRaw); + def->externalDataStoreRaw =3D g_strdup(src->externalDataStoreRaw); + def->snapshot =3D g_strdup(src->snapshot); + def->configFile =3D g_strdup(src->configFile); + def->nodeformat =3D g_strdup(src->nodeformat); + def->nodestorage =3D g_strdup(src->nodestorage); + def->compat =3D g_strdup(src->compat); + def->tlsAlias =3D g_strdup(src->tlsAlias); + def->tlsCertdir =3D g_strdup(src->tlsCertdir); =20 if (src->nhosts) { if (!(def->hosts =3D virStorageNetHostDefCopy(src->nhosts, src->ho= sts))) @@ -2635,8 +2612,7 @@ virStorageSourceNewFromBackingRelative(virStorageSour= cePtr parent, return NULL; =20 /* store relative name */ - if (VIR_STRDUP(def->relPath, rel) < 0) - return NULL; + def->relPath =3D g_strdup(rel); =20 if (!(dirname =3D mdir_name(parent->path))) { virReportOOMError(); @@ -2664,8 +2640,7 @@ virStorageSourceNewFromBackingRelative(virStorageSour= cePtr parent, def->nhosts =3D parent->nhosts; } =20 - if (VIR_STRDUP(def->volume, parent->volume) < 0) - return NULL; + def->volume =3D g_strdup(parent->volume); } else { /* set the type to _FILE, the caller shall update it to the actual= type */ def->type =3D VIR_STORAGE_TYPE_FILE; @@ -2716,10 +2691,8 @@ virStorageSourceParseBackingURI(virStorageSourcePtr = src, } =20 /* handle socket stored as a query */ - if (uri->query) { - if (VIR_STRDUP(src->hosts->socket, STRSKIP(uri->query, "socket=3D"= )) < 0) - return -1; - } + if (uri->query) + src->hosts->socket =3D g_strdup(STRSKIP(uri->query, "socket=3D")); =20 /* uri->path is NULL if the URI does not contain slash after host: * transport://host:port */ @@ -2737,8 +2710,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr s= rc, path[0] =3D=3D '\0') path =3D NULL; =20 - if (VIR_STRDUP(src->path, path) < 0) - return -1; + src->path =3D g_strdup(path); =20 if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER) { char *tmp; @@ -2759,16 +2731,14 @@ virStorageSourceParseBackingURI(virStorageSourcePtr= src, =20 src->volume =3D src->path; =20 - if (VIR_STRDUP(src->path, tmp + 1) < 0) - return -1; + src->path =3D g_strdup(tmp + 1); =20 tmp[0] =3D '\0'; } =20 src->hosts->port =3D uri->port; =20 - if (VIR_STRDUP(src->hosts->name, uri->server) < 0) - return -1; + src->hosts->name =3D g_strdup(uri->server); =20 /* Libvirt doesn't handle inline authentication. Make the caller aware= . */ if (uri->user) @@ -2835,28 +2805,24 @@ virStorageSourceParseRBDColonString(const char *rbd= str, if (STRPREFIX(rbdstr, "rbd:")) rbdstr +=3D strlen("rbd:"); =20 - if (VIR_STRDUP(src->path, rbdstr) < 0) - return -1; + src->path =3D g_strdup(rbdstr); =20 p =3D strchr(src->path, ':'); if (p) { - if (VIR_STRDUP(options, p + 1) < 0) - return -1; + options =3D g_strdup(p + 1); *p =3D '\0'; } =20 /* snapshot name */ if ((p =3D strchr(src->path, '@'))) { - if (VIR_STRDUP(src->snapshot, p + 1) < 0) - return -1; + src->snapshot =3D g_strdup(p + 1); *p =3D '\0'; } =20 /* pool vs. image name */ if ((p =3D strchr(src->path, '/'))) { src->volume =3D g_steal_pointer(&src->path); - if (VIR_STRDUP(src->path, p + 1) < 0) - return -1; + src->path =3D g_strdup(p + 1); *p =3D '\0'; } =20 @@ -2891,12 +2857,9 @@ virStorageSourceParseRBDColonString(const char *rbds= tr, if (VIR_ALLOC(authdef) < 0) return -1; =20 - if (VIR_STRDUP(authdef->username, p + strlen("id=3D")) < 0) - return -1; + authdef->username =3D g_strdup(p + strlen("id=3D")); =20 - if (VIR_STRDUP(authdef->secrettype, - virSecretUsageTypeToString(VIR_SECRET_USAGE_TYP= E_CEPH)) < 0) - return -1; + authdef->secrettype =3D g_strdup(virSecretUsageTypeToString(VI= R_SECRET_USAGE_TYPE_CEPH)); src->auth =3D g_steal_pointer(&authdef); src->authInherited =3D true; =20 @@ -2926,9 +2889,8 @@ virStorageSourceParseRBDColonString(const char *rbdst= r, } } =20 - if (STRPREFIX(p, "conf=3D") && - VIR_STRDUP(src->configFile, p + strlen("conf=3D")) < 0) - return -1; + if (STRPREFIX(p, "conf=3D")) + src->configFile =3D g_strdup(p + strlen("conf=3D")); =20 p =3D next; } @@ -2971,12 +2933,10 @@ virStorageSourceParseNBDColonString(const char *nbd= str, return -1; } =20 - if (VIR_STRDUP(src->hosts->socket, backing[2]) < 0) - return -1; + src->hosts->socket =3D g_strdup(backing[2]); =20 } else { - if (VIR_STRDUP(src->hosts->name, backing[1]) < 0) - return -1; + src->hosts->name =3D g_strdup(backing[1]); =20 if (!backing[2]) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2991,8 +2951,7 @@ virStorageSourceParseNBDColonString(const char *nbdst= r, =20 if ((exportname =3D strstr(nbdstr, "exportname=3D"))) { exportname +=3D strlen("exportname=3D"); - if (VIR_STRDUP(src->path, exportname) < 0) - return -1; + src->path =3D g_strdup(exportname); } =20 return 0; @@ -3080,8 +3039,7 @@ virStorageSourceParseBackingJSONPath(virStorageSource= Ptr src, return -1; } =20 - if (VIR_STRDUP(src->path, path) < 0) - return -1; + src->path =3D g_strdup(path); =20 src->type =3D type; return 0; @@ -3153,9 +3111,9 @@ virStorageSourceParseBackingJSONInetSocketAddress(vir= StorageNetHostDefPtr host, } =20 host->transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + host->name =3D g_strdup(hostname); =20 - if (VIR_STRDUP(host->name, hostname) < 0 || - virStringParsePort(port, &host->port) < 0) + if (virStringParsePort(port, &host->port) < 0) return -1; =20 return 0; @@ -3202,8 +3160,7 @@ virStorageSourceParseBackingJSONSocketAddress(virStor= ageNetHostDefPtr host, return -1; } =20 - if (VIR_STRDUP(host->socket, socket) < 0) - return -1; + host->socket =3D g_strdup(socket); } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("backing store protocol '%s' is not yet supported= "), @@ -3242,9 +3199,8 @@ virStorageSourceParseBackingJSONGluster(virStorageSou= rcePtr src, src->type =3D VIR_STORAGE_TYPE_NETWORK; src->protocol =3D VIR_STORAGE_NET_PROTOCOL_GLUSTER; =20 - if (VIR_STRDUP(src->volume, volume) < 0 || - VIR_STRDUP(src->path, path) < 0) - return -1; + src->volume =3D g_strdup(volume); + src->path =3D g_strdup(path); =20 nservers =3D virJSONValueArraySize(server); if (nservers =3D=3D 0) { @@ -3317,8 +3273,7 @@ virStorageSourceParseBackingJSONiSCSI(virStorageSourc= ePtr src, return -1; } =20 - if (VIR_STRDUP(src->hosts->name, portal) < 0) - return -1; + src->hosts->name =3D g_strdup(portal); =20 if ((port =3D strrchr(src->hosts->name, ':')) && !strchr(port, ']')) { @@ -3361,8 +3316,7 @@ virStorageSourceParseBackingJSONNbd(virStorageSourceP= tr src, src->type =3D VIR_STORAGE_TYPE_NETWORK; src->protocol =3D VIR_STORAGE_NET_PROTOCOL_NBD; =20 - if (VIR_STRDUP(src->path, export) < 0) - return -1; + src->path =3D g_strdup(export); =20 if (VIR_ALLOC_N(src->hosts, 1) < 0) return -1; @@ -3374,12 +3328,10 @@ virStorageSourceParseBackingJSONNbd(virStorageSourc= ePtr src, } else { if (path) { src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_UNIX; - if (VIR_STRDUP(src->hosts[0].socket, path) < 0) - return -1; + src->hosts[0].socket =3D g_strdup(path); } else { src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; - if (VIR_STRDUP(src->hosts[0].name, host) < 0) - return -1; + src->hosts[0].name =3D g_strdup(host); =20 if (virStringParsePort(port, &src->hosts[0].port) < 0) return -1; @@ -3419,8 +3371,7 @@ virStorageSourceParseBackingJSONSheepdog(virStorageSo= urcePtr src, return -1; } =20 - if (VIR_STRDUP(src->path, vdi) < 0) - return -1; + src->path =3D g_strdup(vdi); =20 if (VIR_ALLOC(src->hosts) < 0) return -1; @@ -3454,8 +3405,7 @@ virStorageSourceParseBackingJSONSSH(virStorageSourceP= tr src, src->type =3D VIR_STORAGE_TYPE_NETWORK; src->protocol =3D VIR_STORAGE_NET_PROTOCOL_SSH; =20 - if (VIR_STRDUP(src->path, path) < 0) - return -1; + src->path =3D g_strdup(path); =20 if (VIR_ALLOC_N(src->hosts, 1) < 0) return -1; @@ -3467,9 +3417,9 @@ virStorageSourceParseBackingJSONSSH(virStorageSourceP= tr src, return -1; } else { src->hosts[0].transport =3D VIR_STORAGE_NET_HOST_TRANS_TCP; + src->hosts[0].name =3D g_strdup(host); =20 - if (VIR_STRDUP(src->hosts[0].name, host) < 0 || - virStringParsePort(port, &src->hosts[0].port) < 0) + if (virStringParsePort(port, &src->hosts[0].port) < 0) return -1; } =20 @@ -3506,11 +3456,10 @@ virStorageSourceParseBackingJSONRBD(virStorageSourc= ePtr src, return -1; } =20 - if (VIR_STRDUP(src->volume, pool) < 0 || - VIR_STRDUP(src->path, image) < 0 || - VIR_STRDUP(src->snapshot, snapshot) < 0 || - VIR_STRDUP(src->configFile, conf) < 0) - goto cleanup; + src->volume =3D g_strdup(pool); + src->path =3D g_strdup(image); + src->snapshot =3D g_strdup(snapshot); + src->configFile =3D g_strdup(conf); =20 if (servers) { nservers =3D virJSONValueArraySize(servers); @@ -3562,8 +3511,7 @@ virStorageSourceParseBackingJSONVxHS(virStorageSource= Ptr src, src->type =3D VIR_STORAGE_TYPE_NETWORK; src->protocol =3D VIR_STORAGE_NET_PROTOCOL_VXHS; =20 - if (VIR_STRDUP(src->path, vdisk_id) < 0) - return -1; + src->path =3D g_strdup(vdisk_id); =20 if (VIR_ALLOC_N(src->hosts, 1) < 0) return -1; @@ -3691,8 +3639,7 @@ virStorageSourceNewFromBackingAbsolute(const char *pa= th, if (virStorageIsFile(path)) { def->type =3D VIR_STORAGE_TYPE_FILE; =20 - if (VIR_STRDUP(def->path, path) < 0) - return -1; + def->path =3D g_strdup(path); } else { def->type =3D VIR_STORAGE_TYPE_NETWORK; =20 @@ -4213,8 +4160,7 @@ virStorageFileRemoveLastPathComponent(const char *pat= h) { char *ret; =20 - if (VIR_STRDUP(ret, NULLSTR_EMPTY(path)) < 0) - return NULL; + ret =3D g_strdup(NULLSTR_EMPTY(path)); =20 virFileRemoveLastComponent(ret); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576349; cv=none; d=zoho.com; s=zohoarc; b=kZg+Kx4lT8Zo09kzN8PXLRM6Gc458VsgH7WUAiUhPF4EbnpT729mqdGIXbbhQQpMDPgBzFqr1BjmIrt53tmxcdv3qTQstAWbZOdsVwyUE0uMPQ8+bWxto1QlRrEiz6DF9j71orsVdPg79KxGqaMKRmnJtEjkd0rO461siZmVhBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576349; 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=l984+DpAy8bK+4fot3fIbtKGXqVAL4ToaGSdH4C12zI=; b=aVOE/LFnYGtM8ofw5uVzu2rk5EHXal5V0iWNKPXZ4MGCjgT9V3ZOhCw5k+JkkyO6jMhyyZjOSYBDYz+HJK2e99+o/sup1k6l3MjxexphxiWYHqvsnbkiU4yol8AuHrcTJ4SpO8iwocfLih2rLjUGh8oiCM3MWWmtMnFFWiWxqPI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576349000277.2242160285829; Sun, 20 Oct 2019 05:59:09 -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-292-67jqN3aqOm2D1McKellrlg-1; Sun, 20 Oct 2019 08:56:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86F151800E00; Sun, 20 Oct 2019 12:56:33 +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 60F9160619; Sun, 20 Oct 2019 12:56:33 +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 287041803B4E; Sun, 20 Oct 2019 12:56:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCuAdw023614 for ; Sun, 20 Oct 2019 08:56:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9E3979446; Sun, 20 Oct 2019 12:56:10 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B472194B9 for ; Sun, 20 Oct 2019 12:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576347; 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=l984+DpAy8bK+4fot3fIbtKGXqVAL4ToaGSdH4C12zI=; b=Cqy4hfoNUnX0FwE+H8PmhAgVw6zdslY98ZhpxKxDEUir/z6kaSyuRpCOEPFeg8qLO+IdQn Jj9Wr/+g+n24IHEc7UwIUwfpKRQJAnfHBByLTzCfWALIdIbAY8CPhKoKePQwRE0k40AOW7 8/Yg3NZjrG7t5F+2mfNWYdvB/V9i+HA= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:47 +0200 Message-Id: <4a73246240d5b11bbb315e448c36e8c2109c3080.1571575890.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 29/34] vircgroup: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 67jqN3aqOm2D1McKellrlg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/vircgroup.c | 15 +++++---------- src/util/vircgroupv1.c | 41 ++++++++++++++++++----------------------- src/util/vircgroupv2.c | 3 +-- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index d824aee86d..8af6906a57 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -289,8 +289,7 @@ virCgroupDetectPlacement(virCgroupPtr group, VIR_DEBUG("Detecting placement for pid %lld path %s", (long long) pid, path); if (pid =3D=3D -1) { - if (VIR_STRDUP(procfile, "/proc/self/cgroup") < 0) - goto cleanup; + procfile =3D g_strdup("/proc/self/cgroup"); } else { if (virAsprintf(&procfile, "/proc/%lld/cgroup", (long long) pid) < 0) @@ -547,8 +546,7 @@ virCgroupGetValueForBlkDev(const char *str, if (!(lines =3D virStringSplit(str, "\n", -1))) goto error; =20 - if (VIR_STRDUP(*value, virStringListGetFirstWithPrefix(lines, prefix))= < 0) - goto error; + *value =3D g_strdup(virStringListGetFirstWithPrefix(lines, prefix)); =20 ret =3D 0; error: @@ -682,8 +680,7 @@ virCgroupNew(pid_t pid, goto error; =20 if (path[0] =3D=3D '/' || !parent) { - if (VIR_STRDUP((*group)->path, path) < 0) - goto error; + (*group)->path =3D g_strdup(path); } else { if (virAsprintf(&(*group)->path, "%s%s%s", parent->path, @@ -863,8 +860,7 @@ virCgroupNewPartition(const char *path, =20 if (STRNEQ(newPath, "/")) { char *tmp; - if (VIR_STRDUP(parentPath, newPath) < 0) - goto cleanup; + parentPath =3D g_strdup(newPath); =20 tmp =3D strrchr(parentPath, '/'); tmp++; @@ -979,8 +975,7 @@ virCgroupNewThread(virCgroupPtr domain, return -1; break; case VIR_CGROUP_THREAD_EMULATOR: - if (VIR_STRDUP(name, "emulator") < 0) - return -1; + name =3D g_strdup("emulator"); break; case VIR_CGROUP_THREAD_IOTHREAD: if (virAsprintf(&name, "iothread%d", id) < 0) diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 6ab79a1897..0820c5d638 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -175,13 +175,9 @@ virCgroupV1CopyMounts(virCgroupPtr group, if (!parent->legacy[i].mountPoint) continue; =20 - if (VIR_STRDUP(group->legacy[i].mountPoint, - parent->legacy[i].mountPoint) < 0) - return -1; + group->legacy[i].mountPoint =3D g_strdup(parent->legacy[i].mountPo= int); =20 - if (VIR_STRDUP(group->legacy[i].linkPoint, - parent->legacy[i].linkPoint) < 0) - return -1; + group->legacy[i].linkPoint =3D g_strdup(parent->legacy[i].linkPoin= t); } return 0; } @@ -201,8 +197,7 @@ virCgroupV1CopyPlacement(virCgroupPtr group, continue; =20 if (path[0] =3D=3D '/') { - if (VIR_STRDUP(group->legacy[i].placement, path) < 0) - return -1; + group->legacy[i].placement =3D g_strdup(path); } else { /* * parent =3D=3D "/" + path=3D"" =3D> "/" @@ -233,8 +228,7 @@ virCgroupV1ResolveMountLink(const char *mntDir, char *dirName; struct stat sb; =20 - if (VIR_STRDUP(tmp, mntDir) < 0) - return -1; + tmp =3D g_strdup(mntDir); =20 dirName =3D strrchr(tmp, '/'); if (!dirName) { @@ -325,8 +319,7 @@ virCgroupV1DetectMounts(virCgroupPtr group, =20 VIR_FREE(controller->mountPoint); VIR_FREE(controller->linkPoint); - if (VIR_STRDUP(controller->mountPoint, mntDir) < 0) - return -1; + controller->mountPoint =3D g_strdup(mntDir); =20 /* If it is a co-mount it has a filename like "cpu,cpuacct" * and we must identify the symlink path */ @@ -359,9 +352,7 @@ virCgroupV1DetectPlacement(virCgroupPtr group, * selfpath =3D=3D "/libvirt.service" + path =3D=3D "foo" -> "= /libvirt.service/foo" */ if (i =3D=3D VIR_CGROUP_CONTROLLER_SYSTEMD) { - if (VIR_STRDUP(group->legacy[i].placement, - selfpath) < 0) - return -1; + group->legacy[i].placement =3D g_strdup(selfpath); } else { if (virAsprintf(&group->legacy[i].placement, "%s%s%s", selfpath, @@ -1791,12 +1782,14 @@ virCgroupV1AllowDevice(virCgroupPtr group, g_autofree char *majorstr =3D NULL; g_autofree char *minorstr =3D NULL; =20 - if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) || - (major >=3D 0 && virAsprintf(&majorstr, "%i", major) < 0)) + if (major < 0) + majorstr =3D g_strdup("*"); + if (major >=3D 0 && virAsprintf(&majorstr, "%i", major) < 0) return -1; =20 - if ((minor < 0 && VIR_STRDUP(minorstr, "*") < 0) || - (minor >=3D 0 && virAsprintf(&minorstr, "%i", minor) < 0)) + if (minor < 0) + minorstr =3D g_strdup("*"); + if (minor >=3D 0 && virAsprintf(&minorstr, "%i", minor) < 0) return -1; =20 if (virAsprintf(&devstr, "%c %s:%s %s", type, majorstr, minorstr, @@ -1824,12 +1817,14 @@ virCgroupV1DenyDevice(virCgroupPtr group, g_autofree char *majorstr =3D NULL; g_autofree char *minorstr =3D NULL; =20 - if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) || - (major >=3D 0 && virAsprintf(&majorstr, "%i", major) < 0)) + if (major < 0) + majorstr =3D g_strdup("*"); + if (major >=3D 0 && virAsprintf(&majorstr, "%i", major) < 0) return -1; =20 - if ((minor < 0 && VIR_STRDUP(minorstr, "*") < 0) || - (minor >=3D 0 && virAsprintf(&minorstr, "%i", minor) < 0)) + if (minor < 0) + minorstr =3D g_strdup("*"); + if (minor >=3D 0 && virAsprintf(&minorstr, "%i", minor) < 0) return -1; =20 if (virAsprintf(&devstr, "%c %s:%s %s", type, majorstr, minorstr, diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 7a64e74c3a..e976a8d241 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -159,8 +159,7 @@ virCgroupV2CopyPlacement(virCgroupPtr group, VIR_DEBUG("group=3D%p path=3D%s parent=3D%p", group, path, parent); =20 if (path[0] =3D=3D '/') { - if (VIR_STRDUP(group->unified.placement, path) < 0) - return -1; + group->unified.placement =3D g_strdup(path); } else { /* * parent =3D=3D "/" + path=3D"" =3D> "/" --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576348; cv=none; d=zoho.com; s=zohoarc; b=m3DzOvWDN88HRKvxr9IkySq9FR4kvgTWQ3SW80ME/vGaEwnclOUFEEvYsVrRGuAubaR5OAMoiHdKgJVVEWQJnreawsVK8d4j+FlincnAoIzt6bl6IYKzH9mCiOOWMTgqIIz3tOLqrYdP7LSEm6FfFytELaUxRl8YOVWHPLIaDvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576348; 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=tGyzDfKfw74QeRV368bsjceV69ogdlBZwc8LEc1GmIU=; b=QEwFUGpN/4kx7TTNE8gvUVv2LpPibjvBzuBT/uX5r1sOCOz7q5/ZjATrWVEvSWn2YlGyFzhx3f7nZR+PgnKA83AwpKYDov7uMGhmwB/vBUdEpFiePCYXEdbFN3MUbVUa3ahtJFhnfVk15jASOajLWLGUDN/Peo1rahNB/Zs+dBs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576348983989.1987836846697; Sun, 20 Oct 2019 05:59:08 -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-110-zOs_syFcOtOKeJOEMMIiLQ-1; Sun, 20 Oct 2019 08:56:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7D7460D; Sun, 20 Oct 2019 12:56:36 +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 B10E7100EBDF; Sun, 20 Oct 2019 12:56:36 +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 7053D1803B56; Sun, 20 Oct 2019 12:56:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCuBbL023622 for ; Sun, 20 Oct 2019 08:56:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id D8AC690B3; Sun, 20 Oct 2019 12:56:11 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 136553DA3 for ; Sun, 20 Oct 2019 12:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576347; 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=tGyzDfKfw74QeRV368bsjceV69ogdlBZwc8LEc1GmIU=; b=hQTJ9spJAluDdEvcZzXZqzjTdN3WC7EGl1d+60FGIr+AGMJStnnqfZ8Ax4ynJGMH+G91mA d9w8EVnW7elT40HN2JSnMIrd7tknQdpvsB6B9XOGYpVNMAGxUOZ9i5V28LGXO8rKzmmoAb dyDAOGjPK8FHrfOkVXcFzGCzzJYWT78= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 30/34] util: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: zOs_syFcOtOKeJOEMMIiLQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/util/virarptable.c | 6 ++--- src/util/virauth.c | 12 +++------ src/util/virauthconfig.c | 6 ++--- src/util/vircommand.c | 44 ++++++++------------------------ src/util/virconf.c | 30 +++++----------------- src/util/virdbus.c | 9 +++---- src/util/virdnsmasq.c | 13 +++------- src/util/virerror.c | 12 +++------ src/util/virfcp.c | 3 +-- src/util/virfdstream.c | 10 +++----- src/util/virfile.c | 40 ++++++++++------------------- src/util/virfilecache.c | 6 ++--- src/util/virfirewall.c | 3 +-- src/util/virfirmware.c | 10 +++----- src/util/virhostdev.c | 3 +-- src/util/virhostmem.c | 3 +-- src/util/viriscsi.c | 6 ++--- src/util/virjson.c | 13 +++------- src/util/virlease.c | 3 +-- src/util/virlockspace.c | 19 ++++---------- src/util/virlog.c | 11 +++----- src/util/virmdev.c | 9 +++---- src/util/virnetdevmacvlan.c | 12 +++------ src/util/virnetdevopenvswitch.c | 3 +-- src/util/virnetdevtap.c | 6 ++--- src/util/virnetdevvportprofile.c | 5 +--- src/util/virobject.c | 3 +-- src/util/virpci.c | 26 ++++++------------- src/util/virportallocator.c | 8 +----- src/util/virresctrl.c | 6 ++--- src/util/virrotatingfile.c | 9 +++---- src/util/virscsi.c | 5 ++-- src/util/virscsivhost.c | 13 +++------- src/util/virseclabel.c | 19 ++++++-------- src/util/virsecret.c | 3 +-- src/util/virsocketaddr.c | 6 ++--- src/util/virstring.c | 14 +++++----- src/util/virsysinfo.c | 6 ++--- src/util/virsystemd.c | 3 +-- src/util/virtypedparam-public.c | 6 ++--- src/util/virtypedparam.c | 22 +++++----------- src/util/viruri.c | 22 ++++++---------- src/util/virusb.c | 6 ++--- src/util/virutil.c | 25 +++++++++--------- src/util/virxml.c | 3 +-- 45 files changed, 162 insertions(+), 340 deletions(-) diff --git a/src/util/virarptable.c b/src/util/virarptable.c index cc676a0200..265f60d645 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -127,8 +127,7 @@ virArpTableGet(void) virAddr.data.inet4.sin_addr =3D *(struct in_addr *)addr; ipstr =3D virSocketAddrFormat(&virAddr); =20 - if (VIR_STRDUP(table->t[num].ipaddr, ipstr) < 0) - goto cleanup; + table->t[num].ipaddr =3D g_strdup(ipstr); } =20 if (tb[NDA_LLADDR]) { @@ -140,8 +139,7 @@ virArpTableGet(void) =20 virMacAddrFormat(&macaddr, ifmac); =20 - if (VIR_STRDUP(table->t[num].mac, ifmac) < 0) - goto cleanup; + table->t[num].mac =3D g_strdup(ifmac); =20 num++; } diff --git a/src/util/virauth.c b/src/util/virauth.c index 979cb5773e..ddb46cc498 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -51,8 +51,7 @@ virAuthGetConfigFilePathURI(virURIPtr uri, =20 if (authenv) { VIR_DEBUG("Using path from env '%s'", authenv); - if (VIR_STRDUP(*path, authenv) < 0) - return -1; + *path =3D g_strdup(authenv); return 0; } =20 @@ -61,8 +60,7 @@ virAuthGetConfigFilePathURI(virURIPtr uri, if (STREQ_NULLABLE(uri->params[i].name, "authfile") && uri->params[i].value) { VIR_DEBUG("Using path from URI '%s'", uri->params[i].value= ); - if (VIR_STRDUP(*path, uri->params[i].value) < 0) - return -1; + *path =3D g_strdup(uri->params[i].value); return 0; } } @@ -80,8 +78,7 @@ virAuthGetConfigFilePathURI(virURIPtr uri, =20 VIR_FREE(*path); =20 - if (VIR_STRDUP(*path, SYSCONFDIR "/libvirt/auth.conf") < 0) - return -1; + *path =3D g_strdup(SYSCONFDIR "/libvirt/auth.conf"); =20 VIR_DEBUG("Checking for readability of '%s'", *path); if (access(*path, R_OK) =3D=3D 0) @@ -129,8 +126,7 @@ virAuthGetCredential(const char *servicename, &tmp) < 0) return -1; =20 - if (VIR_STRDUP(*value, tmp) < 0) - return -1; + *value =3D g_strdup(tmp); =20 return 0; } diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 9e55852cd4..6a9001f2d8 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -44,8 +44,7 @@ virAuthConfigPtr virAuthConfigNew(const char *path) if (VIR_ALLOC(auth) < 0) goto error; =20 - if (VIR_STRDUP(auth->path, path) < 0) - goto error; + auth->path =3D g_strdup(path); =20 if (!(auth->keyfile =3D virKeyFileNew())) goto error; @@ -70,8 +69,7 @@ virAuthConfigPtr virAuthConfigNewData(const char *path, if (VIR_ALLOC(auth) < 0) goto error; =20 - if (VIR_STRDUP(auth->path, path) < 0) - goto error; + auth->path =3D g_strdup(path); =20 if (!(auth->keyfile =3D virKeyFileNew())) goto error; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 93b3dd218f..223a2a824e 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1061,8 +1061,7 @@ virCommandSetPidFile(virCommandPtr cmd, const char *p= idfile) return; =20 VIR_FREE(cmd->pidfile); - if (VIR_STRDUP_QUIET(cmd->pidfile, pidfile) < 0) - cmd->has_error =3D ENOMEM; + cmd->pidfile =3D g_strdup(pidfile); } =20 =20 @@ -1194,8 +1193,7 @@ virCommandSetSELinuxLabel(virCommandPtr cmd, =20 #if defined(WITH_SECDRIVER_SELINUX) VIR_FREE(cmd->seLinuxLabel); - if (VIR_STRDUP_QUIET(cmd->seLinuxLabel, label) < 0) - cmd->has_error =3D ENOMEM; + cmd->seLinuxLabel =3D g_strdup(label); #endif return; } @@ -1219,8 +1217,7 @@ virCommandSetAppArmorProfile(virCommandPtr cmd, =20 #if defined(WITH_SECDRIVER_APPARMOR) VIR_FREE(cmd->appArmorProfile); - if (VIR_STRDUP_QUIET(cmd->appArmorProfile, profile) < 0) - cmd->has_error =3D ENOMEM; + cmd->appArmorProfile =3D g_strdup(profile); #endif return; } @@ -1369,10 +1366,7 @@ virCommandAddEnvString(virCommandPtr cmd, const char= *str) if (!cmd || cmd->has_error) return; =20 - if (VIR_STRDUP_QUIET(env, str) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + env =3D g_strdup(str); =20 virCommandAddEnv(cmd, env); } @@ -1501,10 +1495,7 @@ virCommandAddArg(virCommandPtr cmd, const char *val) return; } =20 - if (VIR_STRDUP_QUIET(arg, val) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + arg =3D g_strdup(val); =20 /* Arg plus trailing NULL. */ if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) { @@ -1542,12 +1533,8 @@ virCommandAddArgBuffer(virCommandPtr cmd, virBufferP= tr buf) } =20 cmd->args[cmd->nargs] =3D virBufferContentAndReset(buf); - if (!cmd->args[cmd->nargs]) { - if (VIR_STRDUP_QUIET(cmd->args[cmd->nargs], "") < 0) { - cmd->has_error =3D ENOMEM; - return; - } - } + if (!cmd->args[cmd->nargs]) + cmd->args[cmd->nargs] =3D g_strdup(""); cmd->nargs++; } =20 @@ -1638,10 +1625,7 @@ virCommandAddArgSet(virCommandPtr cmd, const char *c= onst*vals) while (vals[narg] !=3D NULL) { char *arg; =20 - if (VIR_STRDUP_QUIET(arg, vals[narg++]) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + arg =3D g_strdup(vals[narg++]); cmd->args[cmd->nargs++] =3D arg; } } @@ -1678,11 +1662,7 @@ virCommandAddArgList(virCommandPtr cmd, ...) char *arg =3D va_arg(list, char *); if (!arg) break; - if (VIR_STRDUP_QUIET(arg, arg) < 0) { - cmd->has_error =3D ENOMEM; - va_end(list); - return; - } + arg =3D g_strdup(arg); cmd->args[cmd->nargs++] =3D arg; } va_end(list); @@ -1707,8 +1687,7 @@ virCommandSetWorkingDirectory(virCommandPtr cmd, cons= t char *pwd) cmd->has_error =3D -1; VIR_DEBUG("cannot set directory twice"); } else { - if (VIR_STRDUP_QUIET(cmd->pwd, pwd) < 0) - cmd->has_error =3D ENOMEM; + cmd->pwd =3D g_strdup(pwd); } } =20 @@ -1869,8 +1848,7 @@ virCommandSetInputBuffer(virCommandPtr cmd, const cha= r *inbuf) return; } =20 - if (VIR_STRDUP_QUIET(cmd->inbuf, inbuf) < 0) - cmd->has_error =3D ENOMEM; + cmd->inbuf =3D g_strdup(inbuf); } =20 =20 diff --git a/src/util/virconf.c b/src/util/virconf.c index 6f7bf3be8e..3b678015f5 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -187,10 +187,7 @@ virConfCreate(const char *filename, unsigned int flags) if (!ret) return NULL; =20 - if (VIR_STRDUP(ret->filename, filename) < 0) { - VIR_FREE(ret); - return NULL; - } + ret->filename =3D g_strdup(filename); =20 ret->flags =3D flags; return ret; @@ -905,8 +902,7 @@ int virConfGetValueString(virConfPtr conf, } =20 VIR_FREE(*value); - if (VIR_STRDUP(*value, cval->str) < 0) - return -1; + *value =3D g_strdup(cval->str); =20 return 1; } @@ -964,24 +960,16 @@ int virConfGetValueStringList(virConfPtr conf, if (VIR_ALLOC_N(*values, len + 1) < 0) return -1; =20 - for (len =3D 0, eval =3D cval->list; eval; len++, eval =3D eval->n= ext) { - if (VIR_STRDUP((*values)[len], eval->str) < 0) { - virStringListFree(*values); - *values =3D NULL; - return -1; - } - } + for (len =3D 0, eval =3D cval->list; eval; len++, eval =3D eval->n= ext) + (*values)[len] =3D g_strdup(eval->str); break; =20 case VIR_CONF_STRING: if (compatString) { if (VIR_ALLOC_N(*values, cval->str ? 2 : 1) < 0) return -1; - if (cval->str && - VIR_STRDUP((*values)[0], cval->str) < 0) { - VIR_FREE(*values); - return -1; - } + if (cval->str) + (*values)[0] =3D g_strdup(cval->str); break; } G_GNUC_FALLTHROUGH; @@ -1383,11 +1371,7 @@ virConfSetValue(virConfPtr conf, return -1; } cur->comment =3D NULL; - if (VIR_STRDUP(cur->name, setting) < 0) { - virConfFreeValue(value); - VIR_FREE(cur); - return -1; - } + cur->name =3D g_strdup(setting); cur->value =3D value; if (prev) { cur->next =3D prev->next; diff --git a/src/util/virdbus.c b/src/util/virdbus.c index f54c917c03..89c9cb3e24 100644 --- a/src/util/virdbus.c +++ b/src/util/virdbus.c @@ -1010,8 +1010,7 @@ virDBusMessageIterDecode(DBusMessageIter *rootiter, } char *s; dbus_message_iter_get_basic(iter, &s); - if (VIR_STRDUP(*x, s) < 0) - goto cleanup; + *x =3D g_strdup(s); VIR_DEBUG("Read basic type 'char *' varg 'char **'" "' val '%s'", *x); } while (0); @@ -1573,10 +1572,8 @@ virDBusCall(DBusConnection *conn, error->level =3D VIR_ERR_ERROR; error->code =3D VIR_ERR_DBUS_SERVICE; error->domain =3D VIR_FROM_DBUS; - if (VIR_STRDUP(error->message, localerror.message) < 0) - goto cleanup; - if (VIR_STRDUP(error->str1, localerror.name) < 0) - goto cleanup; + error->message =3D g_strdup(localerror.message); + error->str1 =3D g_strdup(localerror.name); ret =3D 0; } else { virReportError(VIR_ERR_DBUS_SERVICE, _("%s: %s"), member, diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 9aeb7b120d..f22250a07e 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -112,8 +112,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile, if (VIR_ALLOC(addnhostsfile->hosts[idx].hostnames) < 0) goto error; =20 - if (VIR_STRDUP(addnhostsfile->hosts[idx].ip, ipstr) < 0) - goto error; + addnhostsfile->hosts[idx].ip =3D g_strdup(ipstr); =20 addnhostsfile->hosts[idx].nhostnames =3D 0; addnhostsfile->nhosts++; @@ -122,9 +121,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile, if (VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames, addnhostsfile->= hosts[idx].nhostnames + 1) < 0) goto error; =20 - if (VIR_STRDUP(addnhostsfile->hosts[idx].hostnames[addnhostsfile->host= s[idx].nhostnames], - name) < 0) - goto error; + addnhostsfile->hosts[idx].hostnames[addnhostsfile->hosts[idx].nhostnam= es] =3D g_strdup(name); =20 VIR_FREE(ipstr); =20 @@ -467,8 +464,7 @@ dnsmasqContextNew(const char *network_name, if (VIR_ALLOC(ctx) < 0) return NULL; =20 - if (VIR_STRDUP(ctx->config_dir, config_dir) < 0) - goto error; + ctx->config_dir =3D g_strdup(config_dir); =20 if (!(ctx->hostsfile =3D hostsfileNew(network_name, config_dir))) goto error; @@ -786,8 +782,7 @@ dnsmasqCapsNewEmpty(const char *binaryPath) return NULL; if (!(caps->flags =3D virBitmapNew(DNSMASQ_CAPS_LAST))) goto error; - if (VIR_STRDUP(caps->binaryPath, binaryPath ? binaryPath : DNSMASQ) < = 0) - goto error; + caps->binaryPath =3D g_strdup(binaryPath ? binaryPath : DNSMASQ); return caps; =20 error: diff --git a/src/util/virerror.c b/src/util/virerror.c index 512b2bc7fe..f0ef7e337c 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -207,14 +207,10 @@ virCopyError(virErrorPtr from, to->code =3D from->code; to->domain =3D from->domain; to->level =3D from->level; - if (VIR_STRDUP_QUIET(to->message, from->message) < 0) - ret =3D -1; - if (VIR_STRDUP_QUIET(to->str1, from->str1) < 0) - ret =3D -1; - if (VIR_STRDUP_QUIET(to->str2, from->str2) < 0) - ret =3D -1; - if (VIR_STRDUP_QUIET(to->str3, from->str3) < 0) - ret =3D -1; + to->message =3D g_strdup(from->message); + to->str1 =3D g_strdup(from->str1); + to->str2 =3D g_strdup(from->str2); + to->str3 =3D g_strdup(from->str3); to->int1 =3D from->int1; to->int2 =3D from->int2; /* diff --git a/src/util/virfcp.c b/src/util/virfcp.c index 2315b517bd..80773c7c5d 100644 --- a/src/util/virfcp.c +++ b/src/util/virfcp.c @@ -62,8 +62,7 @@ virFCReadRportValue(const char *rport, if ((p =3D strchr(buf, '\n'))) *p =3D '\0'; =20 - if (VIR_STRDUP(*result, buf) < 0) - return -1; + *result =3D g_strdup(buf); =20 return 0; } diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 693f1619b3..719185d992 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -1302,17 +1302,15 @@ virFDStreamOpenFileInternal(virStreamPtr st, if ((oflags & O_ACCMODE) =3D=3D O_RDONLY) { threadData->fdin =3D fd; threadData->fdout =3D pipefds[1]; - if (VIR_STRDUP(threadData->fdinname, path) < 0 || - VIR_STRDUP(threadData->fdoutname, "pipe") < 0) - goto error; + threadData->fdinname =3D g_strdup(path); + threadData->fdoutname =3D g_strdup("pipe"); tmpfd =3D pipefds[0]; threadData->doRead =3D true; } else { threadData->fdin =3D pipefds[0]; threadData->fdout =3D fd; - if (VIR_STRDUP(threadData->fdinname, "pipe") < 0 || - VIR_STRDUP(threadData->fdoutname, path) < 0) - goto error; + threadData->fdinname =3D g_strdup("pipe"); + threadData->fdoutname =3D g_strdup(path); tmpfd =3D pipefds[1]; threadData->doRead =3D false; } diff --git a/src/util/virfile.c b/src/util/virfile.c index 6a26d4838c..c4d544be73 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1578,8 +1578,10 @@ virFileResolveLinkHelper(const char *linkpath, if (lstat(linkpath, &st) < 0) return -1; =20 - if (!S_ISLNK(st.st_mode)) - return VIR_STRDUP_QUIET(*resultpath, linkpath) < 0 ? -1 : 0; + if (!S_ISLNK(st.st_mode)) { + *resultpath =3D g_strdup(linkpath); + return 0; + } } =20 *resultpath =3D virFileCanonicalizePath(linkpath); @@ -1684,9 +1686,7 @@ virFindFileInPath(const char *file) origpath =3D getenv("PATH"); if (!origpath) origpath =3D "/bin:/usr/bin"; - - if (VIR_STRDUP_QUIET(path, origpath) <=3D 0) - return NULL; + path =3D g_strdup(origpath); =20 /* for each path segment, append the file to search for and test for * it. return it if found. @@ -2023,8 +2023,7 @@ virFileGetMountSubtreeImpl(const char *mtabpath, =20 if (VIR_EXPAND_N(mounts, nmounts, nmounts ? 1 : 2) < 0) goto cleanup; - if (VIR_STRDUP(mounts[nmounts - 2], mntent.mnt_dir) < 0) - goto cleanup; + mounts[nmounts - 2] =3D g_strdup(mntent.mnt_dir); } =20 if (mounts) @@ -3070,10 +3069,7 @@ virFileMakePathWithMode(const char *path, { g_autofree char *tmp =3D NULL; =20 - if (VIR_STRDUP(tmp, path) < 0) { - errno =3D ENOMEM; - return -1; - } + tmp =3D g_strdup(path); =20 return virFileMakePathHelper(tmp, mode); } @@ -3087,10 +3083,7 @@ virFileMakeParentPath(const char *path) =20 VIR_DEBUG("path=3D%s", path); =20 - if (VIR_STRDUP(tmp, path) < 0) { - errno =3D ENOMEM; - return -1; - } + tmp =3D g_strdup(path); =20 if ((p =3D strrchr(tmp, '/')) =3D=3D NULL) { errno =3D EINVAL; @@ -3293,8 +3286,7 @@ int virFileAbsPath(const char *path, char **abspath) { if (path[0] =3D=3D '/') { - if (VIR_STRDUP(*abspath, path) < 0) - return -1; + *abspath =3D g_strdup(path); } else { g_autofree char *buf =3D getcwd(NULL, 0); =20 @@ -3317,8 +3309,7 @@ virFileSanitizePath(const char *path) char *cleanpath; int idx =3D 0; =20 - if (VIR_STRDUP(cleanpath, path) < 0) - return NULL; + cleanpath =3D g_strdup(path); =20 /* don't sanitize URIs - rfc3986 states that two slashes may lead to a * different resource, thus removing them would possibly change the pa= th */ @@ -3504,9 +3495,8 @@ virFileIsSharedFixFUSE(const char *path, maxMatching =3D len; VIR_FREE(mntType); VIR_FREE(mntDir); - if (VIR_STRDUP(mntDir, mb.mnt_dir) < 0 || - VIR_STRDUP(mntType, mb.mnt_type) < 0) - goto cleanup; + mntDir =3D g_strdup(mb.mnt_dir); + mntType =3D g_strdup(mb.mnt_type); } } =20 @@ -3540,8 +3530,7 @@ virFileIsSharedFSType(const char *path, int statfs_ret; long long f_type =3D 0; =20 - if (VIR_STRDUP(dirpath, path) < 0) - return -1; + dirpath =3D g_strdup(path); =20 statfs_ret =3D statfs(dirpath, &sb); =20 @@ -3712,8 +3701,7 @@ virFileFindHugeTLBFS(virHugeTLBFSPtr *ret_fs, =20 tmp =3D &fs[nfs - 1]; =20 - if (VIR_STRDUP(tmp->mnt_dir, mb.mnt_dir) < 0) - goto cleanup; + tmp->mnt_dir =3D g_strdup(mb.mnt_dir); =20 if (virFileGetHugepageSize(tmp->mnt_dir, &tmp->size) < 0) goto cleanup; diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index 3a99dc210b..8ab37bae4a 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -245,11 +245,9 @@ virFileCacheNew(const char *dir, if (!(cache->table =3D virHashCreate(10, virObjectFreeHashData))) goto cleanup; =20 - if (VIR_STRDUP(cache->dir, dir) < 0) - goto cleanup; + cache->dir =3D g_strdup(dir); =20 - if (VIR_STRDUP(cache->suffix, suffix) < 0) - goto cleanup; + cache->suffix =3D g_strdup(suffix); =20 cache->handlers =3D *handlers; =20 diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index c2e88ec382..fc2c7248cb 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -323,8 +323,7 @@ void virFirewallFree(virFirewallPtr firewall) rule->argsLen, 1) < 0) \ goto no_memory; \ \ - if (VIR_STRDUP(rule->args[rule->argsLen++], str) < 0) \ - goto no_memory; \ + rule->args[rule->argsLen++] =3D g_strdup(str); \ } while (0) =20 static virFirewallRulePtr diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c index b4747bd346..9a0610c647 100644 --- a/src/util/virfirmware.c +++ b/src/util/virfirmware.c @@ -79,9 +79,8 @@ virFirmwareParse(const char *str, virFirmwarePtr firmware) goto cleanup; } =20 - if (VIR_STRDUP(firmware->name, token[0]) < 0 || - VIR_STRDUP(firmware->nvram, token[1]) < 0) - goto cleanup; + firmware->name =3D g_strdup(token[0]); + firmware->nvram =3D g_strdup(token[1]); =20 ret =3D 0; cleanup: @@ -122,9 +121,8 @@ virFirmwareParseList(const char *list, =20 if (VIR_ALLOC(fws[j]) < 0) goto cleanup; - if (VIR_STRDUP(fws[j]->name, token[2 * j]) < 0 || - VIR_STRDUP(fws[j]->nvram, token[2 * j + 1]) < 0) - goto cleanup; + fws[j]->name =3D g_strdup(token[2 * j]); + fws[j]->nvram =3D g_strdup(token[2 * j + 1]); } } =20 diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 6b29bb1a73..6633b48805 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -169,8 +169,7 @@ virHostdevManagerNew(void) return NULL; =20 if (privileged) { - if (VIR_STRDUP(hostdevMgr->stateDir, HOSTDEV_STATE_DIR) < 0) - return NULL; + hostdevMgr->stateDir =3D g_strdup(HOSTDEV_STATE_DIR); =20 if (virFileMakePath(hostdevMgr->stateDir) < 0) { virReportError(VIR_ERR_OPERATION_FAILED, diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c index 938e2fa6b3..c1dfc1225c 100644 --- a/src/util/virhostmem.c +++ b/src/util/virhostmem.c @@ -268,8 +268,7 @@ virHostMemGetStats(int cellNum G_GNUC_UNUSED, cellNum =3D VIR_NODE_MEMORY_STATS_ALL_CELLS; =20 if (cellNum =3D=3D VIR_NODE_MEMORY_STATS_ALL_CELLS) { - if (VIR_STRDUP(meminfo_path, MEMINFO_PATH) < 0) - return -1; + meminfo_path =3D g_strdup(MEMINFO_PATH); } else { if ((max_node =3D virNumaGetMaxNode()) < 0) return -1; diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index 1b143ec61f..ba90c41763 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -176,8 +176,7 @@ virStorageBackendIQNFound(const char *initiatoriqn, current =3D next + 1; } =20 - if (VIR_STRDUP(iqn, current) < 0) - goto cleanup; + iqn =3D g_strdup(current); =20 if (STREQ(iqn, initiatoriqn)) { *ifacename =3D g_steal_pointer(&iface); @@ -373,8 +372,7 @@ virISCSIGetTargets(char **const groups, struct virISCSITargetList *list =3D data; g_autofree char *target =3D NULL; =20 - if (VIR_STRDUP(target, groups[1]) < 0) - return -1; + target =3D g_strdup(groups[1]); =20 if (VIR_APPEND_ELEMENT(list->targets, list->ntargets, target) < 0) return -1; diff --git a/src/util/virjson.c b/src/util/virjson.c index d3e6c9e41d..eb6207f13f 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -450,10 +450,7 @@ virJSONValueNewString(const char *data) return NULL; =20 val->type =3D VIR_JSON_TYPE_STRING; - if (VIR_STRDUP(val->data.string, data) < 0) { - VIR_FREE(val); - return NULL; - } + val->data.string =3D g_strdup(data); =20 return val; } @@ -490,10 +487,7 @@ virJSONValueNewNumber(const char *data) return NULL; =20 val->type =3D VIR_JSON_TYPE_NUMBER; - if (VIR_STRDUP(val->data.number, data) < 0) { - VIR_FREE(val); - return NULL; - } + val->data.number =3D g_strdup(data); =20 return val; } @@ -626,8 +620,7 @@ virJSONValueObjectInsert(virJSONValuePtr object, return -1; } =20 - if (VIR_STRDUP(pair.key, key) < 0) - return -1; + pair.key =3D g_strdup(key); =20 if (prepend) { ret =3D VIR_INSERT_ELEMENT(object->data.object.pairs, 0, diff --git a/src/util/virlease.c b/src/util/virlease.c index 3d851eb808..e0f81539be 100644 --- a/src/util/virlease.c +++ b/src/util/virlease.c @@ -221,8 +221,7 @@ virLeaseNew(virJSONValuePtr *lease_ret, return 0; =20 if (exptime_tmp) { - if (VIR_STRDUP(exptime, exptime_tmp) < 0) - return -1; + exptime =3D g_strdup(exptime_tmp); =20 /* Removed extraneous trailing space in DNSMASQ_LEASE_EXPIRES * (dnsmasq < 2.52) */ diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index d383746183..b0f73c2a8a 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -127,8 +127,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace, res->fd =3D -1; res->flags =3D flags; =20 - if (VIR_STRDUP(res->name, resname) < 0) - goto error; + res->name =3D g_strdup(resname); =20 if (!(res->path =3D virLockSpaceGetResourcePath(lockspace, resname))) goto error; @@ -255,8 +254,7 @@ virLockSpacePtr virLockSpaceNew(const char *directory) return NULL; } =20 - if (VIR_STRDUP(lockspace->dir, directory) < 0) - goto error; + lockspace->dir =3D g_strdup(directory); =20 if (!(lockspace->resources =3D virHashCreate(VIR_LOCKSPACE_TABLE_SIZE, virLockSpaceResourceDataFre= e))) @@ -313,8 +311,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONV= aluePtr object) =20 if (virJSONValueObjectHasKey(object, "directory")) { const char *dir =3D virJSONValueObjectGetString(object, "directory= "); - if (VIR_STRDUP(lockspace->dir, dir) < 0) - goto error; + lockspace->dir =3D g_strdup(dir); } =20 if (!(resources =3D virJSONValueObjectGet(object, "resources"))) { @@ -347,10 +344,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSON= ValuePtr object) virLockSpaceResourceFree(res); goto error; } - if (VIR_STRDUP(res->name, tmp) < 0) { - virLockSpaceResourceFree(res); - goto error; - } + res->name =3D g_strdup(tmp); =20 if (!(tmp =3D virJSONValueObjectGetString(child, "path"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -358,10 +352,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSON= ValuePtr object) virLockSpaceResourceFree(res); goto error; } - if (VIR_STRDUP(res->path, tmp) < 0) { - virLockSpaceResourceFree(res); - goto error; - } + res->path =3D g_strdup(tmp); if (virJSONValueObjectGetNumberInt(child, "fd", &res->fd) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing resource fd in JSON document")); diff --git a/src/util/virlog.c b/src/util/virlog.c index 2ce094f6aa..27843363e7 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -840,8 +840,7 @@ virLogNewOutputToSyslog(virLogPriority priority, * rather than copying @ident, syslog uses caller's reference inst= ead */ VIR_FREE(current_ident); - if (VIR_STRDUP(current_ident, ident) < 0) - return NULL; + current_ident =3D g_strdup(ident); =20 openlog(current_ident, 0, 0); } @@ -1331,8 +1330,7 @@ virLogOutputNew(virLogOutputFunc f, return NULL; } =20 - if (VIR_STRDUP(ndup, name) < 0) - return NULL; + ndup =3D g_strdup(name); } =20 if (VIR_ALLOC(ret) < 0) { @@ -1466,10 +1464,7 @@ virLogDefineOutputs(virLogOutputPtr *outputs, size_t= noutputs) * holding the lock so it's safe to call openlog and change the me= ssage * tag */ - if (VIR_STRDUP_QUIET(tmp, outputs[id]->name) < 0) { - virLogUnlock(); - return -1; - } + tmp =3D g_strdup(outputs[id]->name); VIR_FREE(current_ident); current_ident =3D tmp; openlog(current_ident, 0, 0); diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 7e70ceb658..9f8cb95423 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -271,10 +271,8 @@ virMediatedDeviceSetUsedBy(virMediatedDevicePtr dev, { VIR_FREE(dev->used_by_drvname); VIR_FREE(dev->used_by_domname); - if (VIR_STRDUP(dev->used_by_drvname, drvname) < 0) - return -1; - if (VIR_STRDUP(dev->used_by_domname, domname) < 0) - return -1; + dev->used_by_drvname =3D g_strdup(drvname); + dev->used_by_domname =3D g_strdup(domname); =20 return 0; } @@ -509,8 +507,7 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath, if (VIR_ALLOC(tmp) < 0) return -1; =20 - if (VIR_STRDUP(tmp->id, last_component(sysfspath)) < 0) - return -1; + tmp->id =3D g_strdup(last_component(sysfspath)); =20 /* @name sysfs attribute is optional, so getting ENOENT is fine */ MDEV_GET_SYSFS_ATTR("name", &tmp->name, virFileReadValueString, true); diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 4c388b6c55..2ccd83d1bb 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -836,14 +836,12 @@ virNetDevMacVLanVPortProfileRegisterCallback(const ch= ar *ifname, if (virtPortProfile && virNetlinkEventServiceIsRunning(NETLINK_ROUTE))= { if (VIR_ALLOC(calld) < 0) goto error; - if (VIR_STRDUP(calld->cr_ifname, ifname) < 0) - goto error; + calld->cr_ifname =3D g_strdup(ifname); if (VIR_ALLOC(calld->virtPortProfile) < 0) goto error; memcpy(calld->virtPortProfile, virtPortProfile, sizeof(*virtPortPr= ofile)); virMacAddrSet(&calld->macaddress, macaddress); - if (VIR_STRDUP(calld->linkdev, linkdev) < 0) - goto error; + calld->linkdev =3D g_strdup(linkdev); memcpy(calld->vmuuid, vmuuid, sizeof(calld->vmuuid)); =20 calld->vmOp =3D vmOp; @@ -1044,11 +1042,9 @@ virNetDevMacVLanCreateWithVPortProfile(const char *i= fnameRequested, if (virNetDevMacVLanTapSetup(tapfd, tapfdSize, vnet_hdr) < 0) goto disassociate_exit; =20 - if (VIR_STRDUP(*ifnameResult, ifnameCreated) < 0) - goto disassociate_exit; + *ifnameResult =3D g_strdup(ifnameCreated); } else { - if (VIR_STRDUP(*ifnameResult, ifnameCreated) < 0) - goto disassociate_exit; + *ifnameResult =3D g_strdup(ifnameCreated); } =20 if (vmOp =3D=3D VIR_NETDEV_VPORT_PROFILE_OP_CREATE || diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 6e13c0f684..1d2bbf9dd7 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -529,8 +529,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, goto cleanup; } =20 - if (VIR_STRDUP(*ifname, tmpIfname) < 0) - goto cleanup; + *ifname =3D g_strdup(tmpIfname); ret =3D 1; =20 cleanup: diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 8ca4626a90..fe4f55f8fc 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -73,7 +73,8 @@ virNetDevTapGetName(int tapfd G_GNUC_UNUSED, char **ifnam= e G_GNUC_UNUSED) return -1; } =20 - return VIR_STRDUP(*ifname, ifr.ifr_name) < 0 ? -1 : 0; + *ifname =3D g_strdup(ifr.ifr_name); + return 0; #else return -1; #endif @@ -282,8 +283,7 @@ int virNetDevTapCreate(char **ifname, /* In case we are looping more than once, set other * TAPs to have the same name */ VIR_FREE(*ifname); - if (VIR_STRDUP(*ifname, ifr.ifr_name) < 0) - goto cleanup; + *ifname =3D g_strdup(ifr.ifr_name); } =20 if ((flags & VIR_NETDEV_TAP_CREATE_PERSIST) && diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprof= ile.c index b001aea3ec..6442c2a2cf 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -1145,10 +1145,7 @@ virNetDevVPortProfileOp8021Qbh(const char *ifname, goto cleanup; } } else { - if (VIR_STRDUP(physfndev, ifname) < 0) { - rc =3D -1; - goto cleanup; - } + physfndev =3D g_strdup(ifname); } =20 rc =3D virNetDevGetIndex(physfndev, &ifindex); diff --git a/src/util/virobject.c b/src/util/virobject.c index c5363308d8..812b013e72 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -188,8 +188,7 @@ virClassNew(virClassPtr parent, _("too many object classes defined")); goto error; } - if (VIR_STRDUP(klass->name, name) < 0) - goto error; + klass->name =3D g_strdup(name); klass->objectSize =3D objectSize; klass->dispose =3D dispose; =20 diff --git a/src/util/virpci.c b/src/util/virpci.c index 59a93a5e81..f9e39e79d8 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -265,8 +265,7 @@ virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, c= har **path, char **name) } /* path =3D "/sys/bus/pci/drivers/${drivername}" */ =20 - if (VIR_STRDUP(*name, last_component(*path)) < 0) - goto cleanup; + *name =3D g_strdup(last_component(*path)); /* name =3D "${drivername}" */ =20 ret =3D 0; @@ -1435,17 +1434,11 @@ virPCIDeviceCopy(virPCIDevicePtr dev) *copy =3D *dev; copy->path =3D NULL; copy->used_by_drvname =3D copy->used_by_domname =3D NULL; - if (VIR_STRDUP(copy->name, dev->name) < 0 || - VIR_STRDUP(copy->path, dev->path) < 0 || - VIR_STRDUP(copy->used_by_drvname, dev->used_by_drvname) < 0 || - VIR_STRDUP(copy->used_by_domname, dev->used_by_domname) < 0) { - goto error; - } + copy->name =3D g_strdup(dev->name); + copy->path =3D g_strdup(dev->path); + copy->used_by_drvname =3D g_strdup(dev->used_by_drvname); + copy->used_by_domname =3D g_strdup(dev->used_by_domname); return copy; - - error: - virPCIDeviceFree(copy); - return NULL; } =20 =20 @@ -1561,10 +1554,8 @@ virPCIDeviceSetUsedBy(virPCIDevicePtr dev, { VIR_FREE(dev->used_by_drvname); VIR_FREE(dev->used_by_domname); - if (VIR_STRDUP(dev->used_by_drvname, drv_name) < 0) - return -1; - if (VIR_STRDUP(dev->used_by_domname, dom_name) < 0) - return -1; + dev->used_by_drvname =3D g_strdup(drv_name); + dev->used_by_domname =3D g_strdup(dom_name); =20 return 0; } @@ -2503,8 +2494,7 @@ virPCIGetNetName(const char *device_link_sysfs_path, continue; } =20 - if (VIR_STRDUP(*netname, entry->d_name) < 0) - goto cleanup; + *netname =3D g_strdup(entry->d_name); =20 ret =3D 0; break; diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c index 1ffd446f40..494bf9107a 100644 --- a/src/util/virportallocator.c +++ b/src/util/virportallocator.c @@ -111,15 +111,9 @@ virPortAllocatorRangeNew(const char *name, =20 range->start =3D start; range->end =3D end; - - if (VIR_STRDUP(range->name, name) < 0) - goto error; + range->name =3D g_strdup(name); =20 return range; - - error: - virPortAllocatorRangeFree(range); - return NULL; } =20 void diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index e52408ed06..29ea52a16f 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2339,8 +2339,7 @@ virResctrlAllocDeterminePath(virResctrlAllocPtr alloc, =20 /* If the allocation is empty, then the path will be SYSFS_RESCTRL_PAT= H */ if (virResctrlAllocIsEmpty(alloc)) { - if (VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0) - return -1; + alloc->path =3D g_strdup(SYSFS_RESCTRL_PATH); =20 return 0; } @@ -2563,8 +2562,7 @@ virResctrlMonitorDeterminePath(virResctrlMonitorPtr m= onitor, =20 if (!virResctrlAllocIsEmpty(monitor->alloc) && STREQ_NULLABLE(monitor->id, monitor->alloc->id)) { - if (VIR_STRDUP(monitor->path, monitor->alloc->path) < 0) - return -1; + monitor->path =3D g_strdup(monitor->alloc->path); return 0; } =20 diff --git a/src/util/virrotatingfile.c b/src/util/virrotatingfile.c index 1171d3b153..82a677b743 100644 --- a/src/util/virrotatingfile.c +++ b/src/util/virrotatingfile.c @@ -170,8 +170,7 @@ virRotatingFileReaderEntryNew(const char *path) entry->inode =3D sb.st_ino; } =20 - if (VIR_STRDUP(entry->path, path) < 0) - goto error; + entry->path =3D g_strdup(path); =20 return entry; =20 @@ -243,8 +242,7 @@ virRotatingFileWriterNew(const char *path, if (VIR_ALLOC(file) < 0) goto error; =20 - if (VIR_STRDUP(file->basepath, path) < 0) - goto error; + file->basepath =3D g_strdup(path); =20 if (maxbackup > VIR_MAX_MAX_BACKUP) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -389,8 +387,7 @@ virRotatingFileWriterRollover(virRotatingFileWriterPtr = file) =20 for (i =3D file->maxbackup; i > 0; i--) { if (i =3D=3D 1) { - if (VIR_STRDUP(thispath, file->basepath) < 0) - goto cleanup; + thispath =3D g_strdup(file->basepath); } else { if (virAsprintf(&thispath, "%s.%zu", file->basepath, i - 2= ) < 0) goto cleanup; diff --git a/src/util/virscsi.c b/src/util/virscsi.c index af8692eb5b..705571f8ec 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -277,9 +277,8 @@ virSCSIDeviceSetUsedBy(virSCSIDevicePtr dev, =20 if (VIR_ALLOC(copy) < 0) return -1; - if (VIR_STRDUP(copy->drvname, drvname) < 0 || - VIR_STRDUP(copy->domname, domname) < 0) - return -1; + copy->drvname =3D g_strdup(drvname); + copy->domname =3D g_strdup(domname); =20 if (VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy) < 0) return -1; diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c index 0bcd8902a4..5f523636be 100644 --- a/src/util/virscsivhost.c +++ b/src/util/virscsivhost.c @@ -205,10 +205,8 @@ virSCSIVHostDeviceSetUsedBy(virSCSIVHostDevicePtr dev, { VIR_FREE(dev->used_by_drvname); VIR_FREE(dev->used_by_domname); - if (VIR_STRDUP(dev->used_by_drvname, drvname) < 0) - return -1; - if (VIR_STRDUP(dev->used_by_domname, domname) < 0) - return -1; + dev->used_by_drvname =3D g_strdup(drvname); + dev->used_by_domname =3D g_strdup(domname); =20 return 0; } @@ -256,12 +254,7 @@ virSCSIVHostDeviceNew(const char *name) if (VIR_ALLOC(dev) < 0) return NULL; =20 - if (VIR_STRDUP(dev->name, name) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("dev->name buffer overflow: %s"), - name); - return NULL; - } + dev->name =3D g_strdup(name); =20 if (virAsprintf(&dev->path, "%s/%s", SYSFS_VHOST_SCSI_DEVICES, name) < 0) diff --git a/src/util/virseclabel.c b/src/util/virseclabel.c index 02a834223d..a2b5ebf6b7 100644 --- a/src/util/virseclabel.c +++ b/src/util/virseclabel.c @@ -58,12 +58,13 @@ virSecurityLabelDefNew(const char *model) { virSecurityLabelDefPtr seclabel =3D NULL; =20 - if (VIR_ALLOC(seclabel) < 0 || - VIR_STRDUP(seclabel->model, model) < 0) { + if (VIR_ALLOC(seclabel) < 0) { virSecurityLabelDefFree(seclabel); return NULL; } =20 + seclabel->model =3D g_strdup(model); + seclabel->relabel =3D true; =20 return seclabel; @@ -74,12 +75,13 @@ virSecurityDeviceLabelDefNew(const char *model) { virSecurityDeviceLabelDefPtr seclabel =3D NULL; =20 - if (VIR_ALLOC(seclabel) < 0 || - VIR_STRDUP(seclabel->model, model) < 0) { + if (VIR_ALLOC(seclabel) < 0) { virSecurityDeviceLabelDefFree(seclabel); seclabel =3D NULL; } =20 + seclabel->model =3D g_strdup(model); + return seclabel; } =20 @@ -95,13 +97,8 @@ virSecurityDeviceLabelDefCopy(const virSecurityDeviceLab= elDef *src) ret->relabel =3D src->relabel; ret->labelskip =3D src->labelskip; =20 - if (VIR_STRDUP(ret->model, src->model) < 0 || - VIR_STRDUP(ret->label, src->label) < 0) - goto error; + ret->model =3D g_strdup(src->model); + ret->label =3D g_strdup(src->label); =20 return ret; - - error: - virSecurityDeviceLabelDefFree(ret); - return NULL; } diff --git a/src/util/virsecret.c b/src/util/virsecret.c index 7844a76a56..174ce544c0 100644 --- a/src/util/virsecret.c +++ b/src/util/virsecret.c @@ -55,8 +55,7 @@ virSecretLookupDefCopy(virSecretLookupTypeDefPtr dst, if (dst->type =3D=3D VIR_SECRET_LOOKUP_TYPE_UUID) { memcpy(dst->u.uuid, src->u.uuid, VIR_UUID_BUFLEN); } else if (dst->type =3D=3D VIR_SECRET_LOOKUP_TYPE_USAGE) { - if (VIR_STRDUP(dst->u.usage, src->u.usage) < 0) - return -1; + dst->u.usage =3D g_strdup(src->u.usage); } return 0; } diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 91e2a8d558..efe942b44c 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -481,8 +481,7 @@ virSocketAddrFormatFull(const virSocketAddr *addr, separator ? separator : ":") < 0) return NULL; } else { - if (VIR_STRDUP(addrstr, VIR_LOOPBACK_IPV4_ADDR) < 0) - return NULL; + addrstr =3D g_strdup(VIR_LOOPBACK_IPV4_ADDR); } return addrstr; } @@ -515,8 +514,7 @@ virSocketAddrFormatFull(const virSocketAddr *addr, return NULL; } } else { - if (VIR_STRDUP(addrstr, host) < 0) - return NULL; + addrstr =3D g_strdup(host); } =20 return addrstr; diff --git a/src/util/virstring.c b/src/util/virstring.c index fcae16c8fe..1494eab132 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -102,8 +102,7 @@ virStringSplitCount(const char *string, if (VIR_RESIZE_N(tokens, maxtokens, ntokens, 1) < 0) goto error; =20 - if (VIR_STRDUP(tokens[ntokens], remainder) < 0) - goto error; + tokens[ntokens] =3D g_strdup(remainder); ntokens++; } =20 @@ -182,10 +181,11 @@ virStringListAdd(char ***strings, { size_t i =3D virStringListLength((const char **) *strings); =20 - if (VIR_EXPAND_N(*strings, i, 2) < 0 || - VIR_STRDUP((*strings)[i - 2], item) < 0) + if (VIR_EXPAND_N(*strings, i, 2) < 0) return -1; =20 + (*strings)[i - 2] =3D g_strdup(item); + return 0; } =20 @@ -286,10 +286,8 @@ virStringListCopy(char ***dst, if (VIR_ALLOC_N(copy, virStringListLength(src) + 1) < 0) goto error; =20 - for (i =3D 0; src[i]; i++) { - if (VIR_STRDUP(copy[i], src[i]) < 0) - goto error; - } + for (i =3D 0; src[i]; i++) + copy[i] =3D g_strdup(src[i]); =20 *dst =3D copy; return 0; diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index af26e0bab9..0a622dbbf9 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -420,8 +420,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinf= oDefPtr ret) cur, eol - cur) < 0) goto error; =20 - if (VIR_STRDUP(processor->processor_type, processor_type) < 0) - goto error; + processor->processor_type =3D g_strdup(processor_type); =20 base =3D cur; } @@ -558,8 +557,7 @@ virSysinfoParseS390Processor(const char *base, virSysin= foDefPtr ret) if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) goto error; processor =3D &ret->processor[ret->nprocessor - 1]; - if (VIR_STRDUP(processor->processor_manufacturer, manufacturer) < = 0) - goto error; + processor->processor_manufacturer =3D g_strdup(manufacturer); if (!virSysinfoParseS390Delimited(procline, "version", &processor->processor_version, '=3D', ',') || diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index c2e4c3df51..2ff0341b11 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -308,8 +308,7 @@ int virSystemdCreateMachine(const char *name, if (!(slicename =3D virSystemdMakeSliceName(partition))) goto cleanup; } else { - if (VIR_STRDUP(slicename, "") < 0) - goto cleanup; + slicename =3D g_strdup(""); } =20 /* diff --git a/src/util/virtypedparam-public.c b/src/util/virtypedparam-publi= c.c index eaa9f433e7..0ddb618dbf 100644 --- a/src/util/virtypedparam-public.c +++ b/src/util/virtypedparam-public.c @@ -104,8 +104,7 @@ virTypedParameterAssignFromStr(virTypedParameterPtr par= am, } break; case VIR_TYPED_PARAM_STRING: - if (VIR_STRDUP(param->value.s, val) < 0) - return -1; + param->value.s =3D g_strdup(val); break; default: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -736,8 +735,7 @@ virTypedParamsAddString(virTypedParameterPtr *params, goto error; *maxparams =3D max; =20 - if (VIR_STRDUP(str, value) < 0) - goto error; + str =3D g_strdup(value); =20 if (virTypedParameterAssign(*params + n, name, VIR_TYPED_PARAM_STRING, str) < 0) { diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index db440611dc..f50d926860 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -234,8 +234,7 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr = param, break; case VIR_TYPED_PARAM_STRING: if (copystr) { - if (VIR_STRDUP(param->value.s, va_arg(ap, char *)) < 0) - return -1; + param->value.s =3D g_strdup(va_arg(ap, char *)); } else { param->value.s =3D va_arg(ap, char *); } @@ -337,8 +336,7 @@ virTypedParamsReplaceString(virTypedParameterPtr *param= s, param =3D *params + n - 1; } =20 - if (VIR_STRDUP(str, value) < 0) - goto error; + str =3D g_strdup(value); =20 if (virTypedParameterAssign(param, name, VIR_TYPED_PARAM_STRING, str) < 0) { @@ -374,11 +372,7 @@ virTypedParamsCopy(virTypedParameterPtr *dst, ignore_value(virStrcpyStatic((*dst)[i].field, src[i].field)); (*dst)[i].type =3D src[i].type; if (src[i].type =3D=3D VIR_TYPED_PARAM_STRING) { - if (VIR_STRDUP((*dst)[i].value.s, src[i].value.s) < 0) { - virTypedParamsFree(*dst, i - 1); - *dst =3D NULL; - return -1; - } + (*dst)[i].value.s =3D g_strdup(src[i].value.s); } else { (*dst)[i].value =3D src[i].value; } @@ -613,9 +607,7 @@ virTypedParamsDeserialize(virTypedParameterRemotePtr re= mote_params, remote_param->value.remote_typed_param_value.b; break; case VIR_TYPED_PARAM_STRING: - if (VIR_STRDUP(param->value.s, - remote_param->value.remote_typed_param_value.s)= < 0) - goto cleanup; + param->value.s =3D g_strdup(remote_param->value.remote_typed_p= aram_value.s); break; default: virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"), @@ -699,8 +691,7 @@ virTypedParamsSerialize(virTypedParameterPtr params, =20 /* This will be either freed by virNetServerDispatchCall or call(), * depending on the calling side, i.e. server or client */ - if (VIR_STRDUP(val->field, param->field) < 0) - goto cleanup; + val->field =3D g_strdup(param->field); val->value.type =3D param->type; switch (param->type) { case VIR_TYPED_PARAM_INT: @@ -722,8 +713,7 @@ virTypedParamsSerialize(virTypedParameterPtr params, val->value.remote_typed_param_value.b =3D param->value.b; break; case VIR_TYPED_PARAM_STRING: - if (VIR_STRDUP(val->value.remote_typed_param_value.s, param->v= alue.s) < 0) - goto cleanup; + val->value.remote_typed_param_value.s =3D g_strdup(param->valu= e.s); break; default: virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"), diff --git a/src/util/viruri.c b/src/util/viruri.c index af2e828c28..3532fa5576 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -41,8 +41,8 @@ virURIParamAppend(virURIPtr uri, char *pname =3D NULL; char *pvalue =3D NULL; =20 - if (VIR_STRDUP(pname, name) < 0 || VIR_STRDUP(pvalue, value) < 0) - goto error; + pname =3D g_strdup(name); + pvalue =3D g_strdup(value); =20 if (VIR_RESIZE_N(uri->params, uri->paramsAlloc, uri->paramsCount, 1) <= 0) goto error; @@ -167,10 +167,8 @@ virURIParse(const char *uri) if (VIR_ALLOC(ret) < 0) goto error; =20 - if (VIR_STRDUP(ret->scheme, xmluri->scheme) < 0) - goto error; - if (VIR_STRDUP(ret->server, xmluri->server) < 0) - goto error; + ret->scheme =3D g_strdup(xmluri->scheme); + ret->server =3D g_strdup(xmluri->server); /* xmluri->port value is not defined if server was * not given. Modern versions libxml2 fill port * differently to old versions in this case, so @@ -181,14 +179,10 @@ virURIParse(const char *uri) ret->port =3D 0; else ret->port =3D xmluri->port; - if (VIR_STRDUP(ret->path, xmluri->path) < 0) - goto error; - if (VIR_STRDUP(ret->query, xmluri->query_raw) < 0) - goto error; - if (VIR_STRDUP(ret->fragment, xmluri->fragment) < 0) - goto error; - if (VIR_STRDUP(ret->user, xmluri->user) < 0) - goto error; + ret->path =3D g_strdup(xmluri->path); + ret->query =3D g_strdup(xmluri->query_raw); + ret->fragment =3D g_strdup(xmluri->fragment); + ret->user =3D g_strdup(xmluri->user); =20 /* Strip square bracket from an IPv6 address. * The function modifies the string in-place. Even after such diff --git a/src/util/virusb.c b/src/util/virusb.c index 036a7caf79..5a9f369ac1 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -379,10 +379,8 @@ virUSBDeviceSetUsedBy(virUSBDevicePtr dev, { VIR_FREE(dev->used_by_drvname); VIR_FREE(dev->used_by_domname); - if (VIR_STRDUP(dev->used_by_drvname, drv_name) < 0) - return -1; - if (VIR_STRDUP(dev->used_by_domname, dom_name) < 0) - return -1; + dev->used_by_drvname =3D g_strdup(drv_name); + dev->used_by_domname =3D g_strdup(dom_name); =20 return 0; } diff --git a/src/util/virutil.c b/src/util/virutil.c index 63071e2fa6..f2528e257c 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -646,14 +646,14 @@ virGetUserEnt(uid_t uid, char **name, gid_t *group, c= har **dir, char **shell, bo goto cleanup; } =20 - if (name && VIR_STRDUP(*name, pw->pw_name) < 0) - goto cleanup; + if (name) + *name =3D g_strdup(pw->pw_name); if (group) *group =3D pw->pw_gid; - if (dir && VIR_STRDUP(*dir, pw->pw_dir) < 0) - goto cleanup; - if (shell && VIR_STRDUP(*shell, pw->pw_shell) < 0) - goto cleanup; + if (dir) + *dir =3D g_strdup(pw->pw_dir); + if (shell) + *shell =3D g_strdup(pw->pw_shell); =20 ret =3D 0; cleanup: @@ -1094,8 +1094,8 @@ virGetWin32SpecialFolder(int csidl, char **path) *path =3D NULL; =20 if (SHGetSpecialFolderLocation(NULL, csidl, &pidl) =3D=3D S_OK) { - if (SHGetPathFromIDList(pidl, buf) && VIR_STRDUP(*path, buf) < 0) - ret =3D -1; + if (SHGetPathFromIDList(pidl, buf)) + *path =3D g_strdup(buf); CoTaskMemFree(pidl); } return ret; @@ -1123,7 +1123,8 @@ virGetWin32DirectoryRoot(char **path) strcpy(windowsdir, "C:\\"); } =20 - return VIR_STRDUP(*path, windowsdir) < 0 ? -1 : 0; + *path =3D g_strdup(windowsdir); + return 0; } =20 =20 @@ -1159,8 +1160,7 @@ virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED) /* USERPROFILE is probably the closest equivalent to $HOME? */ dir =3D getenv("USERPROFILE"); =20 - if (VIR_STRDUP(ret, dir) < 0) - return NULL; + ret =3D g_strdup(dir); =20 if (!ret && virGetWin32SpecialFolder(CSIDL_PROFILE, &ret) < 0) @@ -1687,8 +1687,7 @@ virParseOwnershipIds(const char *label, uid_t *uidPtr= , gid_t *gidPtr) char *owner =3D NULL; char *group =3D NULL; =20 - if (VIR_STRDUP(tmp_label, label) < 0) - goto cleanup; + tmp_label =3D g_strdup(label); =20 /* Split label */ sep =3D strchr(tmp_label, ':'); diff --git a/src/util/virxml.c b/src/util/virxml.c index 209c83b6cc..f4c9bc89e5 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1260,8 +1260,7 @@ virXMLValidatorInit(const char *schemafile) if (VIR_ALLOC(validator) < 0) return NULL; =20 - if (VIR_STRDUP(validator->schemafile, schemafile) < 0) - goto error; + validator->schemafile =3D g_strdup(schemafile); =20 if (!(validator->rngParser =3D xmlRelaxNGNewParserCtxt(validator->schemafile))) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576300; cv=none; d=zoho.com; s=zohoarc; b=JO95fVlKiMjrZ9WA7Uqyw5k6wMyYNT7Mn3VV6IwuP7h0ZykttVNybGU++0t/HR2v9Px4jNAMwGv2SRw6M5vbwJbIRhj5wVyRidULR26bvPDcGEgwhEjlk2RD1sP0jCx8v+2gPgFkM/MG6R/77zeHzhhKvDqOz1JrDlFELualLZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576300; 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=phrwiikFJr7A/CG+/LTzLUTlIXyyKambpvQWLEUViqQ=; b=MjDdIZ0CmvSZEfEjxbK+TMpK/XrrF46i3zvbHcbPl9aUVBAk1AN2Wyg71EILp078V7AFJVTaud2NhLs+AfnpT0MFMnjRR1x6qnvFDqcbbM0YCNrhzvBKqLXN9XgIyp51mpFWnLC83Qxi6SItn/4dRetCPkU1gCPZHgnGMnOgZ9k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 157157630096492.57731617349748; Sun, 20 Oct 2019 05:58:20 -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-169-vTrH01-mPRKIQMnk-hYL_w-1; Sun, 20 Oct 2019 08:56: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 305855EC; Sun, 20 Oct 2019 12:56:40 +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 EB0F560C4E; Sun, 20 Oct 2019 12:56: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 9B75A3FB49; Sun, 20 Oct 2019 12:56:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCuCCV023635 for ; Sun, 20 Oct 2019 08:56:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id D9C6A3DA3; Sun, 20 Oct 2019 12:56:12 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D3E6194B9 for ; Sun, 20 Oct 2019 12:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576299; 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=phrwiikFJr7A/CG+/LTzLUTlIXyyKambpvQWLEUViqQ=; b=MlTE+Wf8dk6IpgwUdkkOnOyrhUdlmVAJj42+HK60LEbD/40iOml2ETm3fp75N5yT74PfTl hMv3hB0F6bz+rdkbjRpbpLK59Um/94D+d36Gc3DyTDYgikd8lE1lNUAIp4HQLxoDPboA0t oVNnIHFnHSHEstwsqOFvw3ScTlIRlIs= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:49 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 31/34] vbox: use g_strdup instead of VIR_STRDUP 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-MC-Unique: vTrH01-mPRKIQMnk-hYL_w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/vbox/vbox_XPCOMCGlue.c | 3 +- src/vbox/vbox_common.c | 147 ++++++++-------------------------- src/vbox/vbox_network.c | 45 +++++------ src/vbox/vbox_snapshot_conf.c | 15 ++-- src/vbox/vbox_storage.c | 15 ++-- 5 files changed, 67 insertions(+), 158 deletions(-) diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c index 9310cace3e..a20b1c2a36 100644 --- a/src/vbox/vbox_XPCOMCGlue.c +++ b/src/vbox/vbox_XPCOMCGlue.c @@ -96,8 +96,7 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreM= issing, return -1; } } else { - if (VIR_STRDUP(name, DYNLIB_NAME) < 0) - return -1; + name =3D g_strdup(DYNLIB_NAME); } =20 /* diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 94a79bde64..475b3a3147 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1625,23 +1625,13 @@ vboxAttachDisplay(virDomainDefPtr def, vboxDriverPt= r data, IMachine *machine) if ((def->graphics[i]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_DESKTO= P) && (guiPresent =3D=3D 0)) { guiPresent =3D 1; - if (VIR_STRDUP(guiDisplay, def->graphics[i]->data.desktop.disp= lay) < 0) { - /* just don't go to cleanup yet as it is ok to have - * guiDisplay as NULL and we check it below if it - * exist and then only use it there - */ - } + guiDisplay =3D g_strdup(def->graphics[i]->data.desktop.display= ); } =20 if ((def->graphics[i]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SDL) && (sdlPresent =3D=3D 0)) { sdlPresent =3D 1; - if (VIR_STRDUP(sdlDisplay, def->graphics[i]->data.sdl.display)= < 0) { - /* just don't go to cleanup yet as it is ok to have - * sdlDisplay as NULL and we check it below if it - * exist and then only use it there - */ - } + sdlDisplay =3D g_strdup(def->graphics[i]->data.sdl.display); } } =20 @@ -2108,22 +2098,12 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IM= achine *machine, vboxIID *iid =20 if (STREQ(valueTypeUtf8, "sdl")) { sdlPresent =3D 1; - if (VIR_STRDUP(sdlDisplay, valueDisplayUtf8) < 0) { - /* just don't go to cleanup yet as it is ok to have - * sdlDisplay as NULL and we check it below if it - * exist and then only use it there - */ - } + sdlDisplay =3D g_strdup(valueDisplayUtf8); } =20 if (STREQ(valueTypeUtf8, "gui")) { guiPresent =3D 1; - if (VIR_STRDUP(guiDisplay, valueDisplayUtf8) < 0) { - /* just don't go to cleanup yet as it is ok to have - * guiDisplay as NULL and we check it below if it - * exist and then only use it there - */ - } + guiDisplay =3D g_strdup(valueDisplayUtf8); } } =20 @@ -3546,9 +3526,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) goto cleanup; =20 graphics->type =3D VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP; - if (VIR_STRDUP(graphics->data.desktop.display, - getenv("DISPLAY")) < 0) - goto cleanup; + graphics->data.desktop.display =3D g_strdup(getenv("DISPLAY")); } =20 if (graphics && @@ -3641,21 +3619,13 @@ vboxDumpSharedFolders(virDomainDefPtr def, vboxDriv= erPtr data, IMachine *machine =20 gVBoxAPI.UISharedFolder.GetHostPath(sharedFolder, &hostPathUtf16); VBOX_UTF16_TO_UTF8(hostPathUtf16, &hostPath); - if (VIR_STRDUP(def->fss[i]->src->path, hostPath) < 0) { - VBOX_UTF8_FREE(hostPath); - VBOX_UTF16_FREE(hostPathUtf16); - goto cleanup; - } + def->fss[i]->src->path =3D g_strdup(hostPath); VBOX_UTF8_FREE(hostPath); VBOX_UTF16_FREE(hostPathUtf16); =20 gVBoxAPI.UISharedFolder.GetName(sharedFolder, &nameUtf16); VBOX_UTF16_TO_UTF8(nameUtf16, &name); - if (VIR_STRDUP(def->fss[i]->dst, name) < 0) { - VBOX_UTF8_FREE(name); - VBOX_UTF16_FREE(nameUtf16); - goto cleanup; - } + def->fss[i]->dst =3D g_strdup(name); VBOX_UTF8_FREE(name); VBOX_UTF16_FREE(nameUtf16); =20 @@ -3917,8 +3887,7 @@ vboxDumpSerial(virDomainDefPtr def, vboxDriverPtr dat= a, IMachine *machine, PRUin =20 if (pathUtf16) { VBOX_UTF16_TO_UTF8(pathUtf16, &path); - if (VIR_STRDUP(def->serials[serialPortIncCount]->sourc= e->data.file.path, path) < 0) - return -1; + def->serials[serialPortIncCount]->source->data.file.pa= th =3D g_strdup(path); } =20 serialPortIncCount++; @@ -4000,8 +3969,7 @@ vboxDumpParallel(virDomainDefPtr def, vboxDriverPtr d= ata, IMachine *machine, PRU gVBoxAPI.UIParallelPort.GetPath(parallelPort, &pathUtf16); =20 VBOX_UTF16_TO_UTF8(pathUtf16, &path); - if (VIR_STRDUP(def->parallels[parallelPortIncCount]->sourc= e->data.file.path, path) < 0) - return -1; + def->parallels[parallelPortIncCount]->source->data.file.pa= th =3D g_strdup(path); =20 parallelPortIncCount++; =20 @@ -4056,8 +4024,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, u= nsigned int flags) def->virtType =3D VIR_DOMAIN_VIRT_VBOX; def->id =3D dom->id; memcpy(def->uuid, dom->uuid, VIR_UUID_BUFLEN); - if (VIR_STRDUP(def->name, dom->name) < 0) - goto cleanup; + def->name =3D g_strdup(dom->name); =20 gVBoxAPI.UIMachine.GetMemorySize(machine, &memorySize); def->mem.cur_balloon =3D memorySize * 1024; @@ -4218,14 +4185,7 @@ static int vboxConnectListDefinedDomains(virConnectP= tr conn, =20 gVBoxAPI.UIMachine.GetName(machine, &machineNameUtf16); VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName); - if (VIR_STRDUP(names[j], machineName) < 0) { - VBOX_UTF16_FREE(machineNameUtf16); - VBOX_UTF8_FREE(machineName); - for (j =3D 0; j < maxnames; j++) - VIR_FREE(names[j]); - ret =3D -1; - goto cleanup; - } + names[j] =3D g_strdup(machineName); VBOX_UTF16_FREE(machineNameUtf16); VBOX_UTF8_FREE(machineName); j++; @@ -4897,10 +4857,7 @@ vboxSnapshotRedefine(virDomainPtr dom, =20 readOnlyDisk->format =3D format; readOnlyDisk->uuid =3D uuid; - if (VIR_STRDUP(readOnlyDisk->location, def->parent.dom->disks[it]-= >src->path) < 0) { - VIR_FREE(readOnlyDisk); - goto cleanup; - } + readOnlyDisk->location =3D g_strdup(def->parent.dom->disks[it]->sr= c->path); =20 if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readOnlyDisk, sn= apshotMachineDesc->mediaRegistry, parentUuid) < 0) { @@ -4998,23 +4955,18 @@ vboxSnapshotRedefine(virDomainPtr dom, =20 char uuidtmp[VIR_UUID_STRING_BUFLEN]; virUUIDFormat(snapshotUuid, uuidtmp); - if (VIR_STRDUP(newSnapshotPtr->uuid, uuidtmp) < 0) - goto cleanup; + newSnapshotPtr->uuid =3D g_strdup(uuidtmp); =20 VIR_DEBUG("New snapshot UUID: %s", newSnapshotPtr->uuid); - if (VIR_STRDUP(newSnapshotPtr->name, def->parent.name) < 0) - goto cleanup; + newSnapshotPtr->name =3D g_strdup(def->parent.name); =20 newSnapshotPtr->timeStamp =3D virTimeStringThen(def->parent.creationTi= me * 1000); =20 - if (VIR_STRDUP(newSnapshotPtr->description, def->parent.description) <= 0) - goto cleanup; + newSnapshotPtr->description =3D g_strdup(def->parent.description); =20 - if (VIR_STRDUP(newSnapshotPtr->hardware, snapshotMachineDesc->hardware= ) < 0) - goto cleanup; + newSnapshotPtr->hardware =3D g_strdup(snapshotMachineDesc->hardware); =20 - if (VIR_STRDUP(newSnapshotPtr->storageController, snapshotMachineDesc-= >storageController) < 0) - goto cleanup; + newSnapshotPtr->storageController =3D g_strdup(snapshotMachineDesc->st= orageController); =20 /*We get the parent disk uuid from the parent disk location to correct= ly fill the storage controller.*/ for (it =3D 0; it < def->parent.dom->ndisks; it++) { @@ -5045,8 +4997,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VIR_FREE(newSnapshotPtr->storageController); if (!tmp) goto cleanup; - if (VIR_STRDUP(newSnapshotPtr->storageController, tmp) < 0) - goto cleanup; + newSnapshotPtr->storageController =3D g_strdup(tmp); =20 VIR_FREE(tmp); } @@ -5146,10 +5097,7 @@ vboxSnapshotRedefine(virDomainPtr dom, disk->format =3D format; VBOX_UTF16_FREE(formatUtf16); =20 - if (VIR_STRDUP(disk->location, def->disks[it].src->path) < 0) { - VIR_FREE(disk); - goto cleanup; - } + disk->location =3D g_strdup(def->disks[it].src->path); =20 rc =3D gVBoxAPI.UIMedium.GetId(medium, &iid); if (NS_FAILED(rc)) { @@ -5201,8 +5149,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VIR_FREE(snapshotMachineDesc->storageController); if (!tmp) goto cleanup; - if (VIR_STRDUP(snapshotMachineDesc->storageController, tmp= ) < 0) - goto cleanup; + snapshotMachineDesc->storageController =3D g_strdup(tmp); =20 VIR_FREE(tmp); } @@ -5308,8 +5255,7 @@ vboxSnapshotRedefine(virDomainPtr dom, newHardDisk->uuid =3D uuid; vboxIIDUnalloc(&iid); =20 - if (VIR_STRDUP(newHardDisk->location, newLocationUtf8) < 0) - goto cleanup; + newHardDisk->location =3D g_strdup(newLocationUtf8); =20 rc =3D gVBoxAPI.UIMedium.GetFormat(newMedium, &formatUtf16); VBOX_UTF16_TO_UTF8(formatUtf16, &format); @@ -5342,8 +5288,7 @@ vboxSnapshotRedefine(virDomainPtr dom, VIR_FREE(snapshotMachineDesc->storageController); if (!tmp) goto cleanup; - if (VIR_STRDUP(snapshotMachineDesc->storageController, tmp) < = 0) - goto cleanup; + snapshotMachineDesc->storageController =3D g_strdup(tmp); =20 VIR_FREE(tmp); /*Closing the "fake" disk*/ @@ -5922,12 +5867,7 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPt= r def, } VBOX_UTF16_TO_UTF8(childLocUtf16, &childLocUtf8); VBOX_UTF16_FREE(childLocUtf16); - if (VIR_STRDUP(def->disks[diskCount].src->path, childL= ocUtf8) < 0) { - VBOX_RELEASE(storageController); - VBOX_RELEASE(disk); - VBOX_RELEASE(child); - goto cleanup; - } + def->disks[diskCount].src->path =3D g_strdup(childLocU= tf8); VBOX_UTF8_FREE(childLocUtf8); =20 def->disks[diskCount].src->type =3D VIR_STORAGE_TYPE_F= ILE; @@ -6116,8 +6056,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr = def, } VBOX_UTF16_TO_UTF8(mediumLocUtf16, &mediumLocUtf8); VBOX_UTF16_FREE(mediumLocUtf16); - if (VIR_STRDUP(defdom->disks[diskCount]->src->path, mediumLocUtf8)= < 0) - goto cleanup; + defdom->disks[diskCount]->src->path =3D g_strdup(mediumLocUtf8); =20 VBOX_UTF8_FREE(mediumLocUtf8); rc =3D gVBoxAPI.UIMedium.GetReadOnly(disk, &readOnly); @@ -6217,8 +6156,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, !(def->parent.dom =3D virDomainDefNew())) goto cleanup; defdom =3D def->parent.dom; - if (VIR_STRDUP(def->parent.name, snapshot->name) < 0) - goto cleanup; + def->parent.name =3D g_strdup(snapshot->name); =20 if (gVBoxAPI.vboxSnapshotRedefine) { /* Register def->dom properties for them to be saved inside the sn= apshot XMl @@ -6230,8 +6168,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSn= apshotPtr snapshot, defdom->virtType =3D VIR_DOMAIN_VIRT_VBOX; defdom->id =3D dom->id; memcpy(defdom->uuid, dom->uuid, VIR_UUID_BUFLEN); - if (VIR_STRDUP(defdom->name, dom->name) < 0) - goto cleanup; + defdom->name =3D g_strdup(dom->name); gVBoxAPI.UIMachine.GetMemorySize(machine, &memorySize); defdom->mem.cur_balloon =3D memorySize * 1024; /* Currently setting memory and maxMemory as same, cause @@ -6265,10 +6202,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainS= napshotPtr snapshot, if (str16) { VBOX_UTF16_TO_UTF8(str16, &str8); VBOX_UTF16_FREE(str16); - if (VIR_STRDUP(def->parent.description, str8) < 0) { - VBOX_UTF8_FREE(str8); - goto cleanup; - } + def->parent.description =3D g_strdup(str8); VBOX_UTF8_FREE(str8); } =20 @@ -6299,10 +6233,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainS= napshotPtr snapshot, } VBOX_UTF16_TO_UTF8(str16, &str8); VBOX_UTF16_FREE(str16); - if (VIR_STRDUP(def->parent.parent_name, str8) < 0) { - VBOX_UTF8_FREE(str8); - goto cleanup; - } + def->parent.parent_name =3D g_strdup(str8); VBOX_UTF8_FREE(str8); } =20 @@ -6433,10 +6364,7 @@ static int vboxDomainSnapshotListNames(virDomainPtr = dom, char **names, } VBOX_UTF16_TO_UTF8(nameUtf16, &name); VBOX_UTF16_FREE(nameUtf16); - if (VIR_STRDUP(names[i], name) < 0) { - VBOX_UTF8_FREE(name); - goto cleanup; - } + names[i] =3D g_strdup(name); VBOX_UTF8_FREE(name); } =20 @@ -7100,10 +7028,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsh= otPtr snapshot) disk->uuid =3D uuid; vboxIIDUnalloc(&iid); =20 - if (VIR_STRDUP(disk->location, newLocationUtf8) < 0) { - VIR_FREE(disk); - goto cleanup; - } + disk->location =3D g_strdup(newLocationUtf8); =20 rc =3D gVBoxAPI.UIMedium.GetFormat(newMedium, &formatUtf16= ); VBOX_UTF16_TO_UTF8(formatUtf16, &format); @@ -7135,8 +7060,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) VIR_FREE(snapshotMachineDesc->storageController); if (!tmp) goto cleanup; - if (VIR_STRDUP(snapshotMachineDesc->storageController, tmp= ) < 0) - goto cleanup; + snapshotMachineDesc->storageController =3D g_strdup(tmp); =20 VIR_FREE(tmp); /*Closing the "fake" disk*/ @@ -7178,8 +7102,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) VIR_FREE(snapshotMachineDesc->storageController); if (!tmp) goto cleanup; - if (VIR_STRDUP(snapshotMachineDesc->storageController, tmp= ) < 0) - goto cleanup; + snapshotMachineDesc->storageController =3D g_strdup(tmp); =20 VIR_FREE(tmp); } @@ -7289,8 +7212,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) _("Unable to get the snapshot to remove")); goto cleanup; } - if (VIR_STRDUP(snapshotMachineDesc->currentSnapshot, snap->uui= d) < 0) - goto cleanup; + snapshotMachineDesc->currentSnapshot =3D g_strdup(snap->uuid); } } =20 @@ -7528,8 +7450,7 @@ vboxDomainScreenshot(virDomainPtr dom, goto endjob; } =20 - if (VIR_STRDUP(ret, "image/png") < 0) - goto endjob; + ret =3D g_strdup("image/png"); =20 if (virFDStreamOpenFile(st, tmp, 0, 0, O_RDONLY) < 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 814f27155f..9e632ab709 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -132,8 +132,8 @@ static int vboxConnectListNetworks(virConnectPtr conn, = char **const names, int n VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8); =20 VIR_DEBUG("nnames[%d]: %s", ret, nameUtf8); - if (VIR_STRDUP(names[ret], nameUtf8) >=3D 0) - ret++; + names[ret] =3D g_strdup(nameUtf8); + ret++; =20 VBOX_UTF8_FREE(nameUtf8); VBOX_UTF16_FREE(nameUtf16); @@ -234,8 +234,8 @@ static int vboxConnectListDefinedNetworks(virConnectPtr= conn, char **const names VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8); =20 VIR_DEBUG("nnames[%d]: %s", ret, nameUtf8); - if (VIR_STRDUP(names[ret], nameUtf8) >=3D 0) - ret++; + names[ret] =3D g_strdup(nameUtf8); + ret++; =20 VBOX_UTF8_FREE(nameUtf8); VBOX_UTF16_FREE(nameUtf16); @@ -806,8 +806,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr networ= k, unsigned int flags) if (interfaceType !=3D HostNetworkInterfaceType_HostOnly) goto cleanup; =20 - if (VIR_STRDUP(def->name, network->name) < 0) - goto cleanup; + def->name =3D g_strdup(network->name); =20 rc =3D gVBoxAPI.UIHNInterface.GetId(networkInterface, &vboxnet0IID); if (NS_FAILED(rc)) @@ -861,30 +860,26 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr netw= ork, unsigned int flags) =20 ipdef->nhosts =3D 1; if (VIR_ALLOC_N(ipdef->hosts, ipdef->nhosts) >=3D 0) { - if (VIR_STRDUP(ipdef->hosts[0].name, network->name) < 0) { - VIR_FREE(ipdef->hosts); - ipdef->nhosts =3D 0; - } else { - PRUnichar *macAddressUtf16 =3D NULL; - PRUnichar *ipAddressUtf16 =3D NULL; - bool errorOccurred =3D false; + PRUnichar *macAddressUtf16 =3D NULL; + PRUnichar *ipAddressUtf16 =3D NULL; + bool errorOccurred =3D false; =20 - gVBoxAPI.UIHNInterface.GetHardwareAddress(networkInterface= , &macAddressUtf16); - gVBoxAPI.UIHNInterface.GetIPAddress(networkInterface, &ipA= ddressUtf16); + ipdef->hosts[0].name =3D g_strdup(network->name); + gVBoxAPI.UIHNInterface.GetHardwareAddress(networkInterface, &m= acAddressUtf16); + gVBoxAPI.UIHNInterface.GetIPAddress(networkInterface, &ipAddre= ssUtf16); =20 - VBOX_UTF16_TO_UTF8(macAddressUtf16, &ipdef->hosts[0].mac); + VBOX_UTF16_TO_UTF8(macAddressUtf16, &ipdef->hosts[0].mac); =20 - if (vboxSocketParseAddrUtf16(data, ipAddressUtf16, - &ipdef->hosts[0].ip) < 0) { - errorOccurred =3D true; - } + if (vboxSocketParseAddrUtf16(data, ipAddressUtf16, + &ipdef->hosts[0].ip) < 0) { + errorOccurred =3D true; + } =20 - VBOX_UTF16_FREE(macAddressUtf16); - VBOX_UTF16_FREE(ipAddressUtf16); + VBOX_UTF16_FREE(macAddressUtf16); + VBOX_UTF16_FREE(ipAddressUtf16); =20 - if (errorOccurred) - goto cleanup; - } + if (errorOccurred) + goto cleanup; } else { ipdef->nhosts =3D 0; } diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index a6daf0ffcf..8cdfb35357 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -74,8 +74,7 @@ virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(xmlN= odePtr diskNode, _("Cannot parse 'uuid' attribute")); goto cleanup; } - if (VIR_STRDUP(hardDisk->uuid, searchTabResult[0]) < 0) - goto cleanup; + hardDisk->uuid =3D g_strdup(searchTabResult[0]); =20 location =3D virXMLPropString(diskNode, "location"); if (location =3D=3D NULL) { @@ -87,11 +86,9 @@ virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(xml= NodePtr diskNode, /*The location is a relative path, so we must change it into an ab= solute one. */ if (virAsprintf(&tmp, "%s%s", machineLocation, location) < 0) goto cleanup; - if (VIR_STRDUP(hardDisk->location, tmp) < 0) - goto cleanup; + hardDisk->location =3D g_strdup(tmp); } else { - if (VIR_STRDUP(hardDisk->location, location) < 0) - goto cleanup; + hardDisk->location =3D g_strdup(location); } hardDisk->format =3D virXMLPropString(diskNode, "format"); if (hardDisk->format =3D=3D NULL) { @@ -208,8 +205,7 @@ virVBoxSnapshotConfRetrieveSnapshot(xmlNodePtr snapshot= Node, _("Cannot parse 'uuid' attribute")); goto cleanup; } - if (VIR_STRDUP(snapshot->uuid, searchTabResult[0]) < 0) - goto cleanup; + snapshot->uuid =3D g_strdup(searchTabResult[0]); =20 snapshot->name =3D virXMLPropString(snapshotNode, "name"); if (snapshot->name =3D=3D NULL) { @@ -662,8 +658,7 @@ virVBoxSnapshotConfLoadVboxFile(const char *filePath, _("Cannot parse 'currentSnapshot' att= ribute")); goto cleanup; } - if (VIR_STRDUP(machineDescription->currentSnapshot, searchResultTa= b[0]) < 0) - goto cleanup; + machineDescription->currentSnapshot =3D g_strdup(searchResultTab[0= ]); } =20 machineDescription->snapshotFolder =3D virXMLPropString(machineNode, "= snapshotFolder"); diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 6929a9a2f3..c7bea2c219 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -56,9 +56,10 @@ static int vboxConnectListStoragePools(virConnectPtr con= n G_GNUC_UNUSED, { int numActive =3D 0; =20 - if (nnames > 0 && - VIR_STRDUP(names[numActive], "default-pool") > 0) + if (nnames > 0) { + names[numActive] =3D g_strdup("default-pool"); numActive++; + } return numActive; } =20 @@ -167,8 +168,8 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char= **const names, int nname continue; =20 VIR_DEBUG("nnames[%d]: %s", numActive, nameUtf8); - if (VIR_STRDUP(names[numActive], nameUtf8) > 0) - numActive++; + names[numActive] =3D g_strdup(nameUtf8); + numActive++; =20 VBOX_UTF8_FREE(nameUtf8); } @@ -770,11 +771,9 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr= vol, unsigned int flags) if (NS_FAILED(rc)) goto cleanup; =20 - if (VIR_STRDUP(def.name, vol->name) < 0) - goto cleanup; + def.name =3D g_strdup(vol->name); =20 - if (VIR_STRDUP(def.key, vol->key) < 0) - goto cleanup; + def.key =3D g_strdup(vol->key); =20 rc =3D gVBoxAPI.UIMedium.GetFormat(hardDisk, &hddFormatUtf16); if (NS_FAILED(rc)) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576214; cv=none; d=zoho.com; s=zohoarc; b=KiKi3ySMRwOU0w8JufxtKEtdBmeMirvAWUDgukKZelMxqdEoyMiKHjdGoixQURlkT5gnuqdwTP8F35yI8Zljgj69a4a2XDeCnnmbih16R50lMhKBddQWEYszBf3YG2PiohFRVQcCF+/O0bHS+i8ICoN/N0ktt01LNw+YJHCE7Qk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576214; 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=mYuQ0f/c951Wg8tZ4qt2iTpBJ/uLuzIBH99nJvwmUO8=; b=LIFuMjWDS1egb1b0VMIPCy2VjDtqfO/173eB46JMEHGY8ZI4baX1A1QTC/sBI1Mtit7iehCugousWARALK16xynyCs4S1xCs6aqg3FKLJqAxS+q3JmyiVhctTwNShC4gCBZAua8TkciqOo265bq04EpLkcDyp/4uaM/NywUzV3M= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.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 1571576214639238.26774387263617; Sun, 20 Oct 2019 05:56:54 -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-217-RxEtWuw4OByimdVwREX7uQ-1; Sun, 20 Oct 2019 08:56:50 -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 6329D8797DE; Sun, 20 Oct 2019 12:56:46 +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 3A01360C4E; Sun, 20 Oct 2019 12:56:46 +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 F3B5F180BA9C; Sun, 20 Oct 2019 12:56:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCuDr2023645 for ; Sun, 20 Oct 2019 08:56:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id E67283DA3; Sun, 20 Oct 2019 12:56:13 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46ED5194B9 for ; Sun, 20 Oct 2019 12:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576213; 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=mYuQ0f/c951Wg8tZ4qt2iTpBJ/uLuzIBH99nJvwmUO8=; b=R/lpxghVlzw6VpMEYKptb/kBnf8eglx4Gf0K302IisC/QpPAYIhC4Bax0loV/CN2t6KA0c O7zyGLqnsKhyf4hRKWcXk3QXLZwbrnqd+nlPuL7cIQJCee4YW517VfYp2i8Jp4v6tRM7SW sZvzClgbIyxoFeaDL3KXUrwOS/gT3fw= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:50 +0200 Message-Id: <330122d2ee2eb510df605751045ce31bc690165a.1571575890.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 32/34] tests: use g_strdup instead of VIR_STRDUP 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-MC-Unique: RxEtWuw4OByimdVwREX7uQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- tests/bhyvexml2argvmock.c | 6 +-- tests/commandtest.c | 5 +-- tests/cputest.c | 4 +- tests/domaincapstest.c | 13 +++--- tests/nssmock.c | 3 +- tests/openvzutilstest.c | 5 ++- tests/qemublocktest.c | 3 +- tests/qemudomaincheckpointxml2xmltest.c | 9 ++-- tests/qemufirmwaretest.c | 3 +- tests/qemuhotplugtest.c | 8 +--- tests/qemumemlocktest.c | 5 +-- tests/qemumonitorjsontest.c | 3 +- tests/qemumonitortestutils.c | 32 ++++++-------- tests/qemusecuritymock.c | 6 +-- tests/qemuvhostusertest.c | 3 +- tests/qemuxml2argvtest.c | 55 ++++++++----------------- tests/qemuxml2xmltest.c | 5 +-- tests/scsihosttest.c | 5 +-- tests/securityselinuxlabeltest.c | 8 +--- tests/securityselinuxtest.c | 13 +++--- tests/storagebackendsheepdogtest.c | 6 +-- tests/testutils.c | 3 +- tests/testutilsqemu.c | 31 +++++--------- tests/vboxsnapshotxmltest.c | 4 +- tests/viralloctest.c | 3 +- tests/vircgrouptest.c | 5 +-- tests/virfilecachetest.c | 7 +--- tests/virfirewalltest.c | 8 ++-- tests/virhostdevtest.c | 8 +--- tests/virnetmessagetest.c | 11 ++--- tests/virpcimock.c | 19 +++++---- tests/virpcitest.c | 5 +-- tests/virscsitest.c | 5 +-- tests/virstoragetest.c | 6 +-- tests/virstringtest.c | 9 ++-- tests/virtestmock.c | 3 +- tests/virusbmock.c | 4 +- tests/vmx2xmltest.c | 3 +- tests/xml2vmxtest.c | 3 +- 39 files changed, 115 insertions(+), 222 deletions(-) diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c index 717ceb4847..b0d38187f9 100644 --- a/tests/bhyvexml2argvmock.c +++ b/tests/bhyvexml2argvmock.c @@ -34,8 +34,7 @@ int virNetDevTapCreateInBridgePort(const char *brname G_G= NUC_UNUSED, unsigned int fakeflags G_GNUC_UNUSED) { VIR_FREE(*ifname); - if (VIR_STRDUP(*ifname, "vnet0") < 0) - return -1; + *ifname =3D g_strdup("vnet0"); return 0; } =20 @@ -43,8 +42,7 @@ char *virNetDevTapGetRealDeviceName(char *name G_GNUC_UNU= SED) { char *fakename; =20 - if (VIR_STRDUP(fakename, "faketapdev") < 0) - return NULL; + fakename =3D g_strdup("faketapdev"); return fakename; } =20 diff --git a/tests/commandtest.c b/tests/commandtest.c index e79baa2946..6ff2039ab1 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -686,10 +686,7 @@ static int test17(const void *unused G_GNUC_UNUSED) goto cleanup; } VIR_FREE(outbuf); - if (VIR_STRDUP(outbuf, "should not be leaked") < 0) { - puts("test framework failure"); - goto cleanup; - } + outbuf =3D g_strdup("should not be leaked"); =20 virCommandSetErrorBuffer(cmd, &errbuf); if (errbuf !=3D NULL) { diff --git a/tests/cputest.c b/tests/cputest.c index ab68c3b4af..83b494857f 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -492,9 +492,11 @@ cpuTestMakeQEMUCaps(const struct data *data) if (!(testMon =3D qemuMonitorTestNewFromFile(json, driver.xmlopt, true= ))) goto error; =20 - if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, "host") < 0) + if (VIR_ALLOC(cpu) < 0) goto cleanup; =20 + cpu->model =3D g_strdup("host"); + if (ARCH_IS_S390(data->arch)) fail_no_props =3D false; =20 diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 07bc99cc03..61bc019671 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -36,11 +36,11 @@ fillStringValues(virDomainCapsStringValuesPtr values, .= ..) =20 va_start(list, values); while ((str =3D va_arg(list, const char *))) { - if (VIR_REALLOC_N(values->values, values->nvalues + 1) < 0 || - VIR_STRDUP(values->values[values->nvalues], str) < 0) { + if (VIR_REALLOC_N(values->values, values->nvalues + 1) < 0) { ret =3D -1; break; } + values->values[values->nvalues] =3D g_strdup(str); values->nvalues++; } va_end(list); @@ -95,9 +95,7 @@ fillQemuCaps(virDomainCapsPtr domCaps, =20 if (machine) { VIR_FREE(domCaps->machine); - if (VIR_STRDUP(domCaps->machine, - virQEMUCapsGetCanonicalMachine(qemuCaps, machine)) = < 0) - goto cleanup; + domCaps->machine =3D g_strdup(virQEMUCapsGetCanonicalMachine(qemuC= aps, machine)); } =20 if (!domCaps->machine) @@ -153,9 +151,8 @@ fillXenCaps(virDomainCapsPtr domCaps) =20 if (VIR_ALLOC(firmwares[0]) < 0 || VIR_ALLOC(firmwares[1]) < 0) goto cleanup; - if (VIR_STRDUP(firmwares[0]->name, "/usr/lib/xen/boot/hvmloader") < 0 = || - VIR_STRDUP(firmwares[1]->name, "/usr/lib/xen/boot/ovmf.bin") < 0) - goto cleanup; + firmwares[0]->name =3D g_strdup("/usr/lib/xen/boot/hvmloader"); + firmwares[1]->name =3D g_strdup("/usr/lib/xen/boot/ovmf.bin"); =20 if (libxlMakeDomainCapabilities(domCaps, firmwares, 2) < 0) goto cleanup; diff --git a/tests/nssmock.c b/tests/nssmock.c index 230044275a..ea4b26ffab 100644 --- a/tests/nssmock.c +++ b/tests/nssmock.c @@ -62,8 +62,7 @@ getrealpath(char **newpath, return -1; } } else { - if (VIR_STRDUP_QUIET(*newpath, path) < 0) - return -1; + *newpath =3D g_strdup(path); } =20 return 0; diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index 1fcd4d2caa..c15ce9a47b 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -99,10 +99,11 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) " \n" "\n"; =20 - if (!(def =3D virDomainDefNew()) || - VIR_STRDUP(def->os.init, "/sbin/init") < 0) + if (!(def =3D virDomainDefNew())) goto cleanup; =20 + def->os.init =3D g_strdup("/sbin/init"); + def->virtType =3D VIR_DOMAIN_VIRT_OPENVZ; def->os.type =3D VIR_DOMAIN_OSTYPE_EXE; =20 diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 0f073682ca..a8d2f57c6e 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -161,8 +161,7 @@ testQemuDiskXMLToJSONFakeSecrets(virStorageSourcePtr sr= c) return -1; =20 srcpriv->secinfo->type =3D VIR_DOMAIN_SECRET_INFO_TYPE_AES; - if (VIR_STRDUP(srcpriv->secinfo->s.aes.username, src->auth->userna= me) < 0) - return -1; + srcpriv->secinfo->s.aes.username =3D g_strdup(src->auth->username); =20 if (virAsprintf(&srcpriv->secinfo->s.aes.alias, "%s-secalias", NULLSTR(src->nodestorage)) < 0) diff --git a/tests/qemudomaincheckpointxml2xmltest.c b/tests/qemudomainchec= kpointxml2xmltest.c index f6eb1f69b2..4540f15ddd 100644 --- a/tests/qemudomaincheckpointxml2xmltest.c +++ b/tests/qemudomaincheckpointxml2xmltest.c @@ -63,8 +63,7 @@ testCompareXMLToXMLFiles(const char *inxml, if (flags & TEST_PARENT) { if (def->parent.parent_name) return -1; - if (VIR_STRDUP(def->parent.parent_name, "1525111885") < 0) - return -1; + def->parent.parent_name =3D g_strdup("1525111885"); } if (flags & TEST_VDA_BITMAP) { virDomainCheckpointDiskDefPtr disk; @@ -76,13 +75,11 @@ testCompareXMLToXMLFiles(const char *inxml, return -1; if (!disk->name) { disk->type =3D VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP; - if (VIR_STRDUP(disk->name, "vda") < 0) - return -1; + disk->name =3D g_strdup("vda"); } else if (STRNEQ(disk->name, "vda")) { return -1; } - if (VIR_STRDUP(disk->bitmap, def->parent.name) < 0) - return -1; + disk->bitmap =3D g_strdup(def->parent.name); } if (flags & TEST_SIZE) { def->disks[0].size =3D 1048576; diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index 9287ea554b..ad7ed7a384 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -70,8 +70,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED) }; const size_t nexpected =3D G_N_ELEMENTS(expected); =20 - if (VIR_STRDUP(fakehome, abs_srcdir "/qemufirmwaredata/home/user/.conf= ig") < 0) - return -1; + fakehome =3D g_strdup(abs_srcdir "/qemufirmwaredata/home/user/.config"= ); =20 setenv("XDG_CONFIG_HOME", fakehome, 1); =20 diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index d3da08875a..4ff2b38c83 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -597,10 +597,7 @@ mymain(void) struct testQemuHotplugCpuParams cpudata; char *fakerootdir; =20 - if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { - fprintf(stderr, "Out of memory\n"); - abort(); - } + fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 if (!mkdtemp(fakerootdir)) { fprintf(stderr, "Cannot create fakerootdir"); @@ -622,8 +619,7 @@ mymain(void) VIR_FREE(driver.config->spiceListen); VIR_FREE(driver.config->vncListen); /* some dummy values from 'config file' */ - if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0) - return EXIT_FAILURE; + driver.config->spicePassword =3D g_strdup("123456"); =20 if (!(driver.domainEventState =3D virObjectEventStateNew())) return EXIT_FAILURE; diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index c9484ac9cb..490e2ef11f 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -61,10 +61,7 @@ mymain(void) char *fakerootdir; virQEMUCapsPtr qemuCaps =3D NULL; =20 - if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { - fprintf(stderr, "Out of memory\n"); - abort(); - } + fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 if (!mkdtemp(fakerootdir)) { fprintf(stderr, "Cannot create fakerootdir"); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index f754e4d94b..c0eee921cf 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2165,8 +2165,7 @@ testQemuMonitorJSONqemuMonitorJSONSetBlockIoThrottle(= const void *opaque) return -1; =20 expectedInfo =3D (virDomainBlockIoTuneInfo) {1, 2, 3, 4, 5, 6, 7, 8, 9= , 10, 11, 12, 13, NULL, 15, 16, 17, 18, 19, 20}; - if (VIR_STRDUP(expectedInfo.group_name, "group14") < 0) - return -1; + expectedInfo.group_name =3D g_strdup("group14"); =20 if (qemuMonitorTestAddItem(test, "query-block", queryBlockReply) < 0 || qemuMonitorTestAddItemParams(test, "block_set_io_throttle", diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 6b3aa97e39..fb76bf185d 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -604,11 +604,8 @@ qemuMonitorTestAddItem(qemuMonitorTestPtr test, if (VIR_ALLOC(data) < 0) return -1; =20 - if (VIR_STRDUP(data->command_name, command_name) < 0 || - VIR_STRDUP(data->response, response) < 0) { - qemuMonitorTestHandlerDataFree(data); - return -1; - } + data->command_name =3D g_strdup(command_name); + data->response =3D g_strdup(response); =20 return qemuMonitorTestAddHandler(test, qemuMonitorTestProcessCommandDefault, @@ -692,9 +689,8 @@ qemuMonitorTestAddItemVerbatim(qemuMonitorTestPtr test, if (VIR_ALLOC(data) < 0) return -1; =20 - if (VIR_STRDUP(data->response, response) < 0 || - VIR_STRDUP(data->cmderr, cmderr) < 0) - goto error; + data->response =3D g_strdup(response); + data->cmderr =3D g_strdup(cmderr); =20 data->command_name =3D virJSONStringReformat(command, false); if (!data->command_name) @@ -868,9 +864,8 @@ qemuMonitorTestAddItemParams(qemuMonitorTestPtr test, if (VIR_ALLOC(data) < 0) goto error; =20 - if (VIR_STRDUP(data->command_name, cmdname) < 0 || - VIR_STRDUP(data->response, response) < 0) - goto error; + data->command_name =3D g_strdup(cmdname); + data->response =3D g_strdup(response); =20 while ((argname =3D va_arg(args, char *))) { size_t i; @@ -885,9 +880,8 @@ qemuMonitorTestAddItemParams(qemuMonitorTestPtr test, if (VIR_EXPAND_N(data->args, data->nargs, 1)) goto error; =20 - if (VIR_STRDUP(data->args[i].argname, argname) < 0 || - VIR_STRDUP(data->args[i].argval, argval) < 0) - goto error; + data->args[i].argname =3D g_strdup(argname); + data->args[i].argval =3D g_strdup(argval); } =20 va_end(args); @@ -984,10 +978,9 @@ qemuMonitorTestAddItemExpect(qemuMonitorTestPtr test, if (VIR_ALLOC(data) < 0) goto error; =20 - if (VIR_STRDUP(data->command_name, cmdname) < 0 || - VIR_STRDUP(data->response, response) < 0 || - VIR_STRDUP(data->expectArgs, cmdargs) < 0) - goto error; + data->command_name =3D g_strdup(cmdname); + data->response =3D g_strdup(response); + data->expectArgs =3D g_strdup(cmdargs); =20 if (apostrophe) { char *tmp =3D data->expectArgs; @@ -1065,8 +1058,7 @@ qemuMonitorCommonTestNew(virDomainXMLOptionPtr xmlopt, return NULL; } =20 - if (VIR_STRDUP(tmpdir_template, "/tmp/libvirt_XXXXXX") < 0) - goto error; + tmpdir_template =3D g_strdup("/tmp/libvirt_XXXXXX"); =20 if (!(test->tmpdir =3D mkdtemp(tmpdir_template))) { virReportSystemError(errno, "%s", diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index 8b857b0cc1..50435bbd02 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -146,8 +146,7 @@ virFileGetXAttrQuiet(const char *path, goto cleanup; } =20 - if (VIR_STRDUP(*value, val) < 0) - goto cleanup; + *value =3D g_strdup(val); =20 ret =3D 0; cleanup: @@ -194,8 +193,7 @@ int virFileSetXAttr(const char *path, char *val; =20 key =3D get_key(path, name); - if (VIR_STRDUP(val, value) < 0) - return -1; + val =3D g_strdup(value); =20 virMutexLock(&m); init_syms(); diff --git a/tests/qemuvhostusertest.c b/tests/qemuvhostusertest.c index 0ee96d9ecc..3e1890a88f 100644 --- a/tests/qemuvhostusertest.c +++ b/tests/qemuvhostusertest.c @@ -68,8 +68,7 @@ testVUPrecedence(const void *opaque G_GNUC_UNUSED) }; const size_t nexpected =3D G_N_ELEMENTS(expected); =20 - if (VIR_STRDUP(fakehome, abs_srcdir "/qemuvhostuserdata/home/user/.con= fig") < 0) - return -1; + fakehome =3D g_strdup(abs_srcdir "/qemuvhostuserdata/home/user/.config= "); =20 setenv("XDG_CONFIG_HOME", fakehome, 1); =20 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7bbc44451d..122e14b071 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -43,8 +43,7 @@ fakeSecretGetValue(virSecretPtr obj G_GNUC_UNUSED, unsigned int internalFlags G_GNUC_UNUSED) { char *secret; - if (VIR_STRDUP(secret, "AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A") < 0) - return NULL; + secret =3D g_strdup("AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A"); *value_size =3D strlen(secret); return (unsigned char *) secret; } @@ -517,9 +516,7 @@ testCompareXMLToArgv(const void *data) switch (vm->def->tpm->type) { case VIR_DOMAIN_TPM_TYPE_EMULATOR: VIR_FREE(vm->def->tpm->data.emulator.source.data.file.path); - if (VIR_STRDUP(vm->def->tpm->data.emulator.source.data.file.pa= th, - "/dev/test") < 0) - goto cleanup; + vm->def->tpm->data.emulator.source.data.file.path =3D g_strdup= ("/dev/test"); vm->def->tpm->data.emulator.source.type =3D VIR_DOMAIN_CHR_TYP= E_FILE; break; case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: @@ -620,10 +617,7 @@ mymain(void) char *fakerootdir; virHashTablePtr capslatest =3D NULL; =20 - if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { - fprintf(stderr, "Out of memory\n"); - abort(); - } + fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 if (!mkdtemp(fakerootdir)) { fprintf(stderr, "Cannot create fakerootdir"); @@ -648,43 +642,33 @@ mymain(void) driver.privileged =3D true; =20 VIR_FREE(driver.config->defaultTLSx509certdir); - if (VIR_STRDUP_QUIET(driver.config->defaultTLSx509certdir, "/etc/pki/q= emu") < 0) - return EXIT_FAILURE; + driver.config->defaultTLSx509certdir =3D g_strdup("/etc/pki/qemu"); VIR_FREE(driver.config->vncTLSx509certdir); - if (VIR_STRDUP_QUIET(driver.config->vncTLSx509certdir, "/etc/pki/libvi= rt-vnc") < 0) - return EXIT_FAILURE; + driver.config->vncTLSx509certdir =3D g_strdup("/etc/pki/libvirt-vnc"); VIR_FREE(driver.config->spiceTLSx509certdir); - if (VIR_STRDUP_QUIET(driver.config->spiceTLSx509certdir, "/etc/pki/lib= virt-spice") < 0) - return EXIT_FAILURE; + driver.config->spiceTLSx509certdir =3D g_strdup("/etc/pki/libvirt-spic= e"); VIR_FREE(driver.config->chardevTLSx509certdir); - if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/l= ibvirt-chardev") < 0) - return EXIT_FAILURE; + driver.config->chardevTLSx509certdir =3D g_strdup("/etc/pki/libvirt-ch= ardev"); VIR_FREE(driver.config->vxhsTLSx509certdir); - if (VIR_STRDUP_QUIET(driver.config->vxhsTLSx509certdir, "/etc/pki/libv= irt-vxhs/dummy,path") < 0) - return EXIT_FAILURE; + driver.config->vxhsTLSx509certdir =3D g_strdup("/etc/pki/libvirt-vxhs/= dummy,path"); VIR_FREE(driver.config->nbdTLSx509certdir); - if (VIR_STRDUP_QUIET(driver.config->nbdTLSx509certdir, "/etc/pki/libvi= rt-nbd/dummy,path") < 0) - return EXIT_FAILURE; + driver.config->nbdTLSx509certdir =3D g_strdup("/etc/pki/libvirt-nbd/du= mmy,path"); =20 VIR_FREE(driver.config->hugetlbfs); if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0) return EXIT_FAILURE; driver.config->nhugetlbfs =3D 2; - if (VIR_STRDUP(driver.config->hugetlbfs[0].mnt_dir, "/dev/hugepages2M"= ) < 0 || - VIR_STRDUP(driver.config->hugetlbfs[1].mnt_dir, "/dev/hugepages1G"= ) < 0) - return EXIT_FAILURE; + driver.config->hugetlbfs[0].mnt_dir =3D g_strdup("/dev/hugepages2M"); + driver.config->hugetlbfs[1].mnt_dir =3D g_strdup("/dev/hugepages1G"); driver.config->hugetlbfs[0].size =3D 2048; driver.config->hugetlbfs[0].deflt =3D true; driver.config->hugetlbfs[1].size =3D 1048576; driver.config->spiceTLS =3D 1; - if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0) - return EXIT_FAILURE; + driver.config->spicePassword =3D g_strdup("123456"); VIR_FREE(driver.config->memoryBackingDir); - if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir, "/var/lib/libvir= t/qemu/ram") < 0) - return EXIT_FAILURE; + driver.config->memoryBackingDir =3D g_strdup("/var/lib/libvirt/qemu/ra= m"); VIR_FREE(driver.config->nvramDir); - if (VIR_STRDUP(driver.config->nvramDir, "/var/lib/libvirt/qemu/nvram")= < 0) - return EXIT_FAILURE; + driver.config->nvramDir =3D g_strdup("/var/lib/libvirt/qemu/nvram"); =20 capslatest =3D testQemuGetLatestCaps(); if (!capslatest) @@ -1222,9 +1206,7 @@ mymain(void) DO_TEST("graphics-vnc-tls", QEMU_CAPS_VNC, QEMU_CAPS_DEVICE_CIRRUS_VGA= ); DO_TEST_CAPS_VER("graphics-vnc-tls", "2.4.0"); DO_TEST_CAPS_LATEST("graphics-vnc-tls"); - if (VIR_STRDUP_QUIET(driver.config->vncTLSx509secretUUID, - "6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea") < 0) - return EXIT_FAILURE; + driver.config->vncTLSx509secretUUID =3D g_strdup("6fd3f62d-9fe7-4a4e-a= 869-7acd6376d8ea"); DO_TEST_CAPS_LATEST("graphics-vnc-tls-secret"); VIR_FREE(driver.config->vncTLSx509secretUUID); driver.config->vncSASL =3D driver.config->vncTLSx509verify =3D driver.= config->vncTLS =3D 0; @@ -1407,11 +1389,8 @@ mymain(void) QEMU_CAPS_DEVICE_ISA_SERIAL, QEMU_CAPS_OBJECT_TLS_CREDS_X509); VIR_FREE(driver.config->chardevTLSx509certdir); - if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509certdir, "/etc/pki/l= ibvirt-chardev") < 0) - return EXIT_FAILURE; - if (VIR_STRDUP_QUIET(driver.config->chardevTLSx509secretUUID, - "6fd3f62d-9fe7-4a4e-a869-7acd6376d8ea") < 0) - return EXIT_FAILURE; + driver.config->chardevTLSx509certdir =3D g_strdup("/etc/pki/libvirt-ch= ardev"); + driver.config->chardevTLSx509secretUUID =3D g_strdup("6fd3f62d-9fe7-4a= 4e-a869-7acd6376d8ea"); DO_TEST("serial-tcp-tlsx509-secret-chardev", QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_DEVICE_ISA_SERIAL, diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 4c7ba98367..e7c029a74d 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -157,10 +157,7 @@ mymain(void) if (!capslatest) return EXIT_FAILURE; =20 - if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { - fprintf(stderr, "Out of memory\n"); - abort(); - } + fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 if (!mkdtemp(fakerootdir)) { fprintf(stderr, "Cannot create fakerootdir"); diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index c1a7e2d603..35c7d93376 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -253,10 +253,7 @@ mymain(void) char *fakerootdir =3D NULL; char *fakesysfsdir =3D NULL; =20 - if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { - fprintf(stderr, "Out of memory\n"); - goto cleanup; - } + fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 if (!mkdtemp(fakerootdir)) { fprintf(stderr, "Cannot create fakerootdir"); diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index 6f9b5c0e70..9156403c51 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -144,10 +144,7 @@ testSELinuxLoadFileList(const char *testname, abs_builddir, line) < 0) goto cleanup; if (*tmp !=3D '\0' && *tmp !=3D '\n') { - if (VIR_STRDUP(context, tmp) < 0) { - VIR_FREE(file); - goto cleanup; - } + context =3D g_strdup(tmp); =20 tmp =3D strchr(context, '\n'); if (tmp) @@ -270,8 +267,7 @@ testSELinuxCheckLabels(testSELinuxFile *files, size_t n= files) if (errno =3D=3D ENODATA) { /* nothing to do */ } else if (errno =3D=3D EOPNOTSUPP) { - if (VIR_STRDUP(ctx, "EOPNOTSUPP") < 0) - return -1; + ctx =3D g_strdup("EOPNOTSUPP"); } else { virReportSystemError(errno, "Cannot read label on %s", diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c index 5dccb708d8..6c8314de6b 100644 --- a/tests/securityselinuxtest.c +++ b/tests/securityselinuxtest.c @@ -77,17 +77,14 @@ testBuildDomainDef(bool dynamic, if (VIR_ALLOC(secdef) < 0) goto error; =20 - if (VIR_STRDUP(secdef->model, "selinux") < 0) - goto error; + secdef->model =3D g_strdup("selinux"); =20 secdef->type =3D dynamic ? VIR_DOMAIN_SECLABEL_DYNAMIC : VIR_DOMAIN_SE= CLABEL_STATIC; - if (label && - VIR_STRDUP(secdef->label, label) < 0) - goto error; + if (label) + secdef->label =3D g_strdup(label); =20 - if (baselabel && - VIR_STRDUP(secdef->baselabel, baselabel) < 0) - goto error; + if (baselabel) + secdef->baselabel =3D g_strdup(baselabel); =20 def->seclabels[0] =3D secdef; def->nseclabels++; diff --git a/tests/storagebackendsheepdogtest.c b/tests/storagebackendsheep= dogtest.c index 6504881920..a5403e7136 100644 --- a/tests/storagebackendsheepdogtest.c +++ b/tests/storagebackendsheepdogtest.c @@ -63,8 +63,7 @@ test_node_info_parser(const void *opaque) if (!(pool =3D virStoragePoolDefParseFile(data->poolxml))) return -1; =20 - if (VIR_STRDUP(output, test.output) < 0) - return -1; + output =3D g_strdup(test.output); =20 if (virStorageBackendSheepdogParseNodeInfo(pool, output) !=3D test.expected_return) @@ -95,8 +94,7 @@ test_vdi_list_parser(const void *opaque) if (!(vol =3D virStorageVolDefParseFile(pool, data->volxml, 0))) return -1; =20 - if (VIR_STRDUP(output, test.output) < 0) - return -1; + output =3D g_strdup(test.output); =20 if (virStorageBackendSheepdogParseVdiList(vol, output) !=3D test.expected_return) diff --git a/tests/testutils.c b/tests/testutils.c index 1c89d503d9..a141abc91b 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -816,8 +816,7 @@ virTestSetEnvPath(void) virAsprintf(&new_path, "%s:%s", abs_builddir, path) < 0) goto cleanup; } else { - if (VIR_STRDUP(new_path, abs_builddir) < 0) - goto cleanup; + new_path =3D g_strdup(abs_builddir); } =20 if (new_path && diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index e6eca5cb2e..0faa9cb84a 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -74,8 +74,7 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines= (int *nmachines) "pc-0.11", "pc", "pc-0.10", "isapc" }; =20 - if (VIR_STRDUP(canonical, x86_machines[0]) < 0) - return NULL; + canonical =3D g_strdup(x86_machines[0]); =20 machines =3D virCapabilitiesAllocMachines(x86_machines, G_N_ELEMENTS(x86_machines)); @@ -503,9 +502,8 @@ virCapsPtr testQemuCapsInit(void) goto cleanup; caps->host.nsecModels =3D 1; =20 - if (VIR_STRDUP(caps->host.secModels[0].model, "none") < 0 || - VIR_STRDUP(caps->host.secModels[0].doi, "0") < 0) - goto cleanup; + caps->host.secModels[0].model =3D g_strdup("none"); + caps->host.secModels[0].doi =3D g_strdup("0"); =20 if (!(cpuDefault =3D virCPUDefCopy(&cpuDefaultData)) || !(cpuHaswell =3D virCPUDefCopy(&cpuHaswellData)) || @@ -710,29 +708,22 @@ int qemuTestDriverInit(virQEMUDriver *driver) /* Overwrite some default paths so it's consistent for tests. */ VIR_FREE(driver->config->libDir); VIR_FREE(driver->config->channelTargetDir); - if (VIR_STRDUP(driver->config->libDir, "/tmp/lib") < 0 || - VIR_STRDUP(driver->config->channelTargetDir, "/tmp/channel") < 0) - goto error; + driver->config->libDir =3D g_strdup("/tmp/lib"); + driver->config->channelTargetDir =3D g_strdup("/tmp/channel"); =20 if (!mkdtemp(statedir)) { virFilePrintf(stderr, "Cannot create fake stateDir"); goto error; } =20 - if (VIR_STRDUP(driver->config->stateDir, statedir) < 0) { - rmdir(statedir); - goto error; - } + driver->config->stateDir =3D g_strdup(statedir); =20 if (!mkdtemp(configdir)) { virFilePrintf(stderr, "Cannot create fake configDir"); goto error; } =20 - if (VIR_STRDUP(driver->config->configDir, configdir) < 0) { - rmdir(configdir); - goto error; - } + driver->config->configDir =3D g_strdup(configdir); =20 driver->caps =3D testQemuCapsInit(); if (!driver->caps) @@ -827,10 +818,9 @@ testQemuGetLatestCapsForArch(const char *arch, while ((rc =3D virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) { VIR_FREE(tmp); =20 - if ((rc =3D VIR_STRDUP(tmp, STRSKIP(ent->d_name, "caps_"))) < 0) - goto cleanup; + tmp =3D g_strdup(STRSKIP(ent->d_name, "caps_")); =20 - if (rc =3D=3D 0) + if (!tmp) continue; =20 if (!virStringStripSuffix(tmp, fullsuffix)) @@ -1051,8 +1041,7 @@ testQemuInfoSetArgs(struct testQemuInfo *info, bool stripmachinealiases =3D false; =20 if (STREQ(capsver, "latest")) { - if (VIR_STRDUP(capsfile, virHashLookup(capslatest, capsarch)) = < 0) - goto cleanup; + capsfile =3D g_strdup(virHashLookup(capslatest, capsarch)); stripmachinealiases =3D true; } else if (virAsprintf(&capsfile, "%s/caps_%s.%s.xml", TEST_QEMU_CAPS_PATH, capsver, capsarch) < 0= ) { diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index c70d7ab100..3d6171e266 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -58,9 +58,7 @@ testCompareXMLtoXMLFiles(const char *xml) int ret =3D -1; virVBoxSnapshotConfMachinePtr machine =3D NULL; =20 - if (VIR_STRDUP(pathResult, - abs_builddir "/vboxsnapshotxmldata/testResult.vbox") < = 0) - return -1; + pathResult =3D g_strdup(abs_builddir "/vboxsnapshotxmldata/testResult.= vbox"); =20 if (virFileMakePath(abs_builddir "/vboxsnapshotxmldata") < 0) goto cleanup; diff --git a/tests/viralloctest.c b/tests/viralloctest.c index 75e639675b..c52483998b 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -409,8 +409,7 @@ testDispose(const void *opaque G_GNUC_UNUSED) =20 VIR_DISPOSE_N(nums, nnums); =20 - if (VIR_STRDUP(str, "test") < 0) - return -1; + str =3D g_strdup("test"); =20 VIR_DISPOSE_STRING(str); =20 diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index cecb15ae5b..cec07580ac 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -992,10 +992,7 @@ initFakeFS(const char *mode, { char *fakerootdir; =20 - if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { - fprintf(stderr, "Out of memory\n"); - abort(); - } + fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 if (!mkdtemp(fakerootdir)) { fprintf(stderr, "Cannot create fakerootdir"); diff --git a/tests/virfilecachetest.c b/tests/virfilecachetest.c index e3c6401934..6d280b3bec 100644 --- a/tests/virfilecachetest.c +++ b/tests/virfilecachetest.c @@ -71,14 +71,9 @@ testFileCacheObjNew(const char *data) if (!(obj =3D virObjectNew(testFileCacheObjClass))) return NULL; =20 - if (VIR_STRDUP(obj->data, data) < 0) - goto error; + obj->data =3D g_strdup(data); =20 return obj; - - error: - virObjectUnref(obj); - return NULL; } =20 =20 diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index 824e9f46c2..a5323a4256 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -961,19 +961,17 @@ testFirewallQueryHook(const char *const*args, const char *input G_GNUC_UNUSED, char **output, char **error G_GNUC_UNUSED, - int *status, + int *status G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { if (STREQ(args[0], IPTABLES_PATH) && STREQ(args[1], "-L")) { - if (VIR_STRDUP(*output, TEST_FILTER_TABLE_LIST) < 0) - *status =3D 127; + *output =3D g_strdup(TEST_FILTER_TABLE_LIST); } else if (STREQ(args[0], IPTABLES_PATH) && STREQ(args[1], "-t") && STREQ(args[2], "nat") && STREQ(args[3], "-L")) { - if (VIR_STRDUP(*output, TEST_NAT_TABLE_LIST) < 0) - *status =3D 127; + *output =3D g_strdup(TEST_NAT_TABLE_LIST); } } =20 diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 8e21d3eae4..1f3f730433 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -117,8 +117,7 @@ myInit(void) goto cleanup; if ((mgr->activeSCSIHostdevs =3D virSCSIDeviceListNew()) =3D=3D NULL) goto cleanup; - if (VIR_STRDUP(mgr->stateDir, TEST_STATE_DIR) < 0) - goto cleanup; + mgr->stateDir =3D g_strdup(TEST_STATE_DIR); if (virFileMakePath(mgr->stateDir) < 0) goto cleanup; =20 @@ -501,10 +500,7 @@ mymain(void) int ret =3D 0; g_autofree char *fakerootdir =3D NULL; =20 - if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { - fprintf(stderr, "Out of memory\n"); - abort(); - } + fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 if (!mkdtemp(fakerootdir)) { fprintf(stderr, "Cannot create fakerootdir"); diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c index 53544abbdb..b0a01e8b9d 100644 --- a/tests/virnetmessagetest.c +++ b/tests/virnetmessagetest.c @@ -228,15 +228,16 @@ static int testMessagePayloadEncode(const void *args = G_GNUC_UNUSED) err.level =3D VIR_ERR_ERROR; =20 if (VIR_ALLOC(err.message) < 0 || - VIR_STRDUP(*err.message, "Hello World") < 0 || VIR_ALLOC(err.str1) < 0 || - VIR_STRDUP(*err.str1, "One") < 0 || VIR_ALLOC(err.str2) < 0 || - VIR_STRDUP(*err.str2, "Two") < 0 || - VIR_ALLOC(err.str3) < 0 || - VIR_STRDUP(*err.str3, "Three") < 0) + VIR_ALLOC(err.str3) < 0) goto cleanup; =20 + *err.message =3D g_strdup("Hello World"); + *err.str1 =3D g_strdup("One"); + *err.str2 =3D g_strdup("Two"); + *err.str3 =3D g_strdup("Three"); + err.int1 =3D 1; err.int2 =3D 2; =20 diff --git a/tests/virpcimock.c b/tests/virpcimock.c index ba4256e2fb..d7dc0b00f0 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -289,8 +289,7 @@ getrealpath(char **newpath, return -1; } } else { - if (VIR_STRDUP_QUIET(*newpath, path) < 0) - return -1; + *newpath =3D g_strdup(path); } =20 return 0; @@ -324,12 +323,12 @@ add_fd(int fd, const char *path) fd, path, cb.fd, cb.path); } =20 - if (VIR_REALLOC_N_QUIET(callbacks, nCallbacks + 1) < 0 || - VIR_STRDUP_QUIET(callbacks[nCallbacks].path, path) < 0) { + if (VIR_REALLOC_N_QUIET(callbacks, nCallbacks + 1) < 0) { errno =3D ENOMEM; goto cleanup; } =20 + callbacks[nCallbacks].path =3D g_strdup(path); callbacks[nCallbacks++].fd =3D fd; ret =3D 0; cleanup: @@ -477,10 +476,11 @@ pci_device_new_from_stub(const struct pciDevice *data) struct stat sb; bool configSrcExists =3D false; =20 - if (!(devid =3D pci_address_format(&data->addr)) || - VIR_STRDUP_QUIET(id, devid) < 0) + if (!(devid =3D pci_address_format(&data->addr))) ABORT_OOM(); =20 + id =3D g_strdup(devid); + /* Replace ':' with '-' to create the config filename from the * device ID. The device ID cannot be used directly as filename * because it contains ':' and Windows does not allow ':' in @@ -724,9 +724,10 @@ pci_driver_new(const char *name, ...) int vendor, device; g_autofree char *driverpath =3D NULL; =20 - if (VIR_ALLOC_QUIET(driver) < 0 || - VIR_STRDUP_QUIET(driver->name, name) < 0 || - !(driverpath =3D pci_driver_get_path(driver, NULL, true))) + if (VIR_ALLOC_QUIET(driver) < 0) + ABORT_OOM(); + driver->name =3D g_strdup(name); + if (!(driverpath =3D pci_driver_get_path(driver, NULL, true))) ABORT_OOM(); =20 if (virFileMakePath(driverpath) < 0) diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 4078dc4c69..de2ffc7d41 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -328,10 +328,7 @@ mymain(void) int ret =3D 0; char *fakerootdir; =20 - if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { - VIR_TEST_DEBUG("Out of memory"); - abort(); - } + fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); =20 if (!mkdtemp(fakerootdir)) { VIR_TEST_DEBUG("Cannot create fakerootdir"); diff --git a/tests/virscsitest.c b/tests/virscsitest.c index d4019e82f7..99374cc80c 100644 --- a/tests/virscsitest.c +++ b/tests/virscsitest.c @@ -222,10 +222,7 @@ mymain(void) =20 VIR_FREE(virscsi_prefix); =20 - if (VIR_STRDUP(virscsi_prefix, tmpdir) < 0) { - ret =3D -1; - goto cleanup; - } + virscsi_prefix =3D g_strdup(tmpdir); =20 if (virTestRun("test1", test1, NULL) < 0) ret =3D -1; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 5d3edbc854..8f1d93fa5a 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -102,8 +102,7 @@ testStorageFileGetMetadata(const char *path, } } =20 - if (VIR_STRDUP(def->path, path) < 0) - return NULL; + def->path =3D g_strdup(path); =20 if (virStorageFileGetMetadata(def, uid, gid, false) < 0) return NULL; @@ -480,8 +479,7 @@ testPathCanonicalizeReadlink(const char *path, =20 for (i =3D 0; i < G_N_ELEMENTS(testPathCanonicalizeSymlinks); i++) { if (STREQ(path, testPathCanonicalizeSymlinks[i][0])) { - if (VIR_STRDUP(*linkpath, testPathCanonicalizeSymlinks[i][1]) = < 0) - return -1; + *linkpath =3D g_strdup(testPathCanonicalizeSymlinks[i][1]); =20 return 0; } diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 5d010f7f59..1e408f2757 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -718,8 +718,7 @@ static int testStripIPv6Brackets(const void *args) int ret =3D -1; char *res =3D NULL; =20 - if (VIR_STRDUP(res, data->string) < 0) - goto cleanup; + res =3D g_strdup(data->string); =20 virStringStripIPv6Brackets(res); =20 @@ -742,8 +741,7 @@ static int testStripControlChars(const void *args) int ret =3D -1; char *res =3D NULL; =20 - if (VIR_STRDUP(res, data->string) < 0) - goto cleanup; + res =3D g_strdup(data->string); =20 virStringStripControlChars(res); =20 @@ -772,8 +770,7 @@ static int testFilterChars(const void *args) int ret =3D -1; char *res =3D NULL; =20 - if (VIR_STRDUP(res, data->string) < 0) - goto cleanup; + res =3D g_strdup(data->string); =20 virStringFilterChars(res, data->valid); =20 diff --git a/tests/virtestmock.c b/tests/virtestmock.c index 9fe774836b..e0f9c6c2a1 100644 --- a/tests/virtestmock.c +++ b/tests/virtestmock.c @@ -122,8 +122,7 @@ checkPath(const char *path, } else { /* Yeah, our worst nightmares just became true. Path does * not exist. Cut off the last component and retry. */ - if (VIR_STRDUP_QUIET(crippledPath, relPath ? relPath : path) < 0) - goto error; + crippledPath =3D g_strdup(relPath ? relPath : path); =20 virFileRemoveLastComponent(crippledPath); =20 diff --git a/tests/virusbmock.c b/tests/virusbmock.c index f35ad407ad..cace140725 100644 --- a/tests/virusbmock.c +++ b/tests/virusbmock.c @@ -56,8 +56,8 @@ static char *get_fake_path(const char *real_path) if ((p =3D STRSKIP(real_path, USB_SYSFS)) && virAsprintfQuiet(&path, "%s/%s/%s", abs_srcdir, FAKE_USB_SYSFS, p)= < 0) goto error; - else if (!p && VIR_STRDUP_QUIET(path, real_path) < 0) - goto error; + else if (!p) + path =3D g_strdup(real_path); =20 return path; =20 diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 4c5d41aee5..706fec7bac 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -142,8 +142,7 @@ testParseVMXFileName(const char *fileName, void *opaque= G_GNUC_UNUSED) =20 if (STRPREFIX(fileName, "/vmfs/volumes/")) { /* Found absolute path referencing a file inside a datastore */ - if (VIR_STRDUP(copyOfFileName, fileName) < 0) - goto cleanup; + copyOfFileName =3D g_strdup(fileName); =20 /* Expected format: '/vmfs/volumes//' */ if ((tmp =3D STRSKIP(copyOfFileName, "/vmfs/volumes/")) =3D=3D NUL= L || diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 0cfdb1facf..42ab4ed929 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -153,8 +153,7 @@ testFormatVMXFileName(const char *src, void *opaque G_G= NUC_UNUSED) =20 if (STRPREFIX(src, "[")) { /* Found potential datastore path */ - if (VIR_STRDUP(copyOfDatastorePath, src) < 0) - goto cleanup; + copyOfDatastorePath =3D g_strdup(src); =20 /* Expected format: '[] ' where is optiona= l */ if ((tmp =3D STRSKIP(copyOfDatastorePath, "[")) =3D=3D NULL || *tm= p =3D=3D ']' || --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571576224; cv=none; d=zoho.com; s=zohoarc; b=aYHjZmvOkeafICwNyZKuakZdfA4671oiN1WqE6PlEt0Yxa9Jo3qw9byV/o4YgesQ10mCLf/ZWnS+RIVXVc3ABW58z3fBoFsq+O7zvLQnwoWMuclkyUo1Q2H/lI/tt4YkRBXATK0WsXaSbz/CFUtzF9zXK4OSjmC3nAx1bghRSnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576224; 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=SVJqQgfStVP9spNqamGKmMExhOQpyV3uL69ZfZpfVAU=; b=UAOA4Qbquz8Dm4jDjH8tMffKnGJLioKQKpxPJAmFz3D+RFxgKIDo1S+JciITD3MP8XuECqulWz7e0IuUM6QqJ7pJLVCJC13K8C8DyyJiQKTzTY2YAdzkmn/g9MdIUTHZH1P67Flqf9im9DGHkIM18RIlAZLQ0mC6UEKsoPZ83Xg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1571576224115824.1920457138111; Sun, 20 Oct 2019 05:57:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-SSq73I6mM4ePbB2eRmaDtg-1; Sun, 20 Oct 2019 08:56:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D742A107AFA9; Sun, 20 Oct 2019 12:56:50 +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 6BE215C241; Sun, 20 Oct 2019 12:56:50 +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 179C21804761; Sun, 20 Oct 2019 12:56:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCuFGd023655 for ; Sun, 20 Oct 2019 08:56:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0BB9D90B3; Sun, 20 Oct 2019 12:56:15 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E7103DA3 for ; Sun, 20 Oct 2019 12:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576222; 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=SVJqQgfStVP9spNqamGKmMExhOQpyV3uL69ZfZpfVAU=; b=N2S9pmEc38gC/a8Hv4SuyvjsgU3/jcjEs8nTVcptl4tdwSJER4zBDW16QtOgtak00E1G9W UQv6JGNxfHsXpczljvtytrCw+ilRRH/k1UVLurinZI9/B5o4/RsKx5tS3/7/A8brVS6FiR lP+uCw/IhvLc5+/Oej+J23Pv4fLYJhw= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:51 +0200 Message-Id: <3fe20fdd710775d6aacfa2ca161574b6d16adcf1.1571575890.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 33/34] tools: use g_strdup instead of VIR_STRDUP X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: SSq73I6mM4ePbB2eRmaDtg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- tools/virsh-completer-checkpoint.c | 3 +-- tools/virsh-completer-domain.c | 15 +++++---------- tools/virsh-completer-interface.c | 3 +-- tools/virsh-completer-network.c | 14 ++++++-------- tools/virsh-completer-nodedev.c | 15 +++++---------- tools/virsh-completer-nwfilter.c | 6 ++---- tools/virsh-completer-pool.c | 15 +++++---------- tools/virsh-completer-secret.c | 10 ++++------ tools/virsh-completer-snapshot.c | 3 +-- tools/virsh-completer-volume.c | 3 +-- tools/virsh-completer.c | 8 ++++---- tools/virt-admin-completer.c | 3 +-- tools/virt-login-shell-helper.c | 17 +++++------------ tools/vsh-table.c | 3 +-- tools/vsh.c | 11 ++++------- 15 files changed, 46 insertions(+), 83 deletions(-) diff --git a/tools/virsh-completer-checkpoint.c b/tools/virsh-completer-che= ckpoint.c index ce9d32844d..21e8bb5d3b 100644 --- a/tools/virsh-completer-checkpoint.c +++ b/tools/virsh-completer-checkpoint.c @@ -56,8 +56,7 @@ virshCheckpointNameCompleter(vshControl *ctl, for (i =3D 0; i < ncheckpoints; i++) { const char *name =3D virDomainCheckpointGetName(checkpoints[i]); =20 - if (VIR_STRDUP(ret[i], name) < 0) - goto error; + ret[i] =3D g_strdup(name); =20 virshDomainCheckpointFree(checkpoints[i]); } diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index bb06f468d7..6bfa3ab58c 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -62,8 +62,7 @@ virshDomainNameCompleter(vshControl *ctl, for (i =3D 0; i < ndomains; i++) { const char *name =3D virDomainGetName(domains[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); @@ -181,10 +180,8 @@ virshDomainEventNameCompleter(vshControl *ctl G_GNUC_U= NUSED, if (VIR_ALLOC_N(tmp, VIR_DOMAIN_EVENT_ID_LAST + 1) < 0) return NULL; =20 - for (i =3D 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) { - if (VIR_STRDUP(tmp[i], virshDomainEventCallbacks[i].name) < 0) - return NULL; - } + for (i =3D 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) + tmp[i] =3D g_strdup(virshDomainEventCallbacks[i].name); =20 ret =3D g_steal_pointer(&tmp); return ret; @@ -242,11 +239,9 @@ virshDomainInterfaceStateCompleter(vshControl *ctl, =20 if ((state =3D virXPathString("string(./link/@state)", ctxt)) && STREQ(state, "down")) { - if (VIR_STRDUP(tmp[0], "up") < 0) - return NULL; + tmp[0] =3D g_strdup("up"); } else { - if (VIR_STRDUP(tmp[0], "down") < 0) - return NULL; + tmp[0] =3D g_strdup("down"); } =20 ret =3D g_steal_pointer(&tmp); diff --git a/tools/virsh-completer-interface.c b/tools/virsh-completer-inte= rface.c index 6fae0f6584..417374322a 100644 --- a/tools/virsh-completer-interface.c +++ b/tools/virsh-completer-interface.c @@ -53,8 +53,7 @@ virshInterfaceNameCompleter(vshControl *ctl, for (i =3D 0; i < nifaces; i++) { const char *name =3D virInterfaceGetName(ifaces[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); diff --git a/tools/virsh-completer-network.c b/tools/virsh-completer-networ= k.c index a3d8b71d19..0097fca7cc 100644 --- a/tools/virsh-completer-network.c +++ b/tools/virsh-completer-network.c @@ -55,8 +55,7 @@ virshNetworkNameCompleter(vshControl *ctl, for (i =3D 0; i < nnets; i++) { const char *name =3D virNetworkGetName(nets[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); @@ -83,10 +82,8 @@ virshNetworkEventNameCompleter(vshControl *ctl G_GNUC_UN= USED, if (VIR_ALLOC_N(tmp, VIR_NETWORK_EVENT_ID_LAST + 1) < 0) goto cleanup; =20 - for (i =3D 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) { - if (VIR_STRDUP(tmp[i], virshNetworkEventCallbacks[i].name) < 0) - goto cleanup; - } + for (i =3D 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) + tmp[i] =3D g_strdup(virshNetworkEventCallbacks[i].name); =20 ret =3D g_steal_pointer(&tmp); =20 @@ -124,10 +121,11 @@ virshNetworkPortUUIDCompleter(vshControl *ctl, for (i =3D 0; i < nports; i++) { char uuid[VIR_UUID_STRING_BUFLEN]; =20 - if (virNetworkPortGetUUIDString(ports[i], uuid) < 0 || - VIR_STRDUP(ret[i], uuid) < 0) + if (virNetworkPortGetUUIDString(ports[i], uuid) < 0) goto error; =20 + ret[i] =3D g_strdup(uuid); + virNetworkPortFree(ports[i]); } VIR_FREE(ports); diff --git a/tools/virsh-completer-nodedev.c b/tools/virsh-completer-nodede= v.c index 899c199902..6b01941911 100644 --- a/tools/virsh-completer-nodedev.c +++ b/tools/virsh-completer-nodedev.c @@ -53,8 +53,7 @@ virshNodeDeviceNameCompleter(vshControl *ctl, for (i =3D 0; i < ndevs; i++) { const char *name =3D virNodeDeviceGetName(devs[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); @@ -81,10 +80,8 @@ virshNodeDeviceEventNameCompleter(vshControl *ctl G_GNUC= _UNUSED, if (VIR_ALLOC_N(tmp, VIR_NODE_DEVICE_EVENT_ID_LAST + 1) < 0) return NULL; =20 - for (i =3D 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) { - if (VIR_STRDUP(tmp[i], virshNodeDeviceEventCallbacks[i].name) < 0) - return NULL; - } + for (i =3D 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) + tmp[i] =3D g_strdup(virshNodeDeviceEventCallbacks[i].name); =20 ret =3D g_steal_pointer(&tmp); return ret; @@ -108,10 +105,8 @@ virshNodeDeviceCapabilityNameCompleter(vshControl *ctl, if (VIR_ALLOC_N(tmp, VIR_NODE_DEV_CAP_LAST + 1) < 0) return NULL; =20 - for (i =3D 0; i < VIR_NODE_DEV_CAP_LAST; i++) { - if (VIR_STRDUP(tmp[i], virNodeDevCapTypeToString(i)) < 0) - return NULL; - } + for (i =3D 0; i < VIR_NODE_DEV_CAP_LAST; i++) + tmp[i] =3D g_strdup(virNodeDevCapTypeToString(i)); =20 return virshCommaStringListComplete(cap_str, (const char **)tmp); } diff --git a/tools/virsh-completer-nwfilter.c b/tools/virsh-completer-nwfil= ter.c index 5029becf09..989a363847 100644 --- a/tools/virsh-completer-nwfilter.c +++ b/tools/virsh-completer-nwfilter.c @@ -51,8 +51,7 @@ virshNWFilterNameCompleter(vshControl *ctl, for (i =3D 0; i < nnwfilters; i++) { const char *name =3D virNWFilterGetName(nwfilters[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); @@ -91,8 +90,7 @@ virshNWFilterBindingNameCompleter(vshControl *ctl, for (i =3D 0; i < nbindings; i++) { const char *name =3D virNWFilterBindingGetPortDev(bindings[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); diff --git a/tools/virsh-completer-pool.c b/tools/virsh-completer-pool.c index ceb73eed06..bd9d9a9802 100644 --- a/tools/virsh-completer-pool.c +++ b/tools/virsh-completer-pool.c @@ -56,8 +56,7 @@ virshStoragePoolNameCompleter(vshControl *ctl, for (i =3D 0; i < npools; i++) { const char *name =3D virStoragePoolGetName(pools[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); @@ -84,10 +83,8 @@ virshPoolEventNameCompleter(vshControl *ctl G_GNUC_UNUSE= D, if (VIR_ALLOC_N(tmp, VIR_STORAGE_POOL_EVENT_ID_LAST + 1) < 0) return NULL; =20 - for (i =3D 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) { - if (VIR_STRDUP(tmp[i], virshPoolEventCallbacks[i].name) < 0) - return NULL; - } + for (i =3D 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) + tmp[i] =3D g_strdup(virshPoolEventCallbacks[i].name); =20 ret =3D g_steal_pointer(&tmp); return ret; @@ -111,10 +108,8 @@ virshPoolTypeCompleter(vshControl *ctl, if (VIR_ALLOC_N(tmp, VIR_STORAGE_POOL_LAST + 1) < 0) return NULL; =20 - for (i =3D 0; i < VIR_STORAGE_POOL_LAST; i++) { - if (VIR_STRDUP(tmp[i], virStoragePoolTypeToString(i)) < 0) - return NULL; - } + for (i =3D 0; i < VIR_STORAGE_POOL_LAST; i++) + tmp[i] =3D g_strdup(virStoragePoolTypeToString(i)); =20 return virshCommaStringListComplete(type_str, (const char **)tmp); } diff --git a/tools/virsh-completer-secret.c b/tools/virsh-completer-secret.c index a533ac178f..bb02577c82 100644 --- a/tools/virsh-completer-secret.c +++ b/tools/virsh-completer-secret.c @@ -52,9 +52,9 @@ virshSecretUUIDCompleter(vshControl *ctl, for (i =3D 0; i < nsecrets; i++) { char uuid[VIR_UUID_STRING_BUFLEN]; =20 - if (virSecretGetUUIDString(secrets[i], uuid) < 0 || - VIR_STRDUP(tmp[i], uuid) < 0) + if (virSecretGetUUIDString(secrets[i], uuid) < 0) goto cleanup; + tmp[i] =3D g_strdup(uuid); } =20 ret =3D g_steal_pointer(&tmp); @@ -81,10 +81,8 @@ virshSecretEventNameCompleter(vshControl *ctl G_GNUC_UNU= SED, if (VIR_ALLOC_N(tmp, VIR_SECRET_EVENT_ID_LAST + 1) < 0) return NULL; =20 - for (i =3D 0; i < VIR_SECRET_EVENT_ID_LAST; i++) { - if (VIR_STRDUP(tmp[i], virshSecretEventCallbacks[i].name) < 0) - return NULL; - } + for (i =3D 0; i < VIR_SECRET_EVENT_ID_LAST; i++) + tmp[i] =3D g_strdup(virshSecretEventCallbacks[i].name); =20 ret =3D g_steal_pointer(&tmp); return ret; diff --git a/tools/virsh-completer-snapshot.c b/tools/virsh-completer-snaps= hot.c index 14bd7bc6e4..aa1135d132 100644 --- a/tools/virsh-completer-snapshot.c +++ b/tools/virsh-completer-snapshot.c @@ -58,8 +58,7 @@ virshSnapshotNameCompleter(vshControl *ctl, for (i =3D 0; i < nsnapshots; i++) { const char *name =3D virDomainSnapshotGetName(snapshots[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); diff --git a/tools/virsh-completer-volume.c b/tools/virsh-completer-volume.c index f14570f23d..ad54261534 100644 --- a/tools/virsh-completer-volume.c +++ b/tools/virsh-completer-volume.c @@ -58,8 +58,7 @@ virshStorageVolNameCompleter(vshControl *ctl, for (i =3D 0; i < nvols; i++) { const char *name =3D virStorageVolGetName(vols[i]); =20 - if (VIR_STRDUP(tmp[i], name) < 0) - goto cleanup; + tmp[i] =3D g_strdup(name); } =20 ret =3D g_steal_pointer(&tmp); diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index dd03c98a16..7e4bd895e5 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -100,8 +100,7 @@ virshCommaStringListComplete(const char *input, if (input) { char *comma =3D NULL; =20 - if (VIR_STRDUP(inputCopy, input) < 0) - return NULL; + inputCopy =3D g_strdup(input); =20 if ((comma =3D strrchr(inputCopy, ','))) *comma =3D '\0'; @@ -119,9 +118,10 @@ virshCommaStringListComplete(const char *input, if (virStringListHasString((const char **)inputList, options[i])) continue; =20 - if ((inputCopy && virAsprintf(&ret[nret], "%s,%s", inputCopy, opti= ons[i]) < 0) || - (!inputCopy && VIR_STRDUP(ret[nret], options[i]) < 0)) + if (inputCopy && virAsprintf(&ret[nret], "%s,%s", inputCopy, optio= ns[i]) < 0) return NULL; + if (!inputCopy) + ret[nret] =3D g_strdup(options[i]); =20 nret++; } diff --git a/tools/virt-admin-completer.c b/tools/virt-admin-completer.c index b8602efaf9..25dacf51d8 100644 --- a/tools/virt-admin-completer.c +++ b/tools/virt-admin-completer.c @@ -53,8 +53,7 @@ vshAdmServerCompleter(vshControl *ctl, for (i =3D 0; i < nsrvs; i++) { const char *name =3D virAdmServerGetName(srvs[i]); =20 - if (VIR_STRDUP(ret[i], name) < 0) - goto error; + ret[i] =3D g_strdup(name); =20 virAdmServerFree(srvs[i]); } diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index eb2b2dfe9e..ace8733968 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -102,10 +102,7 @@ static int virLoginShellGetShellArgv(virConfPtr conf, if (rv =3D=3D 0) { if (VIR_ALLOC_N(*shargv, 2) < 0) return -1; - if (VIR_STRDUP((*shargv)[0], "/bin/sh") < 0) { - VIR_FREE(*shargv); - return -1; - } + (*shargv)[0] =3D g_strdup("/bin/sh"); *shargvlen =3D 1; } else { *shargvlen =3D virStringListLength((const char *const *)shargv); @@ -347,10 +344,8 @@ main(int argc, char **argv) if (cmdstr) { if (VIR_REALLOC_N(shargv, shargvlen + 3) < 0) goto cleanup; - if (VIR_STRDUP(shargv[shargvlen++], "-c") < 0) - goto cleanup; - if (VIR_STRDUP(shargv[shargvlen++], cmdstr) < 0) - goto cleanup; + shargv[shargvlen++] =3D g_strdup("-c"); + shargv[shargvlen++] =3D g_strdup(cmdstr); shargv[shargvlen] =3D NULL; } =20 @@ -366,15 +361,13 @@ main(int argc, char **argv) goto cleanup; } tmp =3D strrchr(shcmd, '/'); - if (VIR_STRDUP(shargv[0], tmp) < 0) - goto cleanup; + shargv[0] =3D g_strdup(tmp); shargv[0][0] =3D '-'; =20 /* We're duping the string because the clearenv() * call will shortly release the pointer we get * back from getenv() right here */ - if (VIR_STRDUP(term, getenv("TERM")) < 0) - goto cleanup; + term =3D g_strdup(getenv("TERM")); =20 /* A fork is required to create new process in correct pid namespace. = */ if ((cpid =3D virFork()) < 0) diff --git a/tools/vsh-table.c b/tools/vsh-table.c index 8bd6d99778..c2271a4e2d 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -104,8 +104,7 @@ vshTableRowNew(const char *arg, va_list ap) while (arg) { char *tmp =3D NULL; =20 - if (VIR_STRDUP(tmp, arg) < 0) - goto error; + tmp =3D g_strdup(arg); =20 if (VIR_APPEND_ELEMENT(row->cells, row->ncells, tmp) < 0) { VIR_FREE(tmp); diff --git a/tools/vsh.c b/tools/vsh.c index a10a9625e4..3ef0031ee2 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -495,8 +495,7 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cm= d, const char *name, opt->help =3D "string=3Dvalue": treat boolean flag as alias of option and its default value */ sa_assert(!alias); - if (VIR_STRDUP(alias, opt->help) < 0) - goto cleanup; + alias =3D g_strdup(opt->help); name =3D alias; if ((value =3D strchr(name, '=3D'))) { *value =3D '\0'; @@ -506,8 +505,7 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cm= d, const char *name, opt->name); goto cleanup; } - if (VIR_STRDUP(*optstr, value + 1) < 0) - goto cleanup; + *optstr =3D g_strdup(value + 1); } continue; } @@ -3499,9 +3497,8 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) =20 vshReadlineInit(ctl); =20 - if (!(rl_line_buffer =3D virBufferContentAndReset(&buf)) && - VIR_STRDUP(rl_line_buffer, "") < 0) - goto cleanup; + if (!(rl_line_buffer =3D virBufferContentAndReset(&buf))) + rl_line_buffer =3D g_strdup(""); =20 /* rl_point is current cursor position in rl_line_buffer. * In our case it's at the end of the whole line. */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 20:29:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571576221; cv=none; d=zoho.com; s=zohoarc; b=MfzqJfpCa8f96/RFShoPP9lhorNaOxpGNWThL7yDLS1qBXqBjl1Va2Bd1ZqEV28v6DHiSernYNKtl/UJANK3V+XyBnNfDhcyEQwkDaWyHs/m+a7uD1DArOcEe/cmu7lC8SdKQOtNAk/BbejytgRoDjPVBRYLM4Rk230EEYIAIyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576221; 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=mPJi7Hw58F2C5Do5V+tjXY9KyyXgAyQ3ICTqIumdnQ0=; b=TJ4wQnMsMEF/i7crbfs9eF0UgX1t7B5C0K28GYr5yHnu+ecEfDqUo4YLmmBgpvLk68PuTd4BumPYIWKV0hhStS/uy2ttxl6Zbuuhnk94HmCwIGU9uSha0NXxufeVzyGL3cIrFp1SobRTcyEAbnXmqm5XGVreoze2bh6PHMESrYk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 157157622154847.39353648607596; Sun, 20 Oct 2019 05:57:01 -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-25-KBlm_IFJM5ykC03IilUWEQ-1; Sun, 20 Oct 2019 08:56:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD2885EF; Sun, 20 Oct 2019 12:56:53 +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 9A15E100EBDC; Sun, 20 Oct 2019 12:56:53 +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 596CB1803B5A; Sun, 20 Oct 2019 12:56:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9KCuGTl023670 for ; Sun, 20 Oct 2019 08:56:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F9BB3DA3; Sun, 20 Oct 2019 12:56:16 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75C7B194B9 for ; Sun, 20 Oct 2019 12:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576220; 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=mPJi7Hw58F2C5Do5V+tjXY9KyyXgAyQ3ICTqIumdnQ0=; b=HUL9p0k++q5i5QJ5inoEs+6J0c4LMPo2BvZAFhFkhKc1uL3D5QUBUxj+zoQX0OX9rrueGx KHAN9STNDC2OXlJb0gc7ASgZlZanq4NHMBI2HJxVwf/pmofwUJWoOmi9ett2rxLBgD3Ed5 4M1FVehf1MdiVWhIi9UiWuZ+Nyh3DWo= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:52 +0200 Message-Id: <84a072a358326d340eb95b84e087f26193afa7ad.1571575890.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 34/34] Use g_strdup instead of VIR_STRDUP everywhere X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: KBlm_IFJM5ykC03IilUWEQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/admin/admin_server_dispatch.c | 3 +-- src/hyperv/hyperv_driver.c | 13 ++++--------- src/hyperv/hyperv_util.c | 3 +-- src/libvirt-admin.c | 18 ++++++------------ src/libvirt.c | 16 +++++----------- src/openvz/openvz_conf.c | 14 ++++---------- src/openvz/openvz_driver.c | 12 ++++-------- src/phyp/phyp_driver.c | 25 ++++++++----------------- src/vmware/vmware_conf.c | 11 +++-------- src/vmware/vmware_driver.c | 6 ++---- src/vmx/vmx.c | 14 +++++++------- src/vz/vz_driver.c | 3 +-- src/vz/vz_sdk.c | 29 +++++++++-------------------- 13 files changed, 55 insertions(+), 112 deletions(-) diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dis= patch.c index e56da3ba9f..0956084301 100644 --- a/src/admin/admin_server_dispatch.c +++ b/src/admin/admin_server_dispatch.c @@ -139,8 +139,7 @@ static int G_GNUC_WARN_UNUSED_RESULT make_nonnull_server(admin_nonnull_server *srv_dst, virNetServerPtr srv_src) { - if (VIR_STRDUP(srv_dst->name, virNetServerGetName(srv_src)) < 0) - return -1; + srv_dst->name =3D g_strdup(virNetServerGetName(srv_src)); return 0; } =20 diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index d69542b500..542253b8b8 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -149,8 +149,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr= auth, =20 /* Request credentials */ if (conn->uri->user !=3D NULL) { - if (VIR_STRDUP(username, conn->uri->user) < 0) - goto cleanup; + username =3D g_strdup(conn->uri->user); } else { if (!(username =3D virAuthGetUsername(conn, auth, "hyperv", "administrator", @@ -846,13 +845,10 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned = int flags) return NULL; } =20 - if (VIR_STRDUP(def->name, computerSystem->data.common->ElementName) < = 0) - goto cleanup; + def->name =3D g_strdup(computerSystem->data.common->ElementName); =20 if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V1) { - if (VIR_STRDUP(def->description, - virtualSystemSettingData->data.v1->Notes) < 0) - goto cleanup; + def->description =3D g_strdup(virtualSystemSettingData->data.v1->N= otes); } else if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V2 && virtualSystemSettingData->data.v2->Notes.data !=3D NULL) { char **notes =3D (char **)virtualSystemSettingData->data.v2->Notes= .data; @@ -935,8 +931,7 @@ hypervConnectListDefinedDomains(virConnectPtr conn, cha= r **const names, int maxn =20 for (computerSystem =3D computerSystemList; computerSystem !=3D NULL; computerSystem =3D computerSystem->next) { - if (VIR_STRDUP(names[count], computerSystem->data.common->ElementN= ame) < 0) - goto cleanup; + names[count] =3D g_strdup(computerSystem->data.common->ElementName= ); =20 ++count; =20 diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c index 3b84713426..2425d6a0c6 100644 --- a/src/hyperv/hyperv_util.c +++ b/src/hyperv/hyperv_util.c @@ -54,8 +54,7 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri) if (STRCASEEQ(queryParam->name, "transport")) { VIR_FREE((*parsedUri)->transport); =20 - if (VIR_STRDUP((*parsedUri)->transport, queryParam->value) < 0) - goto cleanup; + (*parsedUri)->transport =3D g_strdup(queryParam->value); =20 if (STRNEQ((*parsedUri)->transport, "http") && STRNEQ((*parsedUri)->transport, "https")) { diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c index 93c73615e3..9a18ea0f8b 100644 --- a/src/libvirt-admin.c +++ b/src/libvirt-admin.c @@ -112,8 +112,7 @@ getSocketPath(virURIPtr uri) =20 if (STREQ(param->name, "socket")) { VIR_FREE(sock_path); - if (VIR_STRDUP(sock_path, param->value) < 0) - goto error; + sock_path =3D g_strdup(param->value); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown URI parameter '%s'"), param->name); @@ -140,8 +139,7 @@ getSocketPath(virURIPtr uri) } =20 if (legacy) { - if (VIR_STRDUP(sockbase, "libvirt-admin-sock") < 0) - goto error; + sockbase =3D g_strdup("libvirt-admin-sock"); } else { if (virAsprintf(&sockbase, "%s-admin-sock", uri->scheme) < 0) goto error; @@ -177,8 +175,7 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr) { const char *defname =3D getenv("LIBVIRT_ADMIN_DEFAULT_URI"); if (defname && *defname) { - if (VIR_STRDUP(*uristr, defname) < 0) - return -1; + *uristr =3D g_strdup(defname); VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", *uristr); } else { if (virConfGetValueString(conf, "uri_default", uristr) < 0) @@ -194,11 +191,9 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr) * 'libvirtd:///session' depending on the process's EUID. */ if (geteuid() =3D=3D 0) { - if (VIR_STRDUP(*uristr, "libvirtd:///system") < 0) - return -1; + *uristr =3D g_strdup("libvirtd:///system"); } else { - if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0) - return -1; + *uristr =3D g_strdup("libvirtd:///session"); } } } @@ -238,8 +233,7 @@ virAdmConnectOpen(const char *name, unsigned int flags) goto error; =20 if (name) { - if (VIR_STRDUP(uristr, name) < 0) - goto error; + uristr =3D g_strdup(name); } else { if (virAdmGetDefaultURI(conf, &uristr) < 0) goto error; diff --git a/src/libvirt.c b/src/libvirt.c index 812cb9efde..33b43305a1 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -173,10 +173,7 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr = cred, } =20 if (cred[i].type !=3D VIR_CRED_EXTERNAL) { - if (VIR_STRDUP(cred[i].result, - STREQ(bufptr, "") && cred[i].defresult ? - cred[i].defresult : bufptr) < 0) - return -1; + cred[i].result =3D g_strdup(STREQ(bufptr, "") && cred[i].defre= sult ? cred[i].defresult : bufptr); cred[i].resultlen =3D strlen(cred[i].result); } } @@ -803,8 +800,7 @@ virConnectGetDefaultURI(virConfPtr conf, const char *defname =3D getenv("LIBVIRT_DEFAULT_URI"); if (defname && *defname) { VIR_DEBUG("Using LIBVIRT_DEFAULT_URI '%s'", defname); - if (VIR_STRDUP(*name, defname) < 0) - goto cleanup; + *name =3D g_strdup(defname); } else { if (virConfGetValueString(conf, "uri_default", name) < 0) goto cleanup; @@ -885,8 +881,7 @@ virConnectOpenInternal(const char *name, * if detectable. */ if (name) { - if (VIR_STRDUP(uristr, name) < 0) - goto failed; + uristr =3D g_strdup(name); } else { if (virConnectGetDefaultURI(conf, &uristr) < 0) goto failed; @@ -924,9 +919,8 @@ virConnectOpenInternal(const char *name, =20 /* Avoid need for drivers to worry about NULLs, as * no one needs to distinguish "" vs NULL */ - if (ret->uri->path =3D=3D NULL && - VIR_STRDUP(ret->uri->path, "") < 0) - goto failed; + if (ret->uri->path =3D=3D NULL) + ret->uri->path =3D g_strdup(""); =20 VIR_DEBUG("Split \"%s\" to URI components:\n" " scheme %s\n" diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index e5ef426329..4646308c48 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -348,8 +348,7 @@ openvzReadFSConf(virDomainDefPtr def, goto error; =20 fs->type =3D VIR_DOMAIN_FS_TYPE_TEMPLATE; - if (VIR_STRDUP(fs->src->path, temp) < 0) - goto error; + fs->src->path =3D g_strdup(temp); } else { /* OSTEMPLATE was not found, VE was booted from a private dir dire= ctly */ ret =3D openvzReadVPSConfigParam(veid, "VE_PRIVATE", &temp); @@ -373,8 +372,7 @@ openvzReadFSConf(virDomainDefPtr def, VIR_FREE(veid_str); } =20 - if (VIR_STRDUP(fs->dst, "/") < 0) - goto error; + fs->dst =3D g_strdup("/"); =20 param =3D "DISKSPACE"; ret =3D openvzReadVPSConfigParam(veid, param, &temp); @@ -549,8 +547,7 @@ int openvzLoadDomains(struct openvz_driver *driver) } =20 def->os.type =3D VIR_DOMAIN_OSTYPE_EXE; - if (VIR_STRDUP(def->os.init, "/sbin/init") < 0) - goto cleanup; + def->os.init =3D g_strdup("/sbin/init"); =20 ret =3D openvzReadVPSConfigParam(veid, "CPUS", &temp); if (ret < 0) { @@ -727,10 +724,7 @@ openvzReadConfigParam(const char *conf_file, const cha= r *param, char **value) saveptr =3D NULL; if ((token =3D strtok_r(sf, "\"\t\n", &saveptr)) !=3D NULL) { VIR_FREE(*value); - if (VIR_STRDUP(*value, token) < 0) { - err =3D 1; - break; - } + *value =3D g_strdup(token); /* keep going - last entry wins */ } } diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index bf399986a7..017eec3081 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -118,10 +118,8 @@ openvzDomainDefPostParse(virDomainDefPtr def, void *parseOpaque G_GNUC_UNUSED) { /* fill the init path */ - if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE && !def->os.init) { - if (VIR_STRDUP(def->os.init, "/sbin/init") < 0) - return -1; - } + if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_EXE && !def->os.init) + def->os.init =3D g_strdup("/sbin/init"); =20 return 0; } @@ -780,8 +778,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *= vpsid, /* if net is ethernet and the user has specified guest interface n= ame, * let's use it; otherwise generate a new one */ if (net->ifname_guest) { - if (VIR_STRDUP(guest_ifname, net->ifname_guest) < 0) - goto cleanup; + guest_ifname =3D g_strdup(net->ifname_guest); } else { guest_ifname =3D openvzGenerateContainerVethName(veid); if (guest_ifname =3D=3D NULL) { @@ -1507,8 +1504,7 @@ static int openvzConnectListDefinedDomains(virConnect= Ptr conn G_GNUC_UNUSED, continue; } snprintf(vpsname, sizeof(vpsname), "%d", veid); - if (VIR_STRDUP(names[got], vpsname) < 0) - goto out; + names[got] =3D g_strdup(vpsname); got ++; } =20 diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 4527adc670..8b1d804233 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -946,8 +946,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr au= th, goto err; =20 if (conn->uri->user !=3D NULL) { - if (VIR_STRDUP(username, conn->uri->user) < 0) - goto err; + username =3D g_strdup(conn->uri->user); } else { if (!(username =3D virAuthGetUsername(conn, auth, "ssh", NULL, conn->uri->server))) @@ -1124,9 +1123,7 @@ phypConnectOpen(virConnectPtr conn, =20 if (conn->uri->path[0] !=3D '\0') { /* need to shift one byte in order to remove the first "/" of URI = component */ - if (VIR_STRDUP(managed_system, - conn->uri->path + (conn->uri->path[0] =3D=3D '/')) = < 0) - goto failure; + managed_system =3D g_strdup(conn->uri->path + (conn->uri->path[0] = =3D=3D '/')); =20 /* here we are handling only the first component of the path, * so skipping the second: @@ -1465,8 +1462,7 @@ phypGetBackingDevice(virConnectPtr conn, const char *= managed_system, else goto cleanup; =20 - if (VIR_STRDUP(backing_device, char_ptr) < 0) - goto cleanup; + backing_device =3D g_strdup(char_ptr); } else { backing_device =3D g_steal_pointer(&ret); } @@ -2228,8 +2224,7 @@ phypStorageVolGetXMLDesc(virStorageVolPtr vol, unsign= ed int flags) goto cleanup; } =20 - if (VIR_STRDUP(voldef.key, vol->key) < 0) - goto cleanup; + voldef.key =3D g_strdup(vol->key); =20 voldef.type =3D VIR_STORAGE_POOL_LOGICAL; =20 @@ -2338,8 +2333,7 @@ phypStoragePoolListVolumes(virStoragePoolPtr pool, ch= ar **const volumes, =20 if (char_ptr) { *char_ptr =3D '\0'; - if (VIR_STRDUP(volumes[got++], volumes_list) < 0) - goto cleanup; + volumes[got++] =3D g_strdup(volumes_list); char_ptr++; volumes_list =3D char_ptr; } else { @@ -2532,8 +2526,7 @@ phypConnectListStoragePools(virConnectPtr conn, char = **const pools, int npools) =20 if (char_ptr) { *char_ptr =3D '\0'; - if (VIR_STRDUP(pools[got++], storage_pools) < 0) - goto cleanup; + pools[got++] =3D g_strdup(storage_pools); char_ptr++; storage_pools =3D char_ptr; } else { @@ -2985,8 +2978,7 @@ phypConnectListInterfaces(virConnectPtr conn, char **= const names, int nnames) =20 if (char_ptr) { *char_ptr =3D '\0'; - if (VIR_STRDUP(names[got++], networks) < 0) - goto cleanup; + names[got++] =3D g_strdup(networks); char_ptr++; networks =3D char_ptr; } else { @@ -3146,8 +3138,7 @@ phypConnectListDefinedDomains(virConnectPtr conn, cha= r **const names, int nnames =20 if (char_ptr) { *char_ptr =3D '\0'; - if (VIR_STRDUP(names[got++], domains) < 0) - goto cleanup; + names[got++] =3D g_strdup(domains); char_ptr++; domains =3D char_ptr; } else { diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 207af8fe81..8707f842ad 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -175,8 +175,7 @@ vmwareLoadDomains(struct vmware_driver *driver) =20 pDomain =3D vm->privateData; =20 - if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0) - goto cleanup; + pDomain->vmxPath =3D g_strdup(vmxPath); =20 vmwareDomainConfigDisplay(pDomain, vmdef); =20 @@ -354,14 +353,10 @@ vmwareParsePath(const char *path, char **directory, c= har **filename) =20 if (VIR_STRNDUP(*directory, path, separator - path - 1) < 0) goto error; - if (VIR_STRDUP(*filename, separator) < 0) { - VIR_FREE(*directory); - goto error; - } + *filename =3D g_strdup(separator); =20 } else { - if (VIR_STRDUP(*filename, path) < 0) - goto error; + *filename =3D g_strdup(path); } =20 return 0; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 912827a921..83974531d5 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -447,8 +447,7 @@ vmwareDomainDefineXMLFlags(virConnectPtr conn, const ch= ar *xml, unsigned int fla goto cleanup; =20 pDomain =3D vm->privateData; - if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0) - goto cleanup; + pDomain->vmxPath =3D g_strdup(vmxPath); =20 vmwareDomainConfigDisplay(pDomain, vmdef); =20 @@ -708,8 +707,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *x= ml, goto cleanup; =20 pDomain =3D vm->privateData; - if (VIR_STRDUP(pDomain->vmxPath, vmxPath) < 0) - goto cleanup; + pDomain->vmxPath =3D g_strdup(vmxPath); =20 vmwareDomainConfigDisplay(pDomain, vmdef); vmdef =3D NULL; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index c9a80ba35d..0d1d87bac6 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1085,8 +1085,7 @@ virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr = def, if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SCSI || !driver) return 0; =20 - if (VIR_STRDUP(copy, driver) < 0) - return -1; + copy =3D g_strdup(driver); tmp =3D copy; =20 for (; *tmp !=3D '\0'; ++tmp) @@ -1812,13 +1811,15 @@ virVMXParseConfig(virVMXContext *ctx, if (ctx->datacenterPath || ctx->moref) { struct virVMXDomainDefNamespaceData *nsdata =3D NULL; =20 - if (VIR_ALLOC(nsdata) < 0 || - VIR_STRDUP(nsdata->datacenterPath, ctx->datacenterPath) < 0 || - VIR_STRDUP(nsdata->moref, ctx->moref) < 0) { + if (VIR_ALLOC(nsdata) < 0) { virVMXDomainDefNamespaceFree(nsdata); goto cleanup; } =20 + nsdata->datacenterPath =3D g_strdup(ctx->datacenterPath); + + nsdata->moref =3D g_strdup(ctx->moref); + def->ns =3D *virDomainXMLOptionGetNamespace(xmlopt); def->namespaceData =3D nsdata; } @@ -2839,8 +2840,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf= , int port, goto cleanup; } =20 - if (VIR_STRDUP((*def)->source->data.tcp.host, parsedUri->server) <= 0) - goto cleanup; + (*def)->source->data.tcp.host =3D g_strdup(parsedUri->server); =20 if (virAsprintf(&(*def)->source->data.tcp.service, "%d", parsedUri->port) < 0) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 76b23788b8..5b54f83b22 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -3015,8 +3015,7 @@ vzDomainMigratePrepare3Params(virConnectPtr conn, =20 if (dname) { VIR_FREE(def->name); - if (VIR_STRDUP(def->name, dname) < 0) - goto cleanup; + def->name =3D g_strdup(dname); } =20 if (virDomainMigratePrepare3ParamsEnsureACL(conn, def) < 0) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 68284d53f7..e7c1676df9 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -501,8 +501,7 @@ prlsdkUUIDParse(const char *uuidstr, unsigned char *uui= d) virCheckNonNullArgGoto(uuidstr, error); virCheckNonNullArgGoto(uuid, error); =20 - if (VIR_STRDUP(tmp, uuidstr) < 0) - goto error; + tmp =3D g_strdup(uuidstr); =20 tmp[strlen(tmp) - 1] =3D '\0'; =20 @@ -774,10 +773,8 @@ prlsdkGetFSInfo(PRL_HANDLE prldisk, fs->type =3D VIR_DOMAIN_FS_TYPE_VOLUME; if (VIR_ALLOC(fs->src->srcpool) < 0) goto cleanup; - if (VIR_STRDUP(fs->src->srcpool->pool, matches[1]) < 0) - goto cleanup; - if (VIR_STRDUP(fs->src->srcpool->volume, matches[2]) < 0) - goto cleanup; + fs->src->srcpool->pool =3D g_strdup(matches[1]); + fs->src->srcpool->volume =3D g_strdup(matches[2]); VIR_FREE(buf); } else { fs->type =3D VIR_DOMAIN_FS_TYPE_FILE; @@ -1054,9 +1051,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetD= efPtr net, bool isCt) * always up */ net->linkstate =3D VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP; net->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; - if (VIR_STRDUP(net->data.network.name, - PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0) - goto cleanup; + net->data.network.name =3D g_strdup(PARALLELS_DOMAIN_ROUTED_NETWOR= K_NAME); return 0; } =20 @@ -1078,9 +1073,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetD= efPtr net, bool isCt) =20 if (emulatedType =3D=3D PNA_ROUTED) { net->type =3D VIR_DOMAIN_NET_TYPE_NETWORK; - if (VIR_STRDUP(net->data.network.name, - PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0) - goto cleanup; + net->data.network.name =3D g_strdup(PARALLELS_DOMAIN_ROUTED_NETWOR= K_NAME); } else { char *netid =3D prlsdkGetStringParamVar(PrlVmDevNet_GetVirtualNetworkId, @@ -1224,8 +1217,7 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainC= hrDefPtr chr) goto cleanup; if (!(uri =3D virURIParse(uristr))) goto cleanup; - if (VIR_STRDUP(chr->source->data.tcp.host, uri->server) < 0) - goto cleanup; + chr->source->data.tcp.host =3D g_strdup(uri->server); if (virAsprintf(&chr->source->data.tcp.service, "%d", uri->port) <= 0) goto cleanup; chr->source->data.tcp.listen =3D socket_mode =3D=3D PSP_SERIAL_SOC= KET_SERVER; @@ -1236,12 +1228,10 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomai= nChrDefPtr chr) goto cleanup; if (!(uri =3D virURIParse(uristr))) goto cleanup; - if (VIR_STRDUP(chr->source->data.udp.bindHost, uri->server) < 0) - goto cleanup; + chr->source->data.udp.bindHost =3D g_strdup(uri->server); if (virAsprintf(&chr->source->data.udp.bindService, "%d", uri->por= t) < 0) goto cleanup; - if (VIR_STRDUP(chr->source->data.udp.connectHost, uri->server) < 0) - goto cleanup; + chr->source->data.udp.connectHost =3D g_strdup(uri->server); if (virAsprintf(&chr->source->data.udp.connectService, "%d", uri->= port) < 0) goto cleanup; break; @@ -1526,8 +1516,7 @@ prlsdkConvertDomainType(PRL_HANDLE sdkdom, virDomainD= efPtr def) break; case PVT_CT: def->os.type =3D VIR_DOMAIN_OSTYPE_EXE; - if (VIR_STRDUP(def->os.init, "/sbin/init") < 0) - return -1; + def->os.init =3D g_strdup("/sbin/init"); break; default: virReportError(VIR_ERR_INTERNAL_ERROR, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list