From nobody Wed May 15 21:01:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530671532499574.2896435550289; Tue, 3 Jul 2018 19:32:12 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id DC316356C0; Wed, 4 Jul 2018 02:32:10 +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 8DAA660BE4; Wed, 4 Jul 2018 02:32:10 +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 254EA18037F0; Wed, 4 Jul 2018 02:32:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w642W7n6014415 for ; Tue, 3 Jul 2018 22:32:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id C63991001643; Wed, 4 Jul 2018 02:32:07 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAE2B1001642 for ; Wed, 4 Jul 2018 02:32:04 +0000 (UTC) Received: from mail-qk0-f171.google.com (mail-qk0-f171.google.com [209.85.220.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 454D330001DE for ; Wed, 4 Jul 2018 02:31:53 +0000 (UTC) Received: by mail-qk0-f171.google.com with SMTP id t79-v6so2145741qke.4 for ; Tue, 03 Jul 2018 19:31:53 -0700 (PDT) Received: from localhost.localdomain ([186.212.94.231]) by smtp.gmail.com with ESMTPSA id b62-v6sm2033363qkj.48.2018.07.03.19.31.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jul 2018 19:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IAcITLrQZ5HqdgFz+nxxhhZULEeHWu/R2sWhaYYGnPg=; b=FxgonVoSLmFxgzAO5mkwKOa6dt22BzMrFyAmYAwd4JGxITeJ+OPPEIph2Xww6ZJg7O zs0BVr0hOcm6SlZdUXxEKPiHmRL0s4ljoyu/yWCsIbn+fr5m46PtywmHY80pIRehQABU wYdKCGq57ZPzvjtrae1FYTU6FelukSRCO00nxEyjnYEO60LzW47rhm9+hVdbSIBDLvTJ 7WmHl3R6dJXydn7u1Ho/hNKKTsywGZkGd+lKAW75mOILvlO70Ry+xQ0WLT119xtESFFk 9UdZfjzX155zI3COJmLI9lIgFRYTHaSchFlJEDBDU3bOL65SlqNImV0z9c/Z5iZoZ95U ycaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IAcITLrQZ5HqdgFz+nxxhhZULEeHWu/R2sWhaYYGnPg=; b=jH2KitiYs2+731+wVnvVDtA3zHBjonR8oRZDSIp3r59aUtkc9aKnEwrx3MOkPpBtnH G4eLe8wPB3lH1rzihQrsxH1yX5HhEyM6MUQX6SmByKp2TF+4cK4QJDnoPei+QJst63/P NJwMYbYZAZjG1RFW8UMgfBlrlhhiXXfbBlQ7HRHTcaqLWTf9mrhKyJyyFlrY8aTee7Wh jHSKDWw3+aAKWv3lNSFWXGQrObw025prqCsYa0rNnYrHTTAbSbqfHD5OxIEUVAjd51of CDTZImWEvwZef+Bz8yO+USYR83sMvwwACmsjHgQdazvLlBZeMDPHmUlTFPxDIwah/E7g T0/A== X-Gm-Message-State: APt69E2oUgMRmSS1mxnkLhYKOGBRlCjWRueExKKyVIwNl4N0s3zfdbWK 35FSepNexmqU0u65JitDvNPQmg== X-Google-Smtp-Source: AAOMgpdTFGpy0Xz5t3qh2rvGrCB1usVTbMN3WegS4FHyEaHNf8/z1+krtMalAAx+QOxMdbKITONGkw== X-Received: by 2002:a37:c44d:: with SMTP id h13-v6mr122574qkm.422.1530671512104; Tue, 03 Jul 2018 19:31:52 -0700 (PDT) From: Marcos Paulo de Souza To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 23:31:22 -0300 Message-Id: <20180704023123.8271-2-marcos.souza.org@gmail.com> In-Reply-To: <20180704023123.8271-1-marcos.souza.org@gmail.com> References: <20180704023123.8271-1-marcos.souza.org@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 04 Jul 2018 02:31:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 04 Jul 2018 02:31:53 +0000 (UTC) for IP:'209.85.220.171' DOMAIN:'mail-qk0-f171.google.com' HELO:'mail-qk0-f171.google.com' FROM:'marcos.souza.org@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.3 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.220.171 mail-qk0-f171.google.com 209.85.220.171 mail-qk0-f171.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Marcos Paulo de Souza Subject: [libvirt] [PATCH -v2 1/2] esx_util.h: Add ESX_VI_CHECK_ARG_LIST macro 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 04 Jul 2018 02:32:11 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This macro avoids code duplication when checking for arrays of objects. Signed-off-by: Marcos Paulo de Souza --- Changes from v1: * Change VIR_ERR_INVALID_ARG to VIR_ERR_INTERNAL_ERROR (Michal) * Change esxVI_checkArgList to ESX_VI_CHECK_ARG_LIST (Matthias) src/esx/esx_util.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h index c6f14bb2d9..63602bf3cb 100644 --- a/src/esx/esx_util.h +++ b/src/esx/esx_util.h @@ -26,6 +26,14 @@ # include "internal.h" # include "viruri.h" =20 +#define ESX_VI_CHECK_ARG_LIST(val) \ + do { \ + if (!val || *val) { \ + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argume= nt")); \ + return -1; \ + } \ + } while (0) + typedef struct _esxUtil_ParsedUri esxUtil_ParsedUri; =20 struct _esxUtil_ParsedUri { --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 15 21:01:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530671556378640.5464593501403; Tue, 3 Jul 2018 19:32:36 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id CAE52FEBD; Wed, 4 Jul 2018 02:32:34 +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 80C281001643; Wed, 4 Jul 2018 02:32:34 +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 3A06918037F1; Wed, 4 Jul 2018 02:32:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w642W965014433 for ; Tue, 3 Jul 2018 22:32:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 890221001643; Wed, 4 Jul 2018 02:32:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EA621001642 for ; Wed, 4 Jul 2018 02:32:09 +0000 (UTC) Received: from mail-qt0-f171.google.com (mail-qt0-f171.google.com [209.85.216.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55B4F308FB97 for ; Wed, 4 Jul 2018 02:31:57 +0000 (UTC) Received: by mail-qt0-f171.google.com with SMTP id y31-v6so3397697qty.9 for ; Tue, 03 Jul 2018 19:31:57 -0700 (PDT) Received: from localhost.localdomain ([186.212.94.231]) by smtp.gmail.com with ESMTPSA id b62-v6sm2033363qkj.48.2018.07.03.19.31.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jul 2018 19:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ga/mHqb2zZ1+DpPEkaIB3ZGqoGQgklzs+WGSOcOf8mg=; b=XYui8rFjUfDvL/4O9gnPFwRwKaJeMEkn6ixyDkReBou7KqXHmI4FXzijW1SX4EI0Ff m/16tAHw8Om8GoqEQBMCFjvNwXZa4XDUfUWMWK9lxz+T/PL4MS8Y+OhA8jpZcAqRkqk6 lpdckwCMSM4C5m7iyONvjNp9GgUO/1emxt/X5UB6Jv8hJaSI/1+m8329gtNqLz6aH1fY 1Ci0R7QchFEMbXa8Vr6CiVfpIaE/MWbEMjpZQSYVqeHpmvEuxQ+W5Cd06QpCTyAGDO+0 aszWV3GuMO+QufPabooIi6uxUPXRV0zQJMiZulAeB9aMTaEqI0Op63vhdtHjvbqsQg8S 8/gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ga/mHqb2zZ1+DpPEkaIB3ZGqoGQgklzs+WGSOcOf8mg=; b=F0DNWZ6m2uJReLTvDOhNDXrJAQz7FyvSF/Z+FoER++EAHmVRUTmjC6gCa5dmEwl9xs dKx5Ymrn8HaOp0FxMqkfUq2WUK1pXk/QfXV3EevjJ6KzZ/QkicDfQEUuWcoImKlSGwdx zF+VFKUi/Eb57gQ6MzX7F0J6b/a1d4nnFMlx6wtcYHGJdzstIk9AGPtsoIGW5YjEX8LB 3jKr24U8Fd7GRxfWxkOytMpTc+A6ZifQZ38hubUXs79ebI2qTlY9TOqNSsLUyXqc2NWH oF+5dLNgdm6PRTi9ay2H0V6fDXho6MjqcygnZNDUFeRF0kyenHea2+8P0UmKnwTMOOx3 92KQ== X-Gm-Message-State: APt69E3EYqdPckH1znfaKRX5TITT1I70Dp9n59ydNYv1hViN7ulobzOk PN7/wSLAKYBtOeH6DMADt5Rs0Q== X-Google-Smtp-Source: AAOMgpcR8RnZnqQIB7BYkjFTP8tcB5zTgVh+QKWA/KYZUH7Z2gEzNfmf405ijiR+03JviwIV87A7jw== X-Received: by 2002:ac8:269b:: with SMTP id 27-v6mr124674qto.281.1530671516040; Tue, 03 Jul 2018 19:31:56 -0700 (PDT) From: Marcos Paulo de Souza To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 23:31:23 -0300 Message-Id: <20180704023123.8271-3-marcos.souza.org@gmail.com> In-Reply-To: <20180704023123.8271-1-marcos.souza.org@gmail.com> References: <20180704023123.8271-1-marcos.souza.org@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 04 Jul 2018 02:31:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 04 Jul 2018 02:31:57 +0000 (UTC) for IP:'209.85.216.171' DOMAIN:'mail-qt0-f171.google.com' HELO:'mail-qt0-f171.google.com' FROM:'marcos.souza.org@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.216.171 mail-qt0-f171.google.com 209.85.216.171 mail-qt0-f171.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Marcos Paulo de Souza Subject: [libvirt] [PATCH -v2 2/2] esx: Use ESX_VI_CHECK_ARG_LIST macro to avoid code duplication 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 04 Jul 2018 02:32:35 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By using this macro we can avoid boilerplate code to check for arrays of objects from ESX driver. This replacement was done using the coccinelle script bellow: @@ identifier ptr; @@ -if (!ptr || *ptr) { ... } +ESX_VI_CHECK_ARG_LIST(ptr); Signed-off-by: Marcos Paulo de Souza --- Changes from v1: * Use ESX_VI_CHECK_ARG_LIST macro from previous patch * Use coccinelle script to check for all files inside esx directory src/esx/esx_driver.c | 5 +- src/esx/esx_network_driver.c | 10 +-- src/esx/esx_util.c | 5 +- src/esx/esx_vi.c | 165 +++++++---------------------------- src/esx/esx_vi_methods.c | 10 +-- src/esx/esx_vi_types.c | 51 +++-------- 6 files changed, 49 insertions(+), 197 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 01bcc99962..06e1238385 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -626,10 +626,7 @@ esxConnectToHost(esxPrivate *priv, ? esxVI_ProductLine_ESX : esxVI_ProductLine_GSX; =20 - if (!vCenterIPAddress || *vCenterIPAddress) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(vCenterIPAddress); =20 if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) = < 0) return -1; diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index b4f7f006d0..04118b4fa6 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -220,10 +220,7 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr band= width, { int result =3D -1; =20 - if (!shapingPolicy || *shapingPolicy) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(shapingPolicy); =20 if (!bandwidth->in || !bandwidth->out || bandwidth->in->average !=3D bandwidth->out->average || @@ -589,10 +586,7 @@ static int esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy *shaping= Policy, virNetDevBandwidthPtr *bandwidth) { - if (!bandwidth || *bandwidth) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(bandwidth); =20 if (!shapingPolicy || shapingPolicy->enabled !=3D esxVI_Boolean_True) return 0; diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index 2dd9f78569..d7210375fa 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -48,10 +48,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPt= r uri) int autoAnswer; char *tmp; =20 - if (!parsedUri || *parsedUri) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(parsedUri); =20 if (VIR_ALLOC(*parsedUri) < 0) return -1; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 25fbdc7e44..d3c4f760ba 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -51,10 +51,7 @@ VIR_LOG_INIT("esx.esx_vi"); int \ esxVI_##_type##_Alloc(esxVI_##_type **ptrptr) \ { \ - if (!ptrptr || *ptrptr) { \ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argume= nt")); \ - return -1; \ - } \ + ESX_VI_CHECK_ARG_LIST(ptrptr); \ \ if (VIR_ALLOC(*ptrptr) < 0) \ return -1; \ @@ -372,10 +369,7 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url,= char **content, virBuffer buffer =3D VIR_BUFFER_INITIALIZER; int responseCode =3D 0; =20 - if (!content || *content) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(content); =20 if (length && *length > 0) { /* @@ -1762,10 +1756,7 @@ esxVI_List_DeepCopy(esxVI_List **destList, esxVI_Lis= t *srcList, esxVI_List *dest =3D NULL; esxVI_List *src =3D NULL; =20 - if (!destList || *destList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(destList); =20 for (src =3D srcList; src; src =3D src->_next) { if (deepCopyFunc(&dest, src) < 0 || @@ -2170,10 +2161,7 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx, bool propertySpec_isAppended =3D false; esxVI_PropertyFilterSpec *propertyFilterSpec =3D NULL; =20 - if (!objectContentList || *objectContentList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(objectContentList); =20 if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) return -1; @@ -2372,10 +2360,7 @@ esxVI_GetVirtualMachineQuestionInfo { esxVI_DynamicProperty *dynamicProperty; =20 - if (!questionInfo || *questionInfo) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(questionInfo); =20 for (dynamicProperty =3D virtualMachine->propSet; dynamicProperty; dynamicProperty =3D dynamicProperty->_next) { @@ -2447,10 +2432,7 @@ esxVI_GetInt(esxVI_ObjectContent *objectContent, con= st char *propertyName, { esxVI_DynamicProperty *dynamicProperty; =20 - if (!value || *value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(value); =20 for (dynamicProperty =3D objectContent->propSet; dynamicProperty; dynamicProperty =3D dynamicProperty->_next) { @@ -2479,10 +2461,7 @@ esxVI_GetLong(esxVI_ObjectContent *objectContent, co= nst char *propertyName, { esxVI_DynamicProperty *dynamicProperty; =20 - if (!value || *value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(value); =20 for (dynamicProperty =3D objectContent->propSet; dynamicProperty; dynamicProperty =3D dynamicProperty->_next) { @@ -2512,10 +2491,7 @@ esxVI_GetStringValue(esxVI_ObjectContent *objectCont= ent, { esxVI_DynamicProperty *dynamicProperty; =20 - if (!value || *value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(value); =20 for (dynamicProperty =3D objectContent->propSet; dynamicProperty; dynamicProperty =3D dynamicProperty->_next) { @@ -2549,10 +2525,7 @@ esxVI_GetManagedObjectReference(esxVI_ObjectContent = *objectContent, { esxVI_DynamicProperty *dynamicProperty; =20 - if (!value || *value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(value); =20 for (dynamicProperty =3D objectContent->propSet; dynamicProperty; dynamicProperty =3D dynamicProperty->_next) { @@ -2863,10 +2836,7 @@ esxVI_GetSnapshotTreeBySnapshot { esxVI_VirtualMachineSnapshotTree *candidate; =20 - if (!snapshotTree || *snapshotTree) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(snapshotTree); =20 for (candidate =3D snapshotTreeList; candidate; candidate =3D candidate->_next) { @@ -2928,10 +2898,7 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx,= const unsigned char *uuid, esxVI_ManagedObjectReference *managedObjectReference =3D NULL; char uuid_string[VIR_UUID_STRING_BUFLEN] =3D ""; =20 - if (!virtualMachine || *virtualMachine) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(virtualMachine); =20 virUUIDFormat(uuid, uuid_string); =20 @@ -2983,10 +2950,7 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx,= const char *name, esxVI_ObjectContent *candidate =3D NULL; char *name_candidate =3D NULL; =20 - if (!virtualMachine || *virtualMachine) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(virtualMachine); =20 if (esxVI_String_DeepCopyList(&completePropertyNameList, propertyNameList) < 0 || @@ -3110,10 +3074,7 @@ esxVI_LookupDatastoreByName(esxVI_Context *ctx, cons= t char *name, esxVI_ObjectContent *candidate =3D NULL; char *name_candidate; =20 - if (!datastore || *datastore) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(datastore); =20 /* Get all datastores */ if (esxVI_String_DeepCopyList(&completePropertyNameList, @@ -3177,10 +3138,7 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *c= tx, esxVI_DatastoreHostMount *datastoreHostMountList =3D NULL; esxVI_DatastoreHostMount *datastoreHostMount =3D NULL; =20 - if (!datastore || *datastore) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(datastore); =20 /* Get all datastores */ if (esxVI_String_DeepCopyList(&completePropertyNameList, @@ -3263,10 +3221,7 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx, esxVI_DatastoreHostMount *hostMountList =3D NULL; esxVI_DatastoreHostMount *candidate =3D NULL; =20 - if (!hostMount || *hostMount) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(hostMount); =20 if (esxVI_String_AppendValueToList(&propertyNameList, "host") < 0 || esxVI_LookupObjectContentByType(ctx, datastore, "Datastore", @@ -3327,10 +3282,7 @@ esxVI_LookupTaskInfoByTask(esxVI_Context *ctx, esxVI_ObjectContent *objectContent =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; =20 - if (!taskInfo || *taskInfo) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(taskInfo); =20 if (esxVI_String_AppendValueToList(&propertyNameList, "info") < 0 || esxVI_LookupObjectContentByType(ctx, task, "Task", propertyNameLis= t, @@ -3375,10 +3327,7 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine esxVI_DynamicProperty *dynamicProperty =3D NULL; esxVI_TaskInfo *taskInfo =3D NULL; =20 - if (!pendingTaskInfoList || *pendingTaskInfoList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(pendingTaskInfoList); =20 /* Get list of recent tasks */ for (dynamicProperty =3D virtualMachine->propSet; dynamicProperty; @@ -3481,10 +3430,7 @@ esxVI_LookupRootSnapshotTreeList esxVI_ObjectContent *virtualMachine =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; =20 - if (!rootSnapshotTreeList || *rootSnapshotTreeList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(rootSnapshotTreeList); =20 if (esxVI_String_AppendValueToList(&propertyNameList, "snapshot.rootSnapshotList") < 0 || @@ -3536,10 +3482,7 @@ esxVI_LookupCurrentSnapshotTree esxVI_VirtualMachineSnapshotTree *rootSnapshotTreeList =3D NULL; esxVI_VirtualMachineSnapshotTree *snapshotTree =3D NULL; =20 - if (!currentSnapshotTree || *currentSnapshotTree) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(currentSnapshotTree); =20 if (esxVI_String_AppendValueListToList(&propertyNameList, "snapshot.currentSnapshot\0" @@ -3633,10 +3576,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *c= tx, esxVI_TaskInfo *taskInfo =3D NULL; esxVI_HostDatastoreBrowserSearchResults *searchResults =3D NULL; =20 - if (!fileInfo || *fileInfo) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(fileInfo); =20 if (esxUtil_ParseDatastorePath(datastorePath, &datastoreName, &directoryName, &directoryAndFileName) = < 0) { @@ -3829,10 +3769,7 @@ esxVI_LookupDatastoreContentByDatastoreName char *taskInfoErrorMessage =3D NULL; esxVI_TaskInfo *taskInfo =3D NULL; =20 - if (!searchResultsList || *searchResultsList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(searchResultsList); =20 /* Lookup Datastore and HostDatastoreBrowser */ if (esxVI_String_AppendValueToList(&propertyNameList, "browser") < 0 || @@ -3941,10 +3878,7 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Co= ntext *ctx, esxVI_FileInfo *fileInfo =3D NULL; char *uuid_string =3D NULL; =20 - if (!key || *key) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(key); =20 if (ctx->hasQueryVirtualDiskUuid) { if (esxVI_LookupFileInfoByDatastorePath @@ -3995,10 +3929,7 @@ esxVI_LookupAutoStartDefaults(esxVI_Context *ctx, esxVI_ObjectContent *hostAutoStartManager =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; =20 - if (!defaults || *defaults) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(defaults); =20 /* * Lookup HostAutoStartManagerConfig from the HostAutoStartManager bec= ause @@ -4052,10 +3983,7 @@ esxVI_LookupAutoStartPowerInfoList(esxVI_Context *ct= x, esxVI_ObjectContent *hostAutoStartManager =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; =20 - if (!powerInfoList || *powerInfoList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(powerInfoList); =20 /* * Lookup HostAutoStartManagerConfig from the HostAutoStartManager bec= ause @@ -4103,10 +4031,7 @@ esxVI_LookupPhysicalNicList(esxVI_Context *ctx, esxVI_ObjectContent *hostSystem =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; =20 - if (!physicalNicList || *physicalNicList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(physicalNicList); =20 if (esxVI_String_AppendValueToList(&propertyNameList, "config.network.pnic") < 0 || @@ -4147,10 +4072,7 @@ esxVI_LookupPhysicalNicByName(esxVI_Context *ctx, co= nst char *name, esxVI_PhysicalNic *physicalNicList =3D NULL; esxVI_PhysicalNic *candidate =3D NULL; =20 - if (!physicalNic || *physicalNic) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(physicalNic); =20 if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) goto cleanup; @@ -4194,10 +4116,7 @@ esxVI_LookupPhysicalNicByMACAddress(esxVI_Context *c= tx, const char *mac, esxVI_PhysicalNic *physicalNicList =3D NULL; esxVI_PhysicalNic *candidate =3D NULL; =20 - if (!physicalNic || *physicalNic) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(physicalNic); =20 if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) goto cleanup; @@ -4241,10 +4160,7 @@ esxVI_LookupHostVirtualSwitchList(esxVI_Context *ctx, esxVI_ObjectContent *hostSystem =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; =20 - if (!hostVirtualSwitchList || *hostVirtualSwitchList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(hostVirtualSwitchList); =20 if (esxVI_String_AppendValueToList(&propertyNameList, "config.network.vswitch") < 0 || @@ -4285,10 +4201,7 @@ esxVI_LookupHostVirtualSwitchByName(esxVI_Context *c= tx, const char *name, esxVI_HostVirtualSwitch *hostVirtualSwitchList =3D NULL; esxVI_HostVirtualSwitch *candidate =3D NULL; =20 - if (!hostVirtualSwitch || *hostVirtualSwitch) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(hostVirtualSwitch); =20 if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0) goto cleanup; @@ -4336,10 +4249,7 @@ esxVI_LookupHostPortGroupList(esxVI_Context *ctx, esxVI_ObjectContent *hostSystem =3D NULL; esxVI_DynamicProperty *dynamicProperty =3D NULL; =20 - if (!hostPortGroupList || *hostPortGroupList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(hostPortGroupList); =20 if (esxVI_String_AppendValueToList(&propertyNameList, "config.network.portgroup") < 0 || @@ -4513,10 +4423,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, bool blocked; esxVI_TaskInfo *taskInfo =3D NULL; =20 - if (!errorMessage || *errorMessage) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(errorMessage); =20 if (VIR_STRDUP(version, "") < 0) return -1; @@ -4982,10 +4889,7 @@ esxVI_LookupHostScsiTopologyLunListByTargetName bool found =3D false; esxVI_HostInternetScsiTargetTransport *candidate =3D NULL; =20 - if (!hostScsiTopologyLunList || *hostScsiTopologyLunList) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(hostScsiTopologyLunList); =20 if (esxVI_String_AppendValueToList (&propertyNameList, @@ -5076,10 +4980,7 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Contex= t *ctx, esxVI_HostScsiTopologyLun *hostScsiTopologyLun; bool found =3D false; =20 - if (!poolName || *poolName) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(poolName); =20 if (esxVI_String_AppendValueToList (&propertyNameList, diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c index a3d489dd66..3156a132d8 100644 --- a/src/esx/esx_vi_methods.c +++ b/src/esx/esx_vi_methods.c @@ -38,10 +38,7 @@ =20 =20 #define ESX_VI__METHOD__CHECK_OUTPUT__NotNone \ - if (!output || *output) { \ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); \ - return -1; \ - } + ESX_VI_CHECK_ARG_LIST(output); =20 =20 =20 @@ -232,10 +229,7 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx, ESX_VI__SOAP__REQUEST_FOOTER; esxVI_Response *response =3D NULL; =20 - if (!serviceContent || *serviceContent) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(serviceContent); =20 if (esxVI_Context_Execute(ctx, "RetrieveServiceContent", request, &response, esxVI_Occurrence_RequiredItem) < = 0 || diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index ec7fda9865..315d67d20f 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -43,10 +43,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); int \ esxVI_##__type##_Alloc(esxVI_##__type **ptrptr) \ { \ - if (!ptrptr || *ptrptr) { \ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argume= nt")); \ - return -1; \ - } \ + ESX_VI_CHECK_ARG_LIST(ptrptr); \ \ if (VIR_ALLOC(*ptrptr) < 0) \ return -1; \ @@ -101,11 +98,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); int \ esxVI_##_type##_DeepCopy(esxVI_##_type **dest, esxVI_##_type *src) \ { \ - if (!dest || *dest) { \ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", \ - _("Invalid argument")); \ - return -1; \ - } \ + ESX_VI_CHECK_ARG_LIST(dest); \ \ if (!src) { \ return 0; \ @@ -940,10 +933,7 @@ esxVI_AnyType_ExpectType(esxVI_AnyType *anyType, esxVI= _Type type) int esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src) { - if (!dest || *dest) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(dest); =20 if (!src) return 0; @@ -1009,10 +999,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyT= ype **anyType) { long long int number; =20 - if (!anyType || *anyType) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(anyType); =20 if (esxVI_AnyType_Alloc(anyType) < 0) return -1; @@ -1218,10 +1205,7 @@ ESX_VI__TEMPLATE__LIST__DEEP_COPY(String) int esxVI_String_DeepCopyValue(char **dest, const char *src) { - if (!dest || *dest) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(dest); =20 if (!src) return 0; @@ -1270,10 +1254,7 @@ esxVI_String_SerializeValue(const char *value, const= char *element, int esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string) { - if (!string || *string) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(string); =20 if (esxVI_String_Alloc(string) < 0 || esxVI_String_DeserializeValue(node, &(*string)->value) < 0) { @@ -1294,10 +1275,7 @@ ESX_VI__TEMPLATE__LIST__DESERIALIZE(String) int esxVI_String_DeserializeValue(xmlNodePtr node, char **value) { - if (!value || *value) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(value); =20 *value =3D (char *)xmlNodeListGetString(node->doc, node->children, 1); =20 @@ -1472,10 +1450,7 @@ ESX_VI__TEMPLATE__SERIALIZE(DateTime, int esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime) { - if (!dateTime || *dateTime) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(dateTime); =20 if (esxVI_DateTime_Alloc(dateTime) < 0) return -1; @@ -1644,10 +1619,7 @@ ESX_VI__TEMPLATE__FREE(MethodFault, int esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodF= ault) { - if (!methodFault || *methodFault) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(methodFault); =20 if (esxVI_MethodFault_Alloc(methodFault) < 0) return -1; @@ -1738,10 +1710,7 @@ int esxVI_ManagedObjectReference_Deserialize (xmlNodePtr node, esxVI_ManagedObjectReference **managedObjectReference) { - if (!managedObjectReference || *managedObjectReference) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); - return -1; - } + ESX_VI_CHECK_ARG_LIST(managedObjectReference); =20 if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0) return -1; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list