libsemanage: drop checks on semanage_module_info_destroy() value

semanage_module_info_destroy() always returns 0. Nevertheless
semanage_direct_list_all() uses its return value in a surprising way:

    cleanup:
        if (priorities != NULL) {
            /* ... */
            free(priorities);
        }
        /* ... */
        ret = semanage_module_info_destroy(sh, modinfo_tmp);
        if (ret != 0) {
            status = -1;
            goto cleanup;
        }

The last "goto cleanup;" leads clang's static analyzer to believe a
double free is possible. Even though this is a false positive, the
body of condition "if (ret != 0)" contains dead code. Remove it.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
Nicolas Iooss 2017-04-07 22:44:27 +02:00 committed by Stephen Smalley
parent 55b5b7a646
commit 86e6ae67fd

View File

@ -2495,11 +2495,7 @@ static int semanage_direct_list_all(semanage_handle_t *sh,
goto cleanup;
}
ret = semanage_module_info_destroy(sh, modinfo_tmp);
if (ret != 0) {
status = -1;
goto cleanup;
}
semanage_module_info_destroy(sh, modinfo_tmp);
free(modinfo_tmp);
modinfo_tmp = NULL;
@ -2524,11 +2520,7 @@ cleanup:
free(modules);
}
ret = semanage_module_info_destroy(sh, modinfo_tmp);
if (ret != 0) {
status = -1;
goto cleanup;
}
semanage_module_info_destroy(sh, modinfo_tmp);
free(modinfo_tmp);
modinfo_tmp = NULL;