I'm aware that's a weird use of -include. The difficulty was that to trigger the bug I needed to really include that specific header - not use cppcheck's built in knowledge of standard headers. But using -I would cause it to really process all the other headers too, which I didn't want to do, and those headers triggered some additional spurious warnings that aren't relevant to this case. -include was a workaround to accomplish that. Just including the structure definition inline was a better approach,...
Sorry, it took me a while to look at this again. Here's the revised source including the struct definition. $ cppcheck --enable=all --library=posix --suppress=missingIncludeSystem --suppress=unusedStructMember --suppress=unusedFunction cppcheck-getsockopt-uninitvar.c Checking cppcheck-getsockopt-uninitvar.c ... cppcheck-getsockopt-uninitvar.c:111:2: warning: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [uselessAssignmentPtrArg] tinfo = &tinfo_new;...
It does not. It does appear if I replace the --include with -I /usr/include so cppcheck can find the header that way. That also triggers a bunch of other warnings from headers, though. The warning also appears if I don't include that header, but locally define struct tcp_info. The bug originally appeared that way, but it's a large structure, so I used the header for brevity, The warning does not appear if I use the version of the structure defined in /usr/include/netinet/tcp.h instead of the one...
It does not. It does appear if I replace the --include with -I /usr/include so cppcheck can find the header that way. The second approach also triggers a bunch of other warnings from headers, though. The warning also appears if I don't include that header, but locally define struct tcp_info. The bug originally appeared that way, but it's a large structure, so I used the header for brevity, The warning does not appear if I use the version of the structure defined in /usr/include/netinet/tcp.h instead...
I just encountered an odd false positive on uninitvar. cppcheck is detecting an variable as uninitialized, although it has been set as the result of a getsockopt(). Specifically, with the attached example file: $ cppcheck --enable=all --library=posix --suppress=missingIncludeSystem --suppress=unusedStructMember --suppress=unusedFunction --include=/usr/include/linux/tcp.h cppcheck-getsockopt-uninitvar.c Checking cppcheck-getsockopt-uninitvar.c ... Checking cppcheck-getsockopt-uninitvar.c: __BIG_ENDIAN_BITFIELD......
I just encountered an odd false positive on uninitvar. cppcheck is detecting an variable as uninitialized, although it has been set as the result of a getsockopt(). Specifically, with the attached example file: $ cppcheck --enable=all --library=posix --suppress=missingIncludeSystem --suppress=unusedStructMember --suppress=unusedFunction --include=/usr/include/linux/tcp.h cppcheck-getsockopt-uninitvar.c Checking cppcheck-getsockopt-uninitvar.c ... Checking cppcheck-getsockopt-uninitvar.c: __BIG_ENDIAN_BITFIELD......
It does not. It does appear if I replace the --include with -I /usr/include so cppcheck can find the header that way. The second approach also triggers a bunch of other warnings from headers, though. The warning also appears if I don't include that header, but locally define struct tcp_info. The bug originally appeared that way, but it's a large structure, so I used the header for brevity,
It does not. It does appear if I replace the --include with -I /usr/include so cppcheck can find the header that way. The second approach also triggers a bunch of other warnings from headers, though.