zephyriot / zep-jira14

0 stars 0 forks source link

Build warnings [-Wpointer-sign] with LLVM/icx (tests/unit/bluetooth/at) #2000

Open nashif opened 7 years ago

nashif commented 7 years ago

Reported by rahul kumar:

Test case with build warning raised from LLVM/icx: tests/unit/bluetooth/at

/home/vikram/Project/zephyr/subsys/bluetooth/host/at.c:203:14: warning:
      passing 'unsigned char *' to parameter of type 'const char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
        if (strncmp(at->buf, "CME ERROR", 9) == 0) {
                    ^~~~~~~
/home/vikram/Project/zephyr/lib/libc/minimal/include/string.h:26:35: note:
      passing argument to parameter 's1' here
extern int    strncmp(const char *s1, const char *s2, size_t n);
                                  ^
/home/vikram/Project/zephyr/subsys/bluetooth/host/at.c:233:14: warning:
      passing 'unsigned char *' to parameter of type 'const char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
        if (strncmp(at->buf, "RING", 4) == 0) {
                    ^~~~~~~
/home/vikram/Project/zephyr/lib/libc/minimal/include/string.h:26:35: note:
      passing argument to parameter 's1' here
extern int    strncmp(const char *s1, const char *s2, size_t n);
                                  ^
/home/vikram/Project/zephyr/subsys/bluetooth/host/at.c:250:22: warning:
      passing 'unsigned char *' to parameter of type 'const char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
        if (at_parse_result(at->buf, buf, &result) == 0) {
                            ^~~~~~~
/home/vikram/Project/zephyr/subsys/bluetooth/host/at.c:73:40: note: passing
      argument to parameter 'str' here
static int at_parse_result(const char *str, struct net_buf *buf,
                                       ^
/home/vikram/Project/zephyr/subsys/bluetooth/host/at.c:338:22: warning:
      passing 'unsigned char *' to parameter of type 'const char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
        if (!str_has_prefix(at->buf, prefix)) {
                            ^~~~~~~
/home/vikram/Project/zephyr/subsys/bluetooth/host/at.c:64:40: note: passing
      argument to parameter 'str' here
static bool str_has_prefix(const char *str, const char *prefix)
                                       ^
4 warnings generated.
  CC      subsys/bluetooth/host/hfp_hf.o
/home/vikram/Project/zephyr/subsys/bluetooth/host/hfp_hf.c:82:18: warning:
      passing 'u8_t *' (aka 'unsigned char *') to parameter of type 'char *'
      converts between pointers to integer types with different sign
      [-Wpointer-sign]
        ret = vsnprintk(buf->data, (net_buf_tailroom(buf) - 1), format, vargs);
                        ^~~~~~~~~
/home/vikram/Project/zephyr/include/misc/printk.h:49:48: note: passing
      argument to parameter 'str' here
extern __printf_like(3, 0) int vsnprintk(char *str, size_t size,
                                               ^
/home/vikram/Project/zephyr/subsys/bluetooth/host/hfp_hf.c:373:16: warning:
      passing 'unsigned char *' to parameter of type 'const char *' converts
      between pointers to integer types with different sign [-Wpointer-sign]
                if (!strncmp(hf_at->buf, handlers[i].cmd,
                             ^~~~~~~~~~
/home/vikram/Project/zephyr/lib/libc/minimal/include/string.h:26:35: note:
      passing argument to parameter 's1' here
extern int    strncmp(const char *s1, const char *s2, size_t n);
                                  ^
/home/vikram/Project/zephyr/subsys/bluetooth/host/hfp_hf.c:657:14: warning:
      assigning to 'unsigned char *' from 'char [140]' converts between pointers
      to integer types with different sign [-Wpointer-sign]
                hf->at.buf = hf->hf_buffer;
                           ^ ~~~~~~~~~~~~~
3 warnings generated.
/home/vikram/Project/zephyr/tests/unit/bluetooth/at/src/main.c:53:9: warning:
      assigning to 'unsigned char *' from 'char [140]' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        at.buf = buffer;
               ^ ~~~~~~
1 warning generated.

How to setup llvm/icx

update the icx compiler with 0214 build from ISSM team

source /linux_prod/linux/bin/xcompilervars_arch.sh ia32 mcu

cd zephyr

source zephyr-env.sh

export ISSM_INSTALLATION_PATH=/issm_2016.1.057

export ZEPHYR_GCC_VARIANT=issm

How-to-reproduce:

cd tests/unit/bluetooth/at

make pristine

make BOARD=quark_se_c1000_devboard CC=icx

Expected result : Build should pass without any warning or error.

Actual result : Observed build warnings.

Attached captured compilation log.

(Imported from Jira ZEP-2161)

nashif commented 7 years ago

by rahul kumar: