Skip to content

Commit

Permalink
Use nullptr where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
robertswiecki committed Oct 20, 2023
1 parent 94b022f commit ac2a69d
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 110 deletions.
4 changes: 2 additions & 2 deletions caps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static cap_user_data_t getCaps() {
};
if (util::syscall(__NR_capget, (uintptr_t)&cap_hdr, (uintptr_t)&cap_data) == -1) {
PLOG_W("capget() failed");
return NULL;
return nullptr;
}
return cap_data;
}
Expand Down Expand Up @@ -214,7 +214,7 @@ static bool initNsKeepCaps(cap_user_data_t cap_data) {

bool initNs(nsjconf_t* nsjconf) {
cap_user_data_t cap_data = getCaps();
if (cap_data == NULL) {
if (cap_data == nullptr) {
return false;
}

Expand Down
196 changes: 98 additions & 98 deletions cmdline.cc

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions contain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static bool containMakeFdsCOEProc(nsjconf_t* nsjconf) {
return false;
}
DIR* dir = fdopendir(dirfd);
if (dir == NULL) {
if (dir == nullptr) {
PLOG_W("fdopendir(fd=%d)", dirfd);
close(dirfd);
return false;
Expand All @@ -245,12 +245,12 @@ static bool containMakeFdsCOEProc(nsjconf_t* nsjconf) {
for (;;) {
errno = 0;
struct dirent* entry = readdir(dir);
if (entry == NULL && errno != 0) {
if (entry == nullptr && errno != 0) {
PLOG_D("readdir('/proc/self/fd')");
closedir(dir);
return false;
}
if (entry == NULL) {
if (entry == nullptr) {
break;
}
if (strcmp(".", entry->d_name) == 0) {
Expand Down
6 changes: 3 additions & 3 deletions mnt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static bool isDir(const char* path) {
/*
* If the source dir is NULL, we assume it's a dir (for /proc and tmpfs)
*/
if (path == NULL) {
if (path == nullptr) {
return true;
}
struct stat st;
Expand Down Expand Up @@ -535,7 +535,7 @@ static bool addMountPt(mount_t* mnt, const std::string& src, const std::string&
const std::string& src_content, bool is_symlink) {
if (!src_env.empty()) {
const char* e = getenv(src_env.c_str());
if (e == NULL) {
if (e == nullptr) {
LOG_W("No such envar:%s", QC(src_env));
return false;
}
Expand All @@ -545,7 +545,7 @@ static bool addMountPt(mount_t* mnt, const std::string& src, const std::string&

if (!dst_env.empty()) {
const char* e = getenv(dst_env.c_str());
if (e == NULL) {
if (e == nullptr) {
LOG_W("No such envar:%s", QC(dst_env));
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace net {
static bool cloneIface(
nsjconf_t* nsjconf, struct nl_sock* sk, struct nl_cache* link_cache, int pid) {
struct rtnl_link* rmv = rtnl_link_macvlan_alloc();
if (rmv == NULL) {
if (rmv == nullptr) {
LOG_E("rtnl_link_macvlan_alloc()");
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions user.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static uid_t parseUid(const std::string& id) {
return getuid();
}
struct passwd* pw = getpwnam(id.c_str());
if (pw != NULL) {
if (pw != nullptr) {
return pw->pw_uid;
}
if (util::isANumber(id.c_str())) {
Expand All @@ -333,7 +333,7 @@ static gid_t parseGid(const std::string& id) {
return getgid();
}
struct group* gr = getgrnam(id.c_str());
if (gr != NULL) {
if (gr != nullptr) {
return gr->gr_gid;
}
if (util::isANumber(id.c_str())) {
Expand Down
2 changes: 1 addition & 1 deletion util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ bool createDirRecursively(const char* dir) {
}

char* next = strchr(curr, '/');
if (next == NULL) {
if (next == nullptr) {
close(prev_dir_fd);
return true;
}
Expand Down

0 comments on commit ac2a69d

Please sign in to comment.