Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wsign-compare warnings #23

Open
edmonds opened this issue Aug 25, 2016 · 2 comments
Open

-Wsign-compare warnings #23

edmonds opened this issue Aug 25, 2016 · 2 comments

Comments

@edmonds
Copy link

edmonds commented Aug 25, 2016

Hi,

I get the following warnings when compiling with -Wsign-compare:

json.c: In function ‘json_print_args’:
json.c:965:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (length == -1)
               ^~
jsonlint.c: In function ‘printchannel’:
jsonlint.c:48:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (ret != length)
          ^~
jsonlint.c: In function ‘process_file’:
jsonlint.c:96:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (i = 0; i < processed; i++) {
                 ^
@vfelsner
Copy link

vfelsner commented Jun 1, 2017

Same here, at least for the first warning.
And looking at it, length is uint32_t. It doesn't make sense to compare that to -1.

I suggest changing that to int32_t?

@vfelsner
Copy link

vfelsner commented Oct 5, 2017

Any news on this? I'd change the code myself but don't have a deep enough understanding of the library.

Here's my warnings output:

Description Resource Path Location Type
conversion to 'int' from 'uint32_t {aka long unsigned int}' may change the sign of the result [-Wsign-conversion] json.c /Master_TestHW/src/c/libjson line 468 C/C++ Problem

conversion to 'int' from 'uint32_t {aka long unsigned int}' may change the sign of the result [-Wsign-conversion] json.c /Master_TestHW/src/c/libjson line 1034 C/C++ Problem

conversion to 'int32_t {aka long int}' from 'size_t {aka unsigned int}' may change the sign of the result [-Wsign-conversion] json.c /Master_TestHW/src/c/libjson line 966 C/C++ Problem

conversion to 'long unsigned int' from 'int' may change the sign of the result [-Wsign-conversion] json.c /Master_TestHW/src/c/libjson line 485 C/C++ Problem

conversion to 'uint16_t {aka short unsigned int}' from 'uint32_t {aka long unsigned int}' may alter its value [-Wconversion] json.c /Master_TestHW/src/c/libjson line 497 C/C++ Problem

conversion to 'uint32_t {aka long unsigned int}' from 'int' may change the sign of the result [-Wsign-conversion] json.c /Master_TestHW/src/c/libjson line 470 C/C++ Problem

conversion to 'uint32_t {aka long unsigned int}' from 'int32_t {aka long int}' may change the sign of the result [-Wsign-conversion] json.c /Master_TestHW/src/c/libjson line 967 C/C++ Problem

conversion to 'uint8_t {aka unsigned char}' from 'int' may alter its value [-Wconversion] json.c /Master_TestHW/src/c/libjson line 364 C/C++ Problem

conversion to 'uint8_t {aka unsigned char}' from 'int' may alter its value [-Wconversion] json.c /Master_TestHW/src/c/libjson line 785 C/C++ Problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants