Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/brpc/ubshm/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ static inline uint64_t GetCurNanoSeconds(void) {

#define FREE_PTR(ptr) \
do { \
if ((ptr) != NULL) { \
if ((ptr) != nullptr) { \
free(ptr); \
(ptr) = NULL; \
(ptr) = nullptr; \
} \
} while (0)

Expand Down
2 changes: 1 addition & 1 deletion src/brpc/ubshm/common/thread_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern "C" {

static inline void UnlockMutex(pthread_mutex_t **mtx)
{
if (LIKELY(mtx != NULL && *mtx != NULL)) {
if (LIKELY(mtx != nullptr && *mtx != nullptr)) {
pthread_mutex_unlock(*mtx);
} else {
LOG(ERROR) << "Invalid input for mtx.";
Expand Down
30 changes: 15 additions & 15 deletions src/brpc/ubshm/shm/shm_ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ RETURN_CODE IpcShmLocalMalloc(SHM *shm)
return SHM_ERR;
}

shm->addr = (uint8_t*)mmap(NULL, shm->len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
shm->addr = (uint8_t*)mmap(nullptr, shm->len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (shm->addr == (uint8_t*)MAP_FAILED) {
LOG(ERROR) << "IPC map shm=" << shm->name << " length=" << shm->len << " failed, ret(" << errno << ").";
shm->addr = NULL;
shm->addr = nullptr;
close(fd);
shm_unlink(shm->name);
return SHM_ERR;
Expand All @@ -106,7 +106,7 @@ RETURN_CODE IpcShmLocalMalloc(SHM *shm)

RETURN_CODE IpcShmMunmap(SHM *shm)
{
if (shm->addr == NULL) {
if (shm->addr == nullptr) {
LOG(INFO) << "IPC unmap shm=" << shm->name << " already unmapped.";
return UBRING_OK;
}
Expand All @@ -117,7 +117,7 @@ RETURN_CODE IpcShmMunmap(SHM *shm)
return SHM_ERR;
}

shm->addr = NULL;
shm->addr = nullptr;
LOG(INFO) << "IPC unmap shm=" << shm->name << " length=" << shm->len << " success.";
return UBRING_OK;
}
Expand All @@ -133,7 +133,7 @@ RETURN_CODE IpcShmFree(SHM *shm)
}
if (errno == ENOENT) {
LOG(INFO) << "IPC free shm=" << shm->name << " already deleted.";
shm->addr = NULL;
shm->addr = nullptr;
return SHM_ERR_NOT_FOUND;
}
LOG_EVERY_SECOND(ERROR) << "IPC free shm=" << shm->name << " failed, errno=" << errno;
Expand All @@ -144,7 +144,7 @@ RETURN_CODE IpcShmFree(SHM *shm)

RETURN_CODE IpcShmLocalFree(SHM *shm)
{
if (shm->addr == NULL) {
if (shm->addr == nullptr) {
LOG(INFO) << "IPC free local shm=" << shm->name << " already freed.";
return SHM_ERR_NOT_FOUND;
}
Expand All @@ -153,7 +153,7 @@ RETURN_CODE IpcShmLocalFree(SHM *shm)
if (ret != UBRING_OK) {
LOG(WARNING) << "IPC unmap shm=" << shm->name << " failed, ret=" << ret;
} else {
shm->addr = NULL;
shm->addr = nullptr;
}

ret = shm_unlink(shm->name);
Expand All @@ -164,13 +164,13 @@ RETURN_CODE IpcShmLocalFree(SHM *shm)
}
if (errno == ENOENT) {
LOG(INFO) << "IPC delete shm=" << shm->name << " already deleted by peer.";
shm->addr = NULL;
shm->addr = nullptr;
return SHM_ERR_NOT_FOUND;
}
LOG_EVERY_SECOND(ERROR) << "IPC delete shm=" << shm->name << " failed, ret=" << ret;
return SHM_ERR;
}
shm->addr = NULL;
shm->addr = nullptr;
LOG(INFO) << "IPC free local shm=" << shm->name << " success.";
return UBRING_OK;
}
Expand All @@ -188,10 +188,10 @@ RETURN_CODE IpcShmRemoteMalloc(SHM *shm)
return SHM_ERR;
}

shm->addr = (uint8_t*)mmap(NULL, shm->len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
shm->addr = (uint8_t*)mmap(nullptr, shm->len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (shm->addr == (uint8_t*)MAP_FAILED) {
LOG(ERROR) << "IPC map shm=" << shm->name << " failed, ret=" << errno;
shm->addr = NULL;
shm->addr = nullptr;
close(fd);
return SHM_ERR;
}
Expand All @@ -213,10 +213,10 @@ RETURN_CODE IpcShmLocalMmap(SHM *shm, int prot)
return SHM_ERR;
}

shm->addr = (uint8_t*)mmap(NULL, shm->len, prot, MAP_SHARED, fd, 0);
shm->addr = (uint8_t*)mmap(nullptr, shm->len, prot, MAP_SHARED, fd, 0);
if (shm->addr == (uint8_t*)MAP_FAILED) {
LOG(ERROR) << "IPC map shm=" << shm->name << " failed, ret=" << errno;
shm->addr = NULL;
shm->addr = nullptr;
close(fd);
return SHM_ERR;
}
Expand All @@ -228,7 +228,7 @@ RETURN_CODE IpcShmLocalMmap(SHM *shm, int prot)

RETURN_CODE IpcShmRemoteFree(SHM *shm)
{
if (shm->addr == NULL) {
if (shm->addr == nullptr) {
LOG(INFO) << "IPC free remote shm=" << shm->name << " already freed.";
return UBRING_OK;
}
Expand All @@ -239,7 +239,7 @@ RETURN_CODE IpcShmRemoteFree(SHM *shm)
return SHM_ERR;
}

shm->addr = NULL;
shm->addr = nullptr;
LOG(INFO) << "IPC free remote shm=" << shm->name << " success.";
return UBRING_OK;
}
Expand Down
4 changes: 2 additions & 2 deletions src/brpc/ubshm/shm/shm_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DEFINE_int32(ub_shm_type, 1, "shm type: 1-ipc; 2-ub_ring");
static SHM_TYPE g_shm_type;

static bool CheckInputShmParam(SHM *shm) {
if (shm == NULL) {
if (shm == nullptr) {
LOG(ERROR) << "Input Param shm is NULL.";
return false;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ RETURN_CODE ShmLocalCalloc(SHM *shm) {
LOG(ERROR) << "Failed to alloc local shm.";
return rc;
}
if (UNLIKELY(shm->addr == NULL)) {
if (UNLIKELY(shm->addr == nullptr)) {
LOG(ERROR) << "Local shm=" << shm->name << " allocated with NULL address.";
ShmFree(shm);
return SHM_ERR;
Expand Down
Loading
Loading