Re: [ovs-dev] [PATCH] python-c-ext: fix a couple of build warnings

2022-07-07 Thread Ilya Maximets
On 6/30/22 12:32, Timothy Redaelli wrote:
> 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 ef7bb4b8e..237beb86f 100644
> --- a/python/ovs/_json.c
> +++ b/python/ovs/_json.c
> @@ -54,7 +54,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;

This will likely cause a build failure in python 2, because
PyString_AsStringAndSize function needs a non-const pointer.

I guess, we need to remove support for python < 3 from this
file before changing the pointer type.

>  
>  if (self->_parser == NULL) {
>  return NULL;
> @@ -123,7 +123,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) {

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] python-c-ext: fix a couple of build warnings

2022-06-30 Thread Timothy Redaelli
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 ef7bb4b8e..237beb86f 100644
--- a/python/ovs/_json.c
+++ b/python/ovs/_json.c
@@ -54,7 +54,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;
@@ -123,7 +123,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) {
-- 
2.36.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev