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

fix build warnings #8

Merged
merged 2 commits into from
Mar 1, 2024
Merged

fix build warnings #8

merged 2 commits into from
Mar 1, 2024

Conversation

Junbo-Zheng
Copy link
Owner

fix build warnings

➜  /Users/junbozheng/project/cNV git:(master) ✗ cmake --build build -j16
[ 20%] Building C object CMakeFiles/cNV.dir/cJSON/cJSON_Utils.c.o
[ 60%] Building C object CMakeFiles/cNV.dir/test.c.o
[ 60%] Building C object CMakeFiles/cNV.dir/cJSON/cJSON.c.o
[ 80%] Building C object CMakeFiles/cNV.dir/nv/nv.c.o
/Users/junbozheng/project/cNV/nv/nv.c:100:32: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            json = cJSON_Parse(nv_buffer);
                               ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:148:47: note: passing argument to parameter 'value' here
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
                                              ^
/Users/junbozheng/project/cNV/nv/nv.c:244:17: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
        sprintf(nv_buffer, "%d.%d.%d.%d", *((uint32_t *)value),
                ^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/secure/_stdio.h:47:28: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                           ^~~
/Users/junbozheng/project/cNV/nv/nv.c:248:44: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            cJSON_SetValuestring(key_item, nv_buffer);
                                           ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:280:69: note: passing argument to parameter 'valuestring' here
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
                                                                    ^
/Users/junbozheng/project/cNV/nv/nv.c:250:48: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            cJSON_AddStringToObject(json, key, nv_buffer);
                                               ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:269:112: note: passing argument to parameter 'string' here
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
                                                                                                               ^
/Users/junbozheng/project/cNV/nv/nv.c:255:17: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
        sprintf(nv_buffer, "%d-%d-%d-%d-%d-%d", *((uint32_t *)value),
                ^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/secure/_stdio.h:47:28: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                           ^~~
/Users/junbozheng/project/cNV/nv/nv.c:261:44: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            cJSON_SetValuestring(key_item, nv_buffer);
                                           ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:280:69: note: passing argument to parameter 'valuestring' here
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
                                                                    ^
/Users/junbozheng/project/cNV/nv/nv.c:263:48: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            cJSON_AddStringToObject(json, key, nv_buffer);
                                               ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:269:112: note: passing argument to parameter 'string' here
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
                                                                                                               ^
/Users/junbozheng/project/cNV/nv/nv.c:297:31: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
    cJSON* json = cJSON_Parse(nv_buffer);
                              ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:148:47: note: passing argument to parameter 'value' here
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
                                              ^
/Users/junbozheng/project/cNV/nv/nv.c:289:64: error: unused parameter 'len' [-Werror,-Wunused-parameter]
bool nv_get(const char* file, char* key, char* value, uint32_t len,
                                                               ^
/Users/junbozheng/project/cNV/test.c:341:23: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
    for (int i = 0; i < ARRAY_SIZE(score_buf); i++) {
                    ~ ^ ~~~~~~~~~~~~~~~~~~~~~/Users/junbozheng/project/cNV/nv/nv.c
:348:32: error: /Users/junbozheng/project/cNV/test.c:357comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'int' [-Werror,-Wsign-compare]:23
: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]        for (uint32_t i = 0; i < size; i++) {

                             ~ ^ ~~~~
    for (int i = 0; i < ARRAY_SIZE(score_buf); i++) {
                    ~ ^ ~~~~~~~~~~~~~~~~~~~~~
/Users/junbozheng/project/cNV/nv/nv.c:400:31: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
    cJSON* json = cJSON_Parse(nv_buffer);
                              ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:148:47: note: passing argument to parameter 'value' here
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
                                              ^
2 errors generated.
11 errors generated.
make[2]: *** [CMakeFiles/cNV.dir/nv/nv.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/cNV.dir/test.c.o] Error 1
make[1]: *** [CMakeFiles/cNV.dir/all] Error 2
make: *** [all] Error 2

Signed-off-by: Junbo Zheng [email protected]

➜  /Users/junbozheng/project/cNV git:(master) ✗ cmake --build build -j16
[ 20%] Building C object CMakeFiles/cNV.dir/cJSON/cJSON_Utils.c.o
[ 60%] Building C object CMakeFiles/cNV.dir/test.c.o
[ 60%] Building C object CMakeFiles/cNV.dir/cJSON/cJSON.c.o
[ 80%] Building C object CMakeFiles/cNV.dir/nv/nv.c.o
/Users/junbozheng/project/cNV/nv/nv.c:100:32: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            json = cJSON_Parse(nv_buffer);
                               ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:148:47: note: passing argument to parameter 'value' here
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
                                              ^
/Users/junbozheng/project/cNV/nv/nv.c:244:17: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
        sprintf(nv_buffer, "%d.%d.%d.%d", *((uint32_t *)value),
                ^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/secure/_stdio.h:47:28: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                           ^~~
/Users/junbozheng/project/cNV/nv/nv.c:248:44: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            cJSON_SetValuestring(key_item, nv_buffer);
                                           ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:280:69: note: passing argument to parameter 'valuestring' here
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
                                                                    ^
/Users/junbozheng/project/cNV/nv/nv.c:250:48: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            cJSON_AddStringToObject(json, key, nv_buffer);
                                               ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:269:112: note: passing argument to parameter 'string' here
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
                                                                                                               ^
/Users/junbozheng/project/cNV/nv/nv.c:255:17: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
        sprintf(nv_buffer, "%d-%d-%d-%d-%d-%d", *((uint32_t *)value),
                ^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/include/secure/_stdio.h:47:28: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                           ^~~
/Users/junbozheng/project/cNV/nv/nv.c:261:44: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            cJSON_SetValuestring(key_item, nv_buffer);
                                           ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:280:69: note: passing argument to parameter 'valuestring' here
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
                                                                    ^
/Users/junbozheng/project/cNV/nv/nv.c:263:48: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
            cJSON_AddStringToObject(json, key, nv_buffer);
                                               ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:269:112: note: passing argument to parameter 'string' here
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
                                                                                                               ^
/Users/junbozheng/project/cNV/nv/nv.c:297:31: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
    cJSON* json = cJSON_Parse(nv_buffer);
                              ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:148:47: note: passing argument to parameter 'value' here
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
                                              ^
/Users/junbozheng/project/cNV/nv/nv.c:289:64: error: unused parameter 'len' [-Werror,-Wunused-parameter]
bool nv_get(const char* file, char* key, char* value, uint32_t len,
                                                               ^
/Users/junbozheng/project/cNV/test.c:341:23: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
    for (int i = 0; i < ARRAY_SIZE(score_buf); i++) {
                    ~ ^ ~~~~~~~~~~~~~~~~~~~~~/Users/junbozheng/project/cNV/nv/nv.c
:348:32: error: /Users/junbozheng/project/cNV/test.c:357comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'int' [-Werror,-Wsign-compare]:23
: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]        for (uint32_t i = 0; i < size; i++) {

                             ~ ^ ~~~~
    for (int i = 0; i < ARRAY_SIZE(score_buf); i++) {
                    ~ ^ ~~~~~~~~~~~~~~~~~~~~~
/Users/junbozheng/project/cNV/nv/nv.c:400:31: error: passing 'uint8_t[1024]' (aka 'unsigned char[1024]') to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign]
    cJSON* json = cJSON_Parse(nv_buffer);
                              ^~~~~~~~~
/Users/junbozheng/project/cNV/cJSON/cJSON.h:148:47: note: passing argument to parameter 'value' here
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
                                              ^
2 errors generated.
11 errors generated.
make[2]: *** [CMakeFiles/cNV.dir/nv/nv.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/cNV.dir/test.c.o] Error 1
make[1]: *** [CMakeFiles/cNV.dir/all] Error 2
make: *** [all] Error 2

Signed-off-by: Junbo Zheng <[email protected]>
@Junbo-Zheng Junbo-Zheng merged commit d0dc006 into master Mar 1, 2024
4 checks passed
@Junbo-Zheng Junbo-Zheng deleted the build branch March 1, 2024 16:17
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

Successfully merging this pull request may close these issues.

1 participant