Project

General

Profile

Bug #3684

Always true/false conditions (reported by clang-4.0 with -Wall)

Added by fixeria 6 days ago. Updated 6 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
11/09/2018
Due date:
% Done:

0%

Resolution:

Description

Sorry for so brief and lazy report, no time.

db.c:278:25: warning: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always false
      [-Wtautological-constant-out-of-range-compare]
        if (sms->user_data_len > sizeof(sms->user_data))
            ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
db.c:424:25: warning: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always false
      [-Wtautological-constant-out-of-range-compare]
        if (sms->user_data_len > sizeof(sms->user_data))
            ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
db.c:780:25: warning: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always false
      [-Wtautological-constant-out-of-range-compare]
        if (sms->user_data_len > sizeof(sms->user_data))
            ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
osmo_msc.c:243:23: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (conn->use_tokens < 0)
            ~~~~~~~~~~~~~~~~ ^ ~
osmo_msc.c:277:29: warning: comparison of constant 32 with expression of type 'enum msc_subscr_conn_use' is always true
      [-Wtautological-constant-out-of-range-compare]
                OSMO_ASSERT(balance_token < 32);
                            ~~~~~~~~~~~~~ ^ ~~
/usr/local/include/osmocom/core/utils.h:89:8: note: expanded from macro 'OSMO_ASSERT'
        if (!(exp)) { \
              ^~~
osmo_msc.c:304:29: warning: comparison of constant 32 with expression of type 'enum msc_subscr_conn_use' is always true
      [-Wtautological-constant-out-of-range-compare]
                OSMO_ASSERT(balance_token < 32);
                            ~~~~~~~~~~~~~ ^ ~~
/usr/local/include/osmocom/core/utils.h:89:8: note: expanded from macro 'OSMO_ASSERT'
        if (!(exp)) { \
              ^~~
smpp_openbsc.c:211:5: warning: comparison of constant 256 with expression of type 'uint8_t' (aka 'unsigned char') is always false
      [-Wtautological-constant-out-of-range-compare]
                                OSMO_MIN(ud_len, sizeof(sms->user_data)));
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/osmocom/core/utils.h:21:29: note: expanded from macro 'OSMO_MIN'
#define OSMO_MIN(a, b) ((a) >= (b) ? (b) : (a))
                        ~~~ ^  ~~~

History

#1 Updated by fixeria 6 days ago

How to reproduce all warnings:

$ ./configure --enable-smpp --enable-sanitize CC=clang-4.0
$ make

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)