From patchwork Fri Aug 9 02:01:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 11085111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9536814DB for ; Fri, 9 Aug 2019 02:03:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D5C528C1E for ; Fri, 9 Aug 2019 02:03:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EA3B28C20; Fri, 9 Aug 2019 02:03:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F1F728C1E for ; Fri, 9 Aug 2019 02:03:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hvuE8-0006ue-RW; Fri, 09 Aug 2019 02:01:56 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hvuE8-0006uZ-CW for xen-devel@lists.xenproject.org; Fri, 09 Aug 2019 02:01:56 +0000 X-Inumbo-ID: a8c1a89f-ba49-11e9-8980-bc764e045a96 Received: from wout1-smtp.messagingengine.com (unknown [64.147.123.24]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id a8c1a89f-ba49-11e9-8980-bc764e045a96; Fri, 09 Aug 2019 02:01:54 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 107C43A4; Thu, 8 Aug 2019 22:01:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Thu, 08 Aug 2019 22:01:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=DfbBgp mNsuEQJ6xN3rGEi3QwmyiOD5hWkKQWkDrRTzw=; b=n5dwSb8XR5M6Em1LgEuF3K 0ExJ1p7PXmIXtIHg0b8jpfwuELB1eadmskocCTszv4bVazu89k7aMpWf0a+kcO4O xs4yAJpml4cKqnseGK4jIZYUTynl+HT1ZkUFM7+V/C97YnYb7hug+L+/OpXamder Tmk1ImtoF8S6z95VvlL0ZHSB6EOzDStT0I723INQHFJ6l0ptvBTU64/urHb54JjP dhJ62qqCuXj9i5KPadjhXtLAOeBINpnc47VlL0X7LKXVcRm8Z22yo9DIEbwhcHxP 9UEUMxUsPJ3DBXbDU5HonIMMH3iMLIwgYygUPGB0S3YOPlwOfH9BX792h82vcrhQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudduiedgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffogggtohfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id A3B5D8005A; Thu, 8 Aug 2019 22:01:50 -0400 (EDT) From: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Fri, 9 Aug 2019 04:01:36 +0200 Message-Id: <20190809020137.27334-1-marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Organization: Invisible Things Lab Subject: [Xen-devel] [PATCH 1/2] python: fix -Wsign-compare warnings X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , =?utf-8?q?Marek_Marczykowski-G?= =?utf-8?q?=C3=B3recki?= , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Specifically: xen/lowlevel/xc/xc.c: In function ‘pyxc_domain_create’: xen/lowlevel/xc/xc.c:147:24: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] 147 | for ( i = 0; i < sizeof(xen_domain_handle_t); i++ ) | ^ xen/lowlevel/xc/xc.c: In function ‘pyxc_domain_sethandle’: xen/lowlevel/xc/xc.c:312:20: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] 312 | for ( i = 0; i < sizeof(xen_domain_handle_t); i++ ) | ^ xen/lowlevel/xc/xc.c: In function ‘pyxc_domain_getinfo’: xen/lowlevel/xc/xc.c:391:24: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] 391 | for ( j = 0; j < sizeof(xen_domain_handle_t); j++ ) | ^ xen/lowlevel/xc/xc.c: In function ‘pyxc_get_device_group’: xen/lowlevel/xc/xc.c:677:20: error: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Werror=sign-compare] 677 | for ( i = 0; i < num_sdevs; i++ ) | ^ xen/lowlevel/xc/xc.c: In function ‘pyxc_physinfo’: xen/lowlevel/xc/xc.c:988:20: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] 988 | for ( i = 0; i < sizeof(pinfo.hw_cap)/4; i++ ) | ^ xen/lowlevel/xc/xc.c:994:20: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] 994 | for ( i = 0; i < ARRAY_SIZE(virtcaps_bits); i++ ) | ^ xen/lowlevel/xc/xc.c:998:24: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare] 998 | for ( i = 0; i < ARRAY_SIZE(virtcaps_bits); i++ ) | ^ xen/lowlevel/xs/xs.c: In function ‘xspy_ls’: xen/lowlevel/xs/xs.c:191:23: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare] 191 | for (i = 0; i < xsval_n; i++) | ^ xen/lowlevel/xs/xs.c: In function ‘xspy_get_permissions’: xen/lowlevel/xs/xs.c:297:23: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare] 297 | for (i = 0; i < perms_n; i++) { | ^ cc1: all warnings being treated as errors Use size_t for loop iterators where it's compared with sizeof() or similar construct. Signed-off-by: Marek Marczykowski-Górecki Acked-by: Ian Jackson --- tools/python/xen/lowlevel/xc/xc.c | 13 ++++++++----- tools/python/xen/lowlevel/xs/xs.c | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 522cbe3b9c..188bfa34da 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -117,7 +117,8 @@ static PyObject *pyxc_domain_create(XcObject *self, PyObject *kwds) { uint32_t dom = 0, target = 0; - int ret, i; + int ret; + size_t i; PyObject *pyhandle = NULL; struct xen_domctl_createdomain config = { .handle = { @@ -295,7 +296,7 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self, static PyObject *pyxc_domain_sethandle(XcObject *self, PyObject *args) { - int i; + size_t i; uint32_t dom; PyObject *pyhandle; xen_domain_handle_t handle; @@ -336,7 +337,8 @@ static PyObject *pyxc_domain_getinfo(XcObject *self, PyObject *list, *info_dict, *pyhandle; uint32_t first_dom = 0; - int max_doms = 1024, nr_doms, i, j; + int max_doms = 1024, nr_doms, i; + size_t j; xc_dominfo_t *info; static char *kwd_list[] = { "first_dom", "max_doms", NULL }; @@ -631,7 +633,8 @@ static PyObject *pyxc_get_device_group(XcObject *self, { uint32_t sbdf; uint32_t max_sdevs, num_sdevs; - int domid, seg, bus, dev, func, rc, i; + int domid, seg, bus, dev, func, rc; + size_t i; PyObject *Pystr; char *group_str; char dev_str[9]; @@ -971,7 +974,7 @@ static PyObject *pyxc_physinfo(XcObject *self) { xc_physinfo_t pinfo; char cpu_cap[128], virt_caps[128], *p; - int i; + size_t i; const char *virtcap_names[] = { "hvm", "pv" }; const unsigned virtcaps_bits[] = { XEN_SYSCTL_PHYSCAP_hvm, XEN_SYSCTL_PHYSCAP_pv }; diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c index 9a0acfc25c..ea50f86bc3 100644 --- a/tools/python/xen/lowlevel/xs/xs.c +++ b/tools/python/xen/lowlevel/xs/xs.c @@ -186,7 +186,7 @@ static PyObject *xspy_ls(XsHandle *self, PyObject *args) Py_END_ALLOW_THREADS if (xsval) { - int i; + size_t i; PyObject *val = PyList_New(xsval_n); for (i = 0; i < xsval_n; i++) #if PY_MAJOR_VERSION >= 3 @@ -276,7 +276,7 @@ static PyObject *xspy_get_permissions(XsHandle *self, PyObject *args) struct xs_handle *xh = xshandle(self); struct xs_permissions *perms; unsigned int perms_n = 0; - int i; + size_t i; xs_transaction_t th; char *thstr;