Skip to content

Commit

Permalink
set dir = nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
ehds committed Oct 17, 2023
1 parent 5bc5abc commit ddfd893
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/butil/files/dir_reader_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef BUTIL_FILES_DIR_READER_UNIX_H_
#define BUTIL_FILES_DIR_READER_UNIX_H_

#include <cstddef>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
Expand All @@ -44,13 +43,17 @@ class DirReaderUnix {

~DirReaderUnix() {
if (NULL != dir_) {
if (IGNORE_EINTR(closedir(dir_))) { // note this implicitly closes fd_
RAW_LOG(ERROR, "Failed to close directory handle");
if (IGNORE_EINTR(closedir(dir_)) == 0) { // this implicitly closes fd_
dir_ = NULL;
} else {
RAW_LOG(ERROR, "Failed to close directory.");
}
};
}

bool IsValid() const { return dir_ == NULL; }
bool IsValid() const {
return dir_ != NULL;
}

// Move to the next entry returning false if the iteration is complete.
bool Next() {
Expand Down

0 comments on commit ddfd893

Please sign in to comment.