https://osmocom.org/https://osmocom.org/favicon.ico?16647414092018-11-09T01:46:30ZOpen Source Mobile CommunicationsOsmoMSC - Bug #3684: Always true/false conditions (reported by clang-4.0 with -Wall)https://osmocom.org/issues/3684?journal_id=125382018-11-09T01:46:30Zfixeria
<ul></ul><p>How to reproduce all warnings:</p>
<pre>
$ ./configure --enable-smpp --enable-sanitize CC=clang-4.0
$ make
</pre> OsmoMSC - Bug #3684: Always true/false conditions (reported by clang-4.0 with -Wall)https://osmocom.org/issues/3684?journal_id=126812018-11-25T19:45:31Zfixeria
<ul><li><strong>Priority</strong> changed from <i>Normal</i> to <i>Low</i></li></ul> OsmoMSC - Bug #3684: Always true/false conditions (reported by clang-4.0 with -Wall)https://osmocom.org/issues/3684?journal_id=137212019-03-31T11:43:47Zfixeria
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>In Progress</i></li></ul><p>Regarding the first three warnings:</p>
<pre>
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))
~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
</pre>
<p>please see: <a class="external" href="https://gerrit.osmocom.org/#/c/osmo-msc/+/13470/">https://gerrit.osmocom.org/#/c/osmo-msc/+/13470/</a></p>
<p>While investigating this and reading libdbi's documentation, I've also noticed the following (see 3.5.3):</p>
<blockquote>
<p>dbi_result_get_field_length() returns the length in bytes of the value stored in the specified field. This is <strong>always one less than the size</strong>, and is probably <strong>only useful for fields containing strings</strong>.</p>
</blockquote>
<p>Do we expect this? There is an alternative function:</p>
<blockquote>
<p>dbi_result_get_field_size() returns the size in bytes of the value stored in the specified field. This is especially <strong>useful for string and binary data fields</strong>, which may have a dynamic size.</p>
</blockquote> OsmoMSC - Bug #3684: Always true/false conditions (reported by clang-4.0 with -Wall)https://osmocom.org/issues/3684?journal_id=137222019-03-31T11:54:48Zfixeria
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Feedback</i></li><li><strong>Assignee</strong> set to <i>fixeria</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>90</i></li></ul><p>Other warnings are most likely going to be resolved by the upcoming changes from neels/ho.</p>
<p>The last one:</p>
<pre>
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))
~~~ ^ ~~~
</pre>
<p>can be safely ignored, I couldn't find any potential threats.</p> OsmoMSC - Bug #3684: Always true/false conditions (reported by clang-4.0 with -Wall)https://osmocom.org/issues/3684?journal_id=146962019-06-03T10:52:55Zfixeria
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Resolved</i></li><li><strong>% Done</strong> changed from <i>90</i> to <i>100</i></li></ul><p>Most of warnings have been resolved. The only one left is related to the internal SMS Centre, which is going to be ripped out some day.</p>