CppCheck on Samba

Lukas Slebodnik lslebodn at redhat.com
Fri Mar 28 03:36:57 MDT 2014

On (28/03/14 11:08), Zahari Zahariev wrote:
>Hello Andrew,
>Long time no see!
>Finally I got my ... together and dicided to do something towards
>Samba. I am recently researching all sorts of static analysis tools
>mainly for work but I always have Samba on my mind. So found this one
>CppCheck that is a free C/C++ code analysis tool that integrates
>neatly with Jenkins to report errors to do with code.
>Here is what it says:
>Do you think it is credible findings especially the 187 errors?
>Thank you!

You should disable some warnings.
For example: unusedFunction or variableScope

libcli/cldap/cldap.c    1171    style   unusedFunction
                    The function 'cldap_netlogon_reply' is never used.

It if a false positive because function cldap_netlogon_reply is public
function declared in header file libcli/cldap/cldap.h and defined in
libcli/cldap/cldap.c (libcli/cldap/cldap.h is included in libcli/cldap/cldap.c)

I think it is a preferred way (samba coding style) to declare variable
at the beginning of function even if variable is used only in one block.

Some errors are also false positive

libcli/util/nterr.c 907 error   syntaxError syntax error

905 NTSTATUS nt_status_squash(NTSTATUS nt_status)
906 {
907   if NT_STATUS_IS_OK(nt_status) {
    There are no brackets after "if", but after expanding macro NT_STATUS_IS_OK
    there will be brackets.
908     return nt_status;


More information about the samba-technical mailing list