Compiling with clang --analyze

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-net-gprs@lists.osmocom.org/.

Holger Hans Peter Freyther hfreyther at sysmocom.de
Tue Jul 24 22:23:16 UTC 2012


Hi,

one more email for tonight. Using clang/smatch from time to time
can highlight certain issues. The easiest way to invoke it is this:

$ make CC="clang --analyze" CXX="clang++ --analyze"


1.)
gprs_bssgp_pcu.cpp:241:6: warning: Access to field 'state' results in a dereference of a null pointer (loaded from variable 'bctx')
        if (bctx->state & BVC_S_BLOCKED && pdu_type != BSSGP_PDUT_STATUS)
            ^~~~

the handling of bctx is a bit weird, in theory it can be NULL but
I am not sure if we are likely to receive the messages that would
make the PCU crash though. gprs_bssgp_pcu_rcvmsg can call the above
function/line with a NULL bctx.


2.)
gprs_rlcmac.cpp:728:25: warning: Assigned value is garbage or undefined
                                tbf->dir.ul.usf[ts] = usf[ts];
                                                    ^ ~~~~~~~
Probably true, alloc_algorithm_b is really too big to be readable to
verify that this is not a false positive.

cheers
	holger


-- 
- Holger Freyther <hfreyther at sysmocom.de>       http://www.sysmocom.de/
=======================================================================
* sysmocom - systems for mobile communications GmbH
* Schivelbeiner Str. 5
* 10439 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B
* Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte





More information about the osmocom-net-gprs mailing list