Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[cppcheck] found possible usage of unintialized variable #12

orbitcowboy opened this Issue Jun 27, 2011 · 0 comments


None yet
1 participant

cppcheck warned about a possible uninitialized variable if the preprocessor defines linux and FreeBSD are NOT set.

Please consider the following code from src/pcm.cc (staring form line 178) :

int e, end=0 ;

if defined (linux)

    e = readlink ("/proc/self/exe", link, sizeof(link)-1) ;

elif defined (FreeBSD)

    int exe_path_mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid() } ;
    size_t exe_path_size = sizeof (link) ;
    e = sysctl (exe_path_mib, 4, link, &exe_path_size, NULL, 0) ;

    if (e != -1)
        e = strlen (link) ;


    if (e == -1)   // <--- possible usage of uninitialized value of e

Best regards from the cppcheck team


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment