On 07/16/2011 01:49 PM, Harald Welte wrote:
Hi!
I've started to play a bit with Smatch (
http://smatch.sourceforge.net/)
and fixed a number of bugs in libosmocore.
When applying it to openbsc, I get:
CC ipaccess.o
/home/laforge/projects/git/openbsc/openbsc/src/libabis/input/ipaccess.c +455
ipaccess_drop(28) info: loop could be replaced with if statement.
/home/laforge/projects/git/openbsc/openbsc/src/libabis/input/ipaccess.c +451
ipaccess_drop(24) info: ignoring unreachable code.
The point herer is: we loop over a list, but we return from the first
iteration of the loop. Zecke?
yes, it can be done with if (!llist_empty()), only ugly part is to access the
first element and cast it. Will fix it today.
CC paging.o
/home/laforge/projects/git/openbsc/openbsc/src/libbsc/paging.c +134 can_send_pag_req(25)
info: ignoring unreachable code.
We have a goto statement in each possible caes (including defualt) above
it. So the return 0 will never be hit. That's ok and not a bug. But I
think the code is too convoluted this way. I think we should have one
function that just returns (sdcch/tch) based on the rsl_type and
net->pag_any_tch, and then a second function that has a simple if/else.
I'm not against goto - but I think this time it really can be avoided
easily.
Okay, will clean this up a bit.
CC ipaccess-firmware.o
/home/laforge/projects/git/openbsc/openbsc/src/ipaccess/ipaccess-firmware.c +64
ipaccess_analyze_file(26) warn: buffer overflow 'firmware_header->more_magic' 2
<= 2
/home/laforge/projects/git/openbsc/openbsc/src/ipaccess/ipaccess-firmware.c +64
ipaccess_analyze_file(26) warn: buffer overflow 'firmware_header->more_magic' 2
<= 3
zecke?
Will take a look.
CC bsc_nat.o
/home/laforge/projects/git/openbsc/openbsc/src/osmo-bsc_nat/bsc_nat.c +1553
get_next_free_bsc_id(20) info: ignoring unreachable code.
zecke?
looks like a bogus break in there, will test.