From patchwork Mon Jul 18 10:40:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timothy Redaelli X-Patchwork-Id: 1657376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CwNLOB22; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LmdlW01mmz9sFk for ; Mon, 18 Jul 2022 20:40:21 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2B3AA60D58; Mon, 18 Jul 2022 10:40:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2B3AA60D58 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CwNLOB22 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XClWnsC0oxHd; Mon, 18 Jul 2022 10:40:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4AA50607D0; Mon, 18 Jul 2022 10:40:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4AA50607D0 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 192FEC0035; Mon, 18 Jul 2022 10:40:17 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id A8ACAC002D for ; Mon, 18 Jul 2022 10:40:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7D301415C8 for ; Mon, 18 Jul 2022 10:40:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7D301415C8 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CwNLOB22 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gwLWB4dQdYis for ; Mon, 18 Jul 2022 10:40:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 0337F415C7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 0337F415C7 for ; Mon, 18 Jul 2022 10:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658140812; h=from:from: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; bh=5v9lXnYfCXDwxBpSK2tjkc5iFUCxgC16bwRXoi+NztM=; b=CwNLOB22DQ6eNqcINcHQaPGiZt31sfUXsZqpQaRpMGR/gvROGQ3Z+mjtA1pUx6B5zEkWrA 3V37QORRSkBoy3Vl0S3DMJsOIPijk0aClSrwgkuILuc+TKhqL6+ULgetY26UM5fsRIQ9ke TgdD+Eo37wbg8zF89+bFjf1de7AM8FA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-8UwlLq1oNmOW1RZy3KodjQ-1; Mon, 18 Jul 2022 06:40:10 -0400 X-MC-Unique: 8UwlLq1oNmOW1RZy3KodjQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A73AA85A581 for ; Mon, 18 Jul 2022 10:40:10 +0000 (UTC) Received: from aldebaran.redhat.com (unknown [10.39.194.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39748141511A for ; Mon, 18 Jul 2022 10:40:10 +0000 (UTC) From: Timothy Redaelli To: dev@openvswitch.org Date: Mon, 18 Jul 2022 12:40:01 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=tredaelli@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 1/2] python-c-ext: Remove Python 2 support X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Since Python 2 is not supported anymore, remove Python 2 support from C extension too Fixes: 1ca0323e7c29 ("Require Python 3 and remove support for Python 2.") Signed-off-by: Timothy Redaelli --- python/ovs/_json.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/python/ovs/_json.c b/python/ovs/_json.c index ef7bb4b8e..80bf9dea3 100644 --- a/python/ovs/_json.c +++ b/python/ovs/_json.c @@ -2,10 +2,6 @@ #include #include "structmember.h" -#if PY_MAJOR_VERSION >= 3 -#define IS_PY3K -#endif - typedef struct { PyObject_HEAD struct json_parser *_parser; @@ -63,21 +59,13 @@ Parser_feed(json_ParserObject * self, PyObject * args) if (!PyArg_UnpackTuple(args, "input", 1, 1, &input)) { return NULL; } -#ifdef IS_PY3K if ((input_str = PyUnicode_AsUTF8AndSize(input, &input_sz)) == NULL) { -#else - if (PyString_AsStringAndSize(input, &input_str, &input_sz) < 0) { -#endif return NULL; } rd = json_parser_feed(self->_parser, input_str, (size_t) input_sz); -#ifdef IS_PY3K return PyLong_FromSize_t(rd); -#else - return PyInt_FromSize_t(rd); -#endif } static PyObject * @@ -144,11 +132,7 @@ json_to_python(struct json *json) return PyFloat_FromDouble(json->real); } /* fall through to treat 0 as int */ case JSON_INTEGER: -#ifdef IS_PY3K return PyLong_FromLong((long) json->integer); -#else - return PyInt_FromLong((long) json->integer); -#endif case JSON_STRING: return PyUnicode_FromString(json->string); @@ -225,7 +209,6 @@ static PyTypeObject json_ParserType = { Parser_new, /* tp_new */ }; -#ifdef IS_PY3K static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "ovs._json", /* m_name */ @@ -238,32 +221,17 @@ static struct PyModuleDef moduledef = { 0, /* m_free */ }; -#define INITERROR return NULL -#else /* !IS_PY3K */ -#define INITERROR return -#endif - PyMODINIT_FUNC -#ifdef IS_PY3K PyInit__json(void) -#else -init_json(void) -#endif { PyObject *m; if (PyType_Ready(&json_ParserType) < 0) { - INITERROR; + return NULL; } -#ifdef IS_PY3K m = PyModule_Create(&moduledef); -#else - m = Py_InitModule3("ovs._json", NULL, "OVS JSON Parser module"); -#endif Py_INCREF(&json_ParserType); PyModule_AddObject(m, "Parser", (PyObject *) & json_ParserType); -#ifdef IS_PY3K return m; -#endif } From patchwork Mon Jul 18 10:40:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Timothy Redaelli X-Patchwork-Id: 1657378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QusbWFyf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lmdlb52Yrz9sFk for ; Mon, 18 Jul 2022 20:40:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5A62440B00; Mon, 18 Jul 2022 10:40:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5A62440B00 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QusbWFyf X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t0FVuZvczz04; Mon, 18 Jul 2022 10:40:24 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5CB8740AFA; Mon, 18 Jul 2022 10:40:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5CB8740AFA Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1B269C007D; Mon, 18 Jul 2022 10:40:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 97FFDC007D for ; Mon, 18 Jul 2022 10:40:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 6287640AE8 for ; Mon, 18 Jul 2022 10:40:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6287640AE8 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3hvebBulUz98 for ; Mon, 18 Jul 2022 10:40:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9FFD840AE3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9FFD840AE3 for ; Mon, 18 Jul 2022 10:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658140819; h=from:from: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; bh=u/s9jP7wSwvy9FNbwQGeTqxHCocj/EDKJ1nP3JIDJrI=; b=QusbWFyf6Ri5IXGpw5tk9jRw70OliBzoZGI0atJyrVvcgziR/aftwi2YEvJwwVFOjA0/NC Lwb1cVr2tEOSLUELrxhRahu6hDUfwi1TnBRqzBwmbEeZCqdbbvhOSS02hcK1UpW0wKRbmv xRS4j2kztzqe296xt6SIFI571BRnl8Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-380--GyIfT4COQ24L0ksMlYVLQ-1; Mon, 18 Jul 2022 06:40:12 -0400 X-MC-Unique: -GyIfT4COQ24L0ksMlYVLQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0BE94811E81 for ; Mon, 18 Jul 2022 10:40:12 +0000 (UTC) Received: from aldebaran.redhat.com (unknown [10.39.194.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89F391415121 for ; Mon, 18 Jul 2022 10:40:11 +0000 (UTC) From: Timothy Redaelli To: dev@openvswitch.org Date: Mon, 18 Jul 2022 12:40:02 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=tredaelli@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 2/2] python-c-ext: fix a couple of build warnings X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" ovs/_json.c:67:20: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] ovs/_json.c:132:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] Signed-off-by: Timothy Redaelli --- python/ovs/_json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/ovs/_json.c b/python/ovs/_json.c index 80bf9dea3..0b980038b 100644 --- a/python/ovs/_json.c +++ b/python/ovs/_json.c @@ -50,7 +50,7 @@ Parser_feed(json_ParserObject * self, PyObject * args) Py_ssize_t input_sz; PyObject *input; size_t rd; - char *input_str; + const char *input_str; if (self->_parser == NULL) { return NULL; @@ -111,7 +111,7 @@ json_to_python(struct json *json) return dict; } case JSON_ARRAY:{ - int i; + size_t i; PyObject *arr = PyList_New(json->array.n); if (arr == NULL) {