RIOT-OS / RIOT

RIOT - The friendly OS for IoT
https://riot-os.org
GNU Lesser General Public License v2.1
4.88k stars 1.98k forks source link

"Minor" compiling issues found by clang #7875

Closed kYc0o closed 5 years ago

kYc0o commented 6 years ago

Here you have a list of compiling issues I found using clang (with its respective PRs):

So far is what I found. This is an effort towards #1121.

aabadie commented 6 years ago

7919 was merged so is this issue still valid @kYc0o ?

kYc0o commented 6 years ago

I'd say all test should be OK right now, but let me check again in case something is missing.

kYc0o commented 6 years ago

I've found some more. I'll post it here so we still keep track of the current errors, even if they're not critical for the release.

type 'uint32_t' (aka 'unsigned int') [-Werror,-Wformat] DEBUG("[DEBUG] Set RX timeout: %lu\n", timeout);


                                   %u
/Users/facosta/git/RIOT-OS/RIOT/core/include/debug.h:97:50: note: expanded from macro 'DEBUG'
#define DEBUG(...) if (ENABLE_DEBUG) DEBUG_PRINT(__VA_ARGS__)
                                                 ^~~~~~~~~~~
/Users/facosta/git/RIOT-OS/RIOT/core/include/debug.h:56:20: note: expanded from macro 'DEBUG_PRINT'
            printf(__VA_ARGS__); \
                   ^~~~~~~~~~~
/Users/facosta/git/RIOT-OS/RIOT/drivers/sx127x/sx127x_getset.c:823:44: error: format specifies type 'unsigned long' but the argument has
      type 'uint32_t' (aka 'unsigned int') [-Werror,-Wformat]
    DEBUG("[DEBUG] Set TX timeout: %lu\n", timeout);
                                   ~~~     ^~~~~~~
                                   %u
/Users/facosta/git/RIOT-OS/RIOT/core/include/debug.h:97:50: note: expanded from macro 'DEBUG'
#define DEBUG(...) if (ENABLE_DEBUG) DEBUG_PRINT(__VA_ARGS__)
                                                 ^~~~~~~~~~~
/Users/facosta/git/RIOT-OS/RIOT/core/include/debug.h:56:20: note: expanded from macro 'DEBUG_PRINT'
            printf(__VA_ARGS__); \
                   ^~~~~~~~~~~
3 errors generated.
```

  - [ ] emb6 **not sure this are legit errors**
```console
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:98:35: error: comparison of unsigned expression >= 0 is
      always true [-Werror,-Wtautological-compare]
        if( i_addr_byte == 0 && f >= 0 )
                                ~ ^  ~
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:205:51: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
#define LOG_ERR(msg, ...)       LOGGER_ERR(0,msg, ##__VA_ARGS__)
                                                  ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:223:138: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
  ...&& (LOGGER_LEVEL > log_lvl)) printf("%lu |  err | %5s (%d)| " msg "\r\n", bsp_getSec(), __FILE__, __LINE__, ##__VA_ARGS__); }while (0)
                                                                                                                 ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:205:51: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
#define LOG_ERR(msg, ...)       LOGGER_ERR(0,msg, ##__VA_ARGS__)
                                                  ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:223:138: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
  ...&& (LOGGER_LEVEL > log_lvl)) printf("%lu |  err | %5s (%d)| " msg "\r\n", bsp_getSec(), __FILE__, __LINE__, ##__VA_ARGS__); }while (0)
                                                                                                                 ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:205:51: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
#define LOG_ERR(msg, ...)       LOGGER_ERR(0,msg, ##__VA_ARGS__)
                                                  ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:223:138: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
  ...&& (LOGGER_LEVEL > log_lvl)) printf("%lu |  err | %5s (%d)| " msg "\r\n", bsp_getSec(), __FILE__, __LINE__, ##__VA_ARGS__); }while (0)
                                                                                                                 ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:205:51: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
#define LOG_ERR(msg, ...)       LOGGER_ERR(0,msg, ##__VA_ARGS__)
                                                  ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:223:138: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
  ...&& (LOGGER_LEVEL > log_lvl)) printf("%lu |  err | %5s (%d)| " msg "\r\n", bsp_getSec(), __FILE__, __LINE__, ##__VA_ARGS__); }while (0)
                                                                                                                 ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:205:51: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
#define LOG_ERR(msg, ...)       LOGGER_ERR(0,msg, ##__VA_ARGS__)
                                                  ^
/Users/facosta/git/RIOT-OS/RIOT/tests/emb6/bin/pkg/native/emb6/utils/inc/logger.h:223:138: error: token pasting of ',' and __VA_ARGS__ is a
      GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments]
  ...&& (LOGGER_LEVEL > log_lvl)) printf("%lu |  err | %5s (%d)| " msg "\r\n", bsp_getSec(), __FILE__, __LINE__, ##__VA_ARGS__); }while (0)
                                                                                                                 ^
11 errors generated.
```

  - [ ] gnrc_lwmac **comparison errors**
```console
/Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/link_layer/lwmac/lwmac.c:225:27: error: comparison of integers of different signs: 'int' and
      'uint32_t' (aka 'unsigned int') [-Werror,-Wsign-compare]
    if (rtt_get_counter() < last) {
        ~~~~~~~~~~~~~~~~~ ^ ~~~~
/Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/link_layer/lwmac/lwmac.c:234:17: error: comparison of integers of different signs: 'uint32_t'
      (aka 'unsigned int') and 'int' [-Werror,-Wsign-compare]
    while (last < (rtt_get_counter() + GNRC_LWMAC_RTT_EVENT_MARGIN_TICKS)) {
           ~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
/Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/link_layer/lwmac/rx_state_machine.c:211:55: error: format specifies type 'void *' but the
      argument has type 'gnrc_pktsnip_t *' (aka 'struct gnrc_pktsnip *') [-Werror,-Wformat-pedantic]
        LOG_DEBUG("[LWMAC-rx] Inspecting pkt @ %p\n", pkt);
/Users/facosta/git/RIOT-OS/RIOT/sys/net/gnrc/link_layer/lwmac/lwmac.c:801:91: error: format specifies type 'void *' but the argument has
      type 'gnrc_pktsnip_t *' (aka 'struct gnrc_pktsnip *') [-Werror,-Wformat-pedantic]
                    LOG_ERROR("ERROR: [LWMAC] Can't push RX packet @ %p, memory full?\n", pkt);
```

That's what I found so far. Though, I'm not sure if all of them are true positives, but we might want to address them at some point.
aabadie commented 6 years ago

@kYc0o, if I'm not mistaken, Clang is now part of the CI (for native at least). So all issues here should be fixed now, right ?

kYc0o commented 6 years ago

I'll test again this compile issues to be completely sure they're gone before closing.

miri64 commented 6 years ago

@kYc0o maybe also have a look at #9809

aabadie commented 5 years ago

9809 was merged so I think we can close this one. @kYc0o did you re-test that the issues are gone ?

aabadie commented 5 years ago

ping @kYc0o

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.