[osmo-fl2k] Code issues/warnings report

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.

SDR is cool sdr_is_cool at riseup.net
Wed May 23 14:18:58 UTC 2018


Hi everybody,

Thank you for developing osmo-fl2k.
Just wanted to report some relevant code issues/warnings I've found in osmo-fl2k's codebase: hope you'll find it useful.
All the issues reported below are based upon the source code as seen in commit 16b102efcdae6c33b1761e4f2da8c507eed03bb4 (osmo-fl2k's git repo current HEAD).

- libosmo-fl2k.c:213 Implicit cast of expression '(pll_clock * mult) / (uint32_t) div' from 'uint32_t' type to 'double' type (perform explicit cast to avoid the loss of the fractional part. Is it intentional?).
- libosmo-fl2k.c:216 Implicit cast of expression '(uint32_t) offset * frac' from 'uint32_t' type to 'double' type (perform explicit cast to avoid integer overflow).
- libosmo-fl2k.c:250 Absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value (use function 'fabs' instead).
- libosmo-fl2k.c:252 Absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value (use function 'fabs' instead).
- libosmo-fl2k.c:262 Absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value (use function 'fabs' instead).
- libosmo-fl2k.c:263 Incorrect 'fprintf' format for argument 'target_freq' (use '%lu' format specifier and add explicit cast like: '(unsigned long)target_freq' or use 'PRIu32' macro from 'inttypes.h').
- libosmo-fl2k.c:458 Useless if (expression 'dev' is always true).
- libosmo-fl2k.c:577 There might be dereferencing of a potential null pointer 'dev->xfer' (malloc call at may return NULL: line 574).
- libosmo-fl2k.c:580 A potential null pointer is given to 'memset' function (malloc call may return NULL: line 579).
- libosmo-fl2k.c:583 A potential null pointer is given to 'memset' function (malloc call may return NULL: line 582).
- libosmo-fl2k.c:586 Incorrect 'fprintf' format for argument 'dev->xfer_buf_num' (use '%lu' format specifier and add explicit cast like: '(unsigned long)dev->xfer_buf_num' or use 'PRIu32' macro from 'inttypes.h').
- libosmo-fl2k.c:593 Incorrect 'fprintf' format for argument 'i' (use '%u' format specifier).
- libosmo-fl2k.c:650 Incorrect 'fprintf' format for argument 'i' (use '%u' format specifier).
- libosmo-fl2k.c:856 Incorrect 'fprintf' format for argument 'dev->underflow_cnt - underflows' (use '%lu' format specifier and add explicit cast like: '(unsigned long)(dev->underflow_cnt - underflows)' or use 'PRIu32' macro from 'inttypes.h').
- fl2k_file.c:98     Incorrect 'fprintf' format for argument 'repeat_cnt' (use '%lu' format specifier and add explicit cast like: '(unsigned long)repeat_cnt' or use 'PRIu32' macro from 'inttypes.h').
- fl2k_file.c:169    The 'r' variable is assigned values twice successively (missing return code check after first assignment?).
- fl2k_fm.c:570      The 'r' variable is assigned values twice successively (missing return code check after first assignment?).
- fl2k_tcp.c:193     The 'r' variable is assigned values twice successively (missing return code check after first assignment?).
- fl2k_test.c:259    Incorrect 'fprintf' format for argument 'dev_index' (use '%lu' format specifier and add explicit cast like: '(unsigned long)dev_index' or use 'PRIu32' macro from 'inttypes.h').
- fl2k_test.c:278    Integer overflow (attempt to store value 255 in a char type variable (which may be signed: range [-128, 127]): redefine 'buffer' variable as 'signed char' type to fix the issue).
- fl2k_test.c:284    The 'r' variable is assigned values twice successively (missing return code check after first assignment?).
- fl2k_test.c:301    Useless if (expression 'do_exit' is always true).


Regards,
SDR_is_cool



More information about the osmocom-sdr mailing list