cppcheck errors

Joel Sherrill joel.sherrill at oarcorp.com
Tue Sep 1 21:43:46 UTC 2015



On 9/1/2015 2:10 PM, Martin Galvan wrote:
> Hi everyone!
>
> I just ran CppCheck again on a fresh clone of the git repo and saw the
> number of error reports was quite smaller than what I reported before.
> That's because my previous run was on a (quite older) version; most of
> those must've been fixed already.
>
> Some of the error reports remain, though. I opened a ticket for that
> and will send a patch that fixes the issues Joel mentioned as worth
> looking at. I'll open separate tickets for issues reported as
> "warning" and "portability" (such as the void * thing), and send their
> respective patches when they're done.
>
> While working the fixes I noticed that the following error:
>
> [cpukit/librpc/src/rpc/netnamer.c:331]: (error) Resource leak: fd
>
> seems to be a false positive. getnetid will be stuck in an endless for
> loop until it exits through one of the return statements; all of them
> seem to have their corresponding fclose (if necessary).

Great. This code did not originate from RTEMS. It is the original Sun
RPC/XDR code. :)

> I also noticed some new error reports. It would be nice if Joel (or
> anyone else who knows the code base better than me) took a look at
> these and pointed out which ones are third-party code:
>
> [cpukit/libfs/src/dosfs/msdos_format.c:1105]: (error) Uninitialized
> struct member: fmt_params.mbr_copy_sec
> [cpukit/libfs/src/nfsclient/src/rpcio.c:1203]: (error) Uninitialized
> variable: stat
> [cpukit/libmisc/shell/print-ls.c:108]: (error) Invalid number of
> character ({) when these macros are defined: 'RTEMS_REMOVED'.

These are ours to fix.

> [cpukit/libnetworking/libc/getifaddrs.c:251]: (error) Deallocation of
> an auto-variable results in undefined behaviour.
> [cpukit/libnetworking/libc/getifaddrs.c:256]: (error) Deallocation of
> an auto-variable results in undefined behaviour.

This code originated in FreeBSD but it sounds interesting enough to look at.

> [cpukit/libnetworking/net/radix.c:935]: (error) Uninitialized variable: error
> [cpukit/libnetworking/net/radix.c:977]: (error) Uninitialized variable: error
> [cpukit/libnetworking/netinet/in.c:647]: (error) Memory leak: inm
> [cpukit/libnetworking/netinet/ip_fw.c:690]: (error) Memory leak: fwc

FreeBSD code.

> [cpukit/mghttpd/mongoose.c:2811] -> [cpukit/mghttpd/mongoose.c:1221]:
> (error) Mismatching allocation and deallocation: dir
> [cpukit/mghttpd/mongoose.c:2852] -> [cpukit/mghttpd/mongoose.c:1221]:
> (error) Mismatching allocation and deallocation: dir
>

This code is from another project and we are trying to replace it but
this looks odd enough to investigate and fix.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985


More information about the devel mailing list