diff mbox series

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

Message ID f7906f86a0b3d9c659e2ac093a398575d25c5202.1656585140.git.tredaelli@redhat.com
State Changes Requested
Headers show
Series [ovs-dev] python-c-ext: fix a couple of build warnings | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Timothy Redaelli June 30, 2022, 10:32 a.m. UTC
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 <tredaelli@redhat.com>
---
 python/ovs/_json.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ilya Maximets July 7, 2022, 1:27 p.m. UTC | #1
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 <tredaelli@redhat.com>
> ---
>  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) {
diff mbox series

Patch

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) {