C & C++

C & C++

Made by DeepSource

Found posix_* or pthread_* return value tested to be negative CXX-W2013

Bug risk
Major

The pthread_* or posix_* functions (except posix_openpt) always return a positive values. When the functions mentioned above are used in negative integer range checks, the expression will always be resolved to false as these functions return either zero (on success) or a positive err-no on failure.

Consider cleaning up the code by removing the redundant block or if it's a bug consider fixing it.

Bad practice

int main(void) {
    if (posix_fadvise(...) < 0) {
        // will never be executed
    }
}

Recommended

int main(void) {
    // if it was bugged.
    if (posix_fadvise(...) > 0) {
        // will be executed if err is raised
        // handle the error...
    }
}