Verified Commit e9cb2605 authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

follow glibc convention for error numbers

readdir and closedir in glibc returns a EINVAL if the directory pointer
passed as parameter is NULL
parent ba0144e9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ struct dirent* readdir(DIR* dirp){
    init_passthrough_if_needed();
    #pragma GCC diagnostic ignored "-Wnonnull-compare"
    if(dirp == nullptr){
        errno = EBADF;
        errno = EINVAL;
        return nullptr;
    }
    auto fd = dirp_to_fd(dirp);
@@ -491,7 +491,7 @@ int closedir(DIR* dirp) {
    init_passthrough_if_needed();
    #pragma GCC diagnostic ignored "-Wnonnull-compare"
    if(dirp == nullptr){
        errno = EBADF;
        errno = EINVAL;
        return -1;
    }
    auto fd = dirp_to_fd(dirp);
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ int main(int argc, char* argv[]) {

    // Close nonexisting directory
    ret = closedir(NULL);
    if(ret != -1 || errno != EBADF){
    if(ret != -1 || errno != EINVAL){
        std::cerr << "Error closing nonexisting directory: " << std::strerror(errno) << std::endl;
        return -1;
    }