aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/support
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-11-10 09:53:21 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-11-10 09:53:21 -0800
commit4782d92b2d4fab261b5520a29d79ba97fea9ce7b (patch)
treed060fc1c4093583abc9348cc69a64b52d065f6e3 /src/core/lib/support
parent1ef989cd50cdfb172e99c552a67e3ed5f350e5cc (diff)
s/NULL/nullptr
Diffstat (limited to 'src/core/lib/support')
-rw-r--r--src/core/lib/support/alloc.cc14
-rw-r--r--src/core/lib/support/arena.cc2
-rw-r--r--src/core/lib/support/atomic_with_atm.h2
-rw-r--r--src/core/lib/support/avl.cc36
-rw-r--r--src/core/lib/support/cmdline.cc20
-rw-r--r--src/core/lib/support/env_linux.cc10
-rw-r--r--src/core/lib/support/host_port.cc18
-rw-r--r--src/core/lib/support/log.cc6
-rw-r--r--src/core/lib/support/log_linux.cc4
-rw-r--r--src/core/lib/support/mpscq.cc16
-rw-r--r--src/core/lib/support/string.cc14
-rw-r--r--src/core/lib/support/string_posix.cc6
-rw-r--r--src/core/lib/support/subprocess_posix.cc6
-rw-r--r--src/core/lib/support/sync.cc6
-rw-r--r--src/core/lib/support/sync_posix.cc4
-rw-r--r--src/core/lib/support/thd_posix.cc6
-rw-r--r--src/core/lib/support/time_posix.cc2
-rw-r--r--src/core/lib/support/tmpfile_posix.cc10
18 files changed, 91 insertions, 91 deletions
diff --git a/src/core/lib/support/alloc.cc b/src/core/lib/support/alloc.cc
index aef4cb8d51..518bdb99f7 100644
--- a/src/core/lib/support/alloc.cc
+++ b/src/core/lib/support/alloc.cc
@@ -40,10 +40,10 @@ gpr_allocation_functions gpr_get_allocation_functions() {
}
void gpr_set_allocation_functions(gpr_allocation_functions functions) {
- GPR_ASSERT(functions.malloc_fn != NULL);
- GPR_ASSERT(functions.realloc_fn != NULL);
- GPR_ASSERT(functions.free_fn != NULL);
- if (functions.zalloc_fn == NULL) {
+ GPR_ASSERT(functions.malloc_fn != nullptr);
+ GPR_ASSERT(functions.realloc_fn != nullptr);
+ GPR_ASSERT(functions.free_fn != nullptr);
+ if (functions.zalloc_fn == nullptr) {
functions.zalloc_fn = zalloc_with_gpr_malloc;
}
g_alloc_functions = functions;
@@ -51,7 +51,7 @@ void gpr_set_allocation_functions(gpr_allocation_functions functions) {
void* gpr_malloc(size_t size) {
void* p;
- if (size == 0) return NULL;
+ if (size == 0) return nullptr;
GPR_TIMER_BEGIN("gpr_malloc", 0);
p = g_alloc_functions.malloc_fn(size);
if (!p) {
@@ -63,7 +63,7 @@ void* gpr_malloc(size_t size) {
void* gpr_zalloc(size_t size) {
void* p;
- if (size == 0) return NULL;
+ if (size == 0) return nullptr;
GPR_TIMER_BEGIN("gpr_zalloc", 0);
p = g_alloc_functions.zalloc_fn(size);
if (!p) {
@@ -80,7 +80,7 @@ void gpr_free(void* p) {
}
void* gpr_realloc(void* p, size_t size) {
- if ((size == 0) && (p == NULL)) return NULL;
+ if ((size == 0) && (p == nullptr)) return nullptr;
GPR_TIMER_BEGIN("gpr_realloc", 0);
p = g_alloc_functions.realloc_fn(p, size);
if (!p) {
diff --git a/src/core/lib/support/arena.cc b/src/core/lib/support/arena.cc
index 0b37a88230..5b9dd370d8 100644
--- a/src/core/lib/support/arena.cc
+++ b/src/core/lib/support/arena.cc
@@ -62,7 +62,7 @@ void* gpr_arena_alloc(gpr_arena* arena, size_t size) {
zone* z = &arena->initial_zone;
while (start > z->size_end) {
zone* next_z = (zone*)gpr_atm_acq_load(&z->next_atm);
- if (next_z == NULL) {
+ if (next_z == nullptr) {
size_t next_z_size = (size_t)gpr_atm_no_barrier_load(&arena->size_so_far);
next_z = (zone*)gpr_zalloc(sizeof(zone) + next_z_size);
next_z->size_begin = z->size_end;
diff --git a/src/core/lib/support/atomic_with_atm.h b/src/core/lib/support/atomic_with_atm.h
index fe00e9b5bc..5d675ff876 100644
--- a/src/core/lib/support/atomic_with_atm.h
+++ b/src/core/lib/support/atomic_with_atm.h
@@ -21,7 +21,7 @@
#include <grpc/support/atm.h>
-namespace grpc_core {
+namespace grpc_core;; {
enum MemoryOrderRelaxed { memory_order_relaxed };
diff --git a/src/core/lib/support/avl.cc b/src/core/lib/support/avl.cc
index 4ba101b74a..ca0e4c6372 100644
--- a/src/core/lib/support/avl.cc
+++ b/src/core/lib/support/avl.cc
@@ -28,7 +28,7 @@
gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable) {
gpr_avl out;
out.vtable = vtable;
- out.root = NULL;
+ out.root = nullptr;
return out;
}
@@ -41,7 +41,7 @@ static gpr_avl_node* ref_node(gpr_avl_node* node) {
static void unref_node(const gpr_avl_vtable* vtable, gpr_avl_node* node,
void* user_data) {
- if (node == NULL) {
+ if (node == nullptr) {
return;
}
if (gpr_unref(&node->refs)) {
@@ -54,18 +54,18 @@ static void unref_node(const gpr_avl_vtable* vtable, gpr_avl_node* node,
}
static long node_height(gpr_avl_node* node) {
- return node == NULL ? 0 : node->height;
+ return node == nullptr ? 0 : node->height;
}
#ifndef NDEBUG
static long calculate_height(gpr_avl_node* node) {
- return node == NULL ? 0
+ return node == nullptr ? 0
: 1 + GPR_MAX(calculate_height(node->left),
calculate_height(node->right));
}
static gpr_avl_node* assert_invariants(gpr_avl_node* n) {
- if (n == NULL) return NULL;
+ if (n == nullptr) return nullptr;
assert_invariants(n->left);
assert_invariants(n->right);
assert(calculate_height(n) == n->height);
@@ -92,8 +92,8 @@ static gpr_avl_node* get(const gpr_avl_vtable* vtable, gpr_avl_node* node,
void* key, void* user_data) {
long cmp;
- if (node == NULL) {
- return NULL;
+ if (node == nullptr) {
+ return nullptr;
}
cmp = vtable->compare_keys(node->key, key, user_data);
@@ -108,12 +108,12 @@ static gpr_avl_node* get(const gpr_avl_vtable* vtable, gpr_avl_node* node,
void* gpr_avl_get(gpr_avl avl, void* key, void* user_data) {
gpr_avl_node* node = get(avl.vtable, avl.root, key, user_data);
- return node ? node->value : NULL;
+ return node ? node->value : nullptr;
}
int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, void* user_data) {
gpr_avl_node* node = get(avl.vtable, avl.root, key, user_data);
- if (node != NULL) {
+ if (node != nullptr) {
*value = node->value;
return 1;
}
@@ -200,8 +200,8 @@ static gpr_avl_node* rebalance(const gpr_avl_vtable* vtable, void* key,
static gpr_avl_node* add_key(const gpr_avl_vtable* vtable, gpr_avl_node* node,
void* key, void* value, void* user_data) {
long cmp;
- if (node == NULL) {
- return new_node(key, value, NULL, NULL);
+ if (node == nullptr) {
+ return new_node(key, value, nullptr, nullptr);
}
cmp = vtable->compare_keys(node->key, key, user_data);
if (cmp == 0) {
@@ -228,14 +228,14 @@ gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, void* user_data) {
}
static gpr_avl_node* in_order_head(gpr_avl_node* node) {
- while (node->left != NULL) {
+ while (node->left != nullptr) {
node = node->left;
}
return node;
}
static gpr_avl_node* in_order_tail(gpr_avl_node* node) {
- while (node->right != NULL) {
+ while (node->right != nullptr) {
node = node->right;
}
return node;
@@ -245,14 +245,14 @@ static gpr_avl_node* remove_key(const gpr_avl_vtable* vtable,
gpr_avl_node* node, void* key,
void* user_data) {
long cmp;
- if (node == NULL) {
- return NULL;
+ if (node == nullptr) {
+ return nullptr;
}
cmp = vtable->compare_keys(node->key, key, user_data);
if (cmp == 0) {
- if (node->left == NULL) {
+ if (node->left == nullptr) {
return ref_node(node->right);
- } else if (node->right == NULL) {
+ } else if (node->right == nullptr) {
return ref_node(node->left);
} else if (node->left->height < node->right->height) {
gpr_avl_node* h = in_order_head(node->right);
@@ -297,4 +297,4 @@ void gpr_avl_unref(gpr_avl avl, void* user_data) {
unref_node(avl.vtable, avl.root, user_data);
}
-int gpr_avl_is_empty(gpr_avl avl) { return avl.root == NULL; }
+int gpr_avl_is_empty(gpr_avl avl) { return avl.root == nullptr; }
diff --git a/src/core/lib/support/cmdline.cc b/src/core/lib/support/cmdline.cc
index d2785d2f30..da9f10a496 100644
--- a/src/core/lib/support/cmdline.cc
+++ b/src/core/lib/support/cmdline.cc
@@ -169,7 +169,7 @@ char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0) {
}
gpr_strvec_add(&s, gpr_strdup("\n"));
- tmp = gpr_strvec_flatten(&s, NULL);
+ tmp = gpr_strvec_flatten(&s, nullptr);
gpr_strvec_destroy(&s);
return tmp;
}
@@ -203,7 +203,7 @@ static arg* find_arg(gpr_cmdline* cl, char* name) {
if (!a) {
fprintf(stderr, "Unknown argument: %s\n", name);
- return NULL;
+ return nullptr;
}
return a;
@@ -246,9 +246,9 @@ static int value_state(gpr_cmdline* cl, char* str) {
}
static int normal_state(gpr_cmdline* cl, char* str) {
- char* eq = NULL;
- char* tmp = NULL;
- char* arg_name = NULL;
+ char* eq = nullptr;
+ char* tmp = nullptr;
+ char* arg_name = nullptr;
int r = 1;
if (0 == strcmp(str, "-help") || 0 == strcmp(str, "--help") ||
@@ -256,7 +256,7 @@ static int normal_state(gpr_cmdline* cl, char* str) {
return print_usage_and_die(cl);
}
- cl->cur_arg = NULL;
+ cl->cur_arg = nullptr;
if (str[0] == '-') {
if (str[1] == '-') {
@@ -274,7 +274,7 @@ static int normal_state(gpr_cmdline* cl, char* str) {
/* str is of the form '--no-foo' - it's a flag disable */
str += 3;
cl->cur_arg = find_arg(cl, str);
- if (cl->cur_arg == NULL) {
+ if (cl->cur_arg == nullptr) {
return print_usage_and_die(cl);
}
if (cl->cur_arg->type != ARGTYPE_BOOL) {
@@ -285,7 +285,7 @@ static int normal_state(gpr_cmdline* cl, char* str) {
return 1; /* early out */
}
eq = strchr(str, '=');
- if (eq != NULL) {
+ if (eq != nullptr) {
/* copy the string into a temp buffer and extract the name */
tmp = arg_name = (char*)gpr_malloc((size_t)(eq - str + 1));
memcpy(arg_name, str, (size_t)(eq - str));
@@ -294,10 +294,10 @@ static int normal_state(gpr_cmdline* cl, char* str) {
arg_name = str;
}
cl->cur_arg = find_arg(cl, arg_name);
- if (cl->cur_arg == NULL) {
+ if (cl->cur_arg == nullptr) {
return print_usage_and_die(cl);
}
- if (eq != NULL) {
+ if (eq != nullptr) {
/* str was of the type --foo=value, parse the value */
r = value_state(cl, eq + 1);
} else if (cl->cur_arg->type != ARGTYPE_BOOL) {
diff --git a/src/core/lib/support/env_linux.cc b/src/core/lib/support/env_linux.cc
index 012ef63eff..0af2de9f7e 100644
--- a/src/core/lib/support/env_linux.cc
+++ b/src/core/lib/support/env_linux.cc
@@ -39,8 +39,8 @@
#include "src/core/lib/support/string.h"
const char* gpr_getenv_silent(const char* name, char** dst) {
- const char* insecure_func_used = NULL;
- char* result = NULL;
+ const char* insecure_func_used = nullptr;
+ char* result = nullptr;
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
typedef char* (*getenv_type)(const char*);
static getenv_type getenv_func = NULL;
@@ -60,14 +60,14 @@ const char* gpr_getenv_silent(const char* name, char** dst) {
result = getenv(name);
insecure_func_used = "getenv";
#endif
- *dst = result == NULL ? result : gpr_strdup(result);
+ *dst = result == nullptr ? result : gpr_strdup(result);
return insecure_func_used;
}
char* gpr_getenv(const char* name) {
- char* result = NULL;
+ char* result = nullptr;
const char* insecure_func_used = gpr_getenv_silent(name, &result);
- if (insecure_func_used != NULL) {
+ if (insecure_func_used != nullptr) {
gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used",
insecure_func_used);
}
diff --git a/src/core/lib/support/host_port.cc b/src/core/lib/support/host_port.cc
index 1927d5507d..cb8e3d4479 100644
--- a/src/core/lib/support/host_port.cc
+++ b/src/core/lib/support/host_port.cc
@@ -26,7 +26,7 @@
#include "src/core/lib/support/string.h"
int gpr_join_host_port(char** out, const char* host, int port) {
- if (host[0] != '[' && strchr(host, ':') != NULL) {
+ if (host[0] != '[' && strchr(host, ':') != nullptr) {
/* IPv6 literals must be enclosed in brackets. */
return gpr_asprintf(out, "[%s]:%d", host, port);
} else {
@@ -40,19 +40,19 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
size_t host_len;
const char* port_start;
- *host = NULL;
- *port = NULL;
+ *host = nullptr;
+ *port = nullptr;
if (name[0] == '[') {
/* Parse a bracketed host, typically an IPv6 literal. */
const char* rbracket = strchr(name, ']');
- if (rbracket == NULL) {
+ if (rbracket == nullptr) {
/* Unmatched [ */
return 0;
}
if (rbracket[1] == '\0') {
/* ]<end> */
- port_start = NULL;
+ port_start = nullptr;
} else if (rbracket[1] == ':') {
/* ]:<port?> */
port_start = rbracket + 2;
@@ -62,14 +62,14 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
}
host_start = name + 1;
host_len = (size_t)(rbracket - host_start);
- if (memchr(host_start, ':', host_len) == NULL) {
+ if (memchr(host_start, ':', host_len) == nullptr) {
/* Require all bracketed hosts to contain a colon, because a hostname or
IPv4 address should never use brackets. */
return 0;
}
} else {
const char* colon = strchr(name, ':');
- if (colon != NULL && strchr(colon + 1, ':') == NULL) {
+ if (colon != nullptr && strchr(colon + 1, ':') == nullptr) {
/* Exactly 1 colon. Split into host:port. */
host_start = name;
host_len = (size_t)(colon - name);
@@ -78,7 +78,7 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
/* 0 or 2+ colons. Bare hostname or IPv6 litearal. */
host_start = name;
host_len = strlen(name);
- port_start = NULL;
+ port_start = nullptr;
}
}
@@ -87,7 +87,7 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
memcpy(*host, host_start, host_len);
(*host)[host_len] = '\0';
- if (port_start != NULL) {
+ if (port_start != nullptr) {
*port = gpr_strdup(port_start);
}
diff --git a/src/core/lib/support/log.cc b/src/core/lib/support/log.cc
index 2140e4bd69..e9adc6c349 100644
--- a/src/core/lib/support/log.cc
+++ b/src/core/lib/support/log.cc
@@ -64,11 +64,11 @@ void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) {
}
void gpr_log_verbosity_init() {
- char* verbosity = NULL;
+ char* verbosity = nullptr;
const char* insecure_getenv = gpr_getenv_silent("GRPC_VERBOSITY", &verbosity);
gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR;
- if (verbosity != NULL) {
+ if (verbosity != nullptr) {
if (gpr_stricmp(verbosity, "DEBUG") == 0) {
min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_DEBUG;
} else if (gpr_stricmp(verbosity, "INFO") == 0) {
@@ -83,7 +83,7 @@ void gpr_log_verbosity_init() {
gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print);
}
- if (insecure_getenv != NULL) {
+ if (insecure_getenv != nullptr) {
gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used",
insecure_getenv);
}
diff --git a/src/core/lib/support/log_linux.cc b/src/core/lib/support/log_linux.cc
index e9be970305..e0e277fe87 100644
--- a/src/core/lib/support/log_linux.cc
+++ b/src/core/lib/support/log_linux.cc
@@ -43,7 +43,7 @@ static long gettid(void) { return syscall(__NR_gettid); }
void gpr_log(const char* file, int line, gpr_log_severity severity,
const char* format, ...) {
- char* message = NULL;
+ char* message = nullptr;
va_list args;
va_start(args, format);
if (vasprintf(&message, format, args) == -1) {
@@ -69,7 +69,7 @@ extern "C" void gpr_default_log(gpr_log_func_args* args) {
timer = (time_t)now.tv_sec;
final_slash = strrchr(args->file, '/');
- if (final_slash == NULL)
+ if (final_slash == nullptr)
display_file = args->file;
else
display_file = final_slash + 1;
diff --git a/src/core/lib/support/mpscq.cc b/src/core/lib/support/mpscq.cc
index b270777d5c..47e896d2df 100644
--- a/src/core/lib/support/mpscq.cc
+++ b/src/core/lib/support/mpscq.cc
@@ -49,15 +49,15 @@ gpr_mpscq_node* gpr_mpscq_pop_and_check_end(gpr_mpscq* q, bool* empty) {
gpr_mpscq_node* next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next);
if (tail == &q->stub) {
// indicates the list is actually (ephemerally) empty
- if (next == NULL) {
+ if (next == nullptr) {
*empty = true;
- return NULL;
+ return nullptr;
}
q->tail = next;
tail = next;
next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next);
}
- if (next != NULL) {
+ if (next != nullptr) {
*empty = false;
q->tail = next;
return tail;
@@ -66,17 +66,17 @@ gpr_mpscq_node* gpr_mpscq_pop_and_check_end(gpr_mpscq* q, bool* empty) {
if (tail != head) {
*empty = false;
// indicates a retry is in order: we're still adding
- return NULL;
+ return nullptr;
}
gpr_mpscq_push(q, &q->stub);
next = (gpr_mpscq_node*)gpr_atm_acq_load(&tail->next);
- if (next != NULL) {
+ if (next != nullptr) {
q->tail = next;
return tail;
}
// indicates a retry is in order: we're still adding
*empty = false;
- return NULL;
+ return nullptr;
}
void gpr_locked_mpscq_init(gpr_locked_mpscq* q) {
@@ -99,7 +99,7 @@ gpr_mpscq_node* gpr_locked_mpscq_try_pop(gpr_locked_mpscq* q) {
gpr_mu_unlock(&q->mu);
return n;
}
- return NULL;
+ return nullptr;
}
gpr_mpscq_node* gpr_locked_mpscq_pop(gpr_locked_mpscq* q) {
@@ -108,7 +108,7 @@ gpr_mpscq_node* gpr_locked_mpscq_pop(gpr_locked_mpscq* q) {
gpr_mpscq_node* n;
do {
n = gpr_mpscq_pop_and_check_end(&q->queue, &empty);
- } while (n == NULL && !empty);
+ } while (n == nullptr && !empty);
gpr_mu_unlock(&q->mu);
return n;
}
diff --git a/src/core/lib/support/string.cc b/src/core/lib/support/string.cc
index 6dc4fbc921..e31ad72c68 100644
--- a/src/core/lib/support/string.cc
+++ b/src/core/lib/support/string.cc
@@ -35,7 +35,7 @@ char* gpr_strdup(const char* src) {
size_t len;
if (!src) {
- return NULL;
+ return nullptr;
}
len = strlen(src) + 1;
@@ -53,7 +53,7 @@ typedef struct {
} dump_out;
static dump_out dump_out_create(void) {
- dump_out r = {0, 0, NULL};
+ dump_out r = {0, 0, nullptr};
return r;
}
@@ -223,7 +223,7 @@ char* gpr_strjoin_sep(const char** strs, size_t nstrs, const char* sep,
out_length += slen;
}
out[out_length] = 0;
- if (final_length != NULL) {
+ if (final_length != nullptr) {
*final_length = out_length;
}
return out;
@@ -278,7 +278,7 @@ static void add_string_to_split(const char* beg, const char* end, char*** strs,
void gpr_string_split(const char* input, const char* sep, char*** strs,
size_t* nstrs) {
const char* next;
- *strs = NULL;
+ *strs = nullptr;
*nstrs = 0;
size_t capstrs = 0;
while ((next = strstr(input, sep))) {
@@ -289,7 +289,7 @@ void gpr_string_split(const char* input, const char* sep, char*** strs,
}
void* gpr_memrchr(const void* s, int c, size_t n) {
- if (s == NULL) return NULL;
+ if (s == nullptr) return nullptr;
char* b = (char*)s;
size_t i;
for (i = 0; i < n; i++) {
@@ -297,12 +297,12 @@ void* gpr_memrchr(const void* s, int c, size_t n) {
return &b[n - i - 1];
}
}
- return NULL;
+ return nullptr;
}
bool gpr_is_true(const char* s) {
size_t i;
- if (s == NULL) {
+ if (s == nullptr) {
return false;
}
static const char* truthy[] = {"yes", "true", "1"};
diff --git a/src/core/lib/support/string_posix.cc b/src/core/lib/support/string_posix.cc
index 79c81656cc..8b818e39b9 100644
--- a/src/core/lib/support/string_posix.cc
+++ b/src/core/lib/support/string_posix.cc
@@ -38,13 +38,13 @@ int gpr_asprintf(char** strp, const char* format, ...) {
ret = vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
if (ret < 0) {
- *strp = NULL;
+ *strp = nullptr;
return -1;
}
/* Allocate a new buffer, with space for the NUL terminator. */
strp_buflen = (size_t)ret + 1;
- if ((*strp = (char*)gpr_malloc(strp_buflen)) == NULL) {
+ if ((*strp = (char*)gpr_malloc(strp_buflen)) == nullptr) {
/* This shouldn't happen, because gpr_malloc() calls abort(). */
return -1;
}
@@ -65,7 +65,7 @@ int gpr_asprintf(char** strp, const char* format, ...) {
/* This should never happen. */
gpr_free(*strp);
- *strp = NULL;
+ *strp = nullptr;
return -1;
}
diff --git a/src/core/lib/support/subprocess_posix.cc b/src/core/lib/support/subprocess_posix.cc
index 4d6972a0c4..dc046b6499 100644
--- a/src/core/lib/support/subprocess_posix.cc
+++ b/src/core/lib/support/subprocess_posix.cc
@@ -50,16 +50,16 @@ gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) {
pid = fork();
if (pid == -1) {
- return NULL;
+ return nullptr;
} else if (pid == 0) {
exec_args = (char**)gpr_malloc(((size_t)argc + 1) * sizeof(char*));
memcpy(exec_args, argv, (size_t)argc * sizeof(char*));
- exec_args[argc] = NULL;
+ exec_args[argc] = nullptr;
execv(exec_args[0], exec_args);
/* if we reach here, an error has occurred */
gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], strerror(errno));
_exit(1);
- return NULL;
+ return nullptr;
} else {
r = (gpr_subprocess*)gpr_zalloc(sizeof(gpr_subprocess));
r->pid = pid;
diff --git a/src/core/lib/support/sync.cc b/src/core/lib/support/sync.cc
index 1c051a1ca4..347ffcd00e 100644
--- a/src/core/lib/support/sync.cc
+++ b/src/core/lib/support/sync.cc
@@ -61,7 +61,7 @@ void gpr_event_set(gpr_event* ev, void* value) {
gpr_atm_rel_store(&ev->state, (gpr_atm)value);
gpr_cv_broadcast(&s->cv);
gpr_mu_unlock(&s->mu);
- GPR_ASSERT(value != NULL);
+ GPR_ASSERT(value != nullptr);
}
void* gpr_event_get(gpr_event* ev) {
@@ -70,12 +70,12 @@ void* gpr_event_get(gpr_event* ev) {
void* gpr_event_wait(gpr_event* ev, gpr_timespec abs_deadline) {
void* result = (void*)gpr_atm_acq_load(&ev->state);
- if (result == NULL) {
+ if (result == nullptr) {
struct sync_array_s* s = hash(ev);
gpr_mu_lock(&s->mu);
do {
result = (void*)gpr_atm_acq_load(&ev->state);
- } while (result == NULL && !gpr_cv_wait(&s->cv, &s->mu, abs_deadline));
+ } while (result == nullptr && !gpr_cv_wait(&s->cv, &s->mu, abs_deadline));
gpr_mu_unlock(&s->mu);
}
return result;
diff --git a/src/core/lib/support/sync_posix.cc b/src/core/lib/support/sync_posix.cc
index 62d800b18c..d306d43cb4 100644
--- a/src/core/lib/support/sync_posix.cc
+++ b/src/core/lib/support/sync_posix.cc
@@ -33,7 +33,7 @@ gpr_atm gpr_counter_atm_cas = 0;
gpr_atm gpr_counter_atm_add = 0;
#endif
-void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, NULL) == 0); }
+void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, nullptr) == 0); }
void gpr_mu_destroy(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_destroy(mu) == 0); }
@@ -63,7 +63,7 @@ int gpr_mu_trylock(gpr_mu* mu) {
/*----------------------------------------*/
-void gpr_cv_init(gpr_cv* cv) { GPR_ASSERT(pthread_cond_init(cv, NULL) == 0); }
+void gpr_cv_init(gpr_cv* cv) { GPR_ASSERT(pthread_cond_init(cv, nullptr) == 0); }
void gpr_cv_destroy(gpr_cv* cv) { GPR_ASSERT(pthread_cond_destroy(cv) == 0); }
diff --git a/src/core/lib/support/thd_posix.cc b/src/core/lib/support/thd_posix.cc
index 297714e659..02e3846be1 100644
--- a/src/core/lib/support/thd_posix.cc
+++ b/src/core/lib/support/thd_posix.cc
@@ -40,7 +40,7 @@ static void* thread_body(void* v) {
struct thd_arg a = *(struct thd_arg*)v;
free(v);
(*a.body)(a.arg);
- return NULL;
+ return nullptr;
}
int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg,
@@ -51,7 +51,7 @@ int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg,
/* don't use gpr_malloc as we may cause an infinite recursion with
* the profiling code */
struct thd_arg* a = (struct thd_arg*)malloc(sizeof(*a));
- GPR_ASSERT(a != NULL);
+ GPR_ASSERT(a != nullptr);
a->body = thd_body;
a->arg = arg;
@@ -75,6 +75,6 @@ int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg,
gpr_thd_id gpr_thd_currentid(void) { return (gpr_thd_id)pthread_self(); }
-void gpr_thd_join(gpr_thd_id t) { pthread_join((pthread_t)t, NULL); }
+void gpr_thd_join(gpr_thd_id t) { pthread_join((pthread_t)t, nullptr); }
#endif /* GPR_POSIX_SYNC */
diff --git a/src/core/lib/support/time_posix.cc b/src/core/lib/support/time_posix.cc
index 3674ef7184..7f65205800 100644
--- a/src/core/lib/support/time_posix.cc
+++ b/src/core/lib/support/time_posix.cc
@@ -158,7 +158,7 @@ void gpr_sleep_until(gpr_timespec until) {
delta = gpr_time_sub(until, now);
delta_ts = timespec_from_gpr(delta);
- ns_result = nanosleep(&delta_ts, NULL);
+ ns_result = nanosleep(&delta_ts, nullptr);
if (ns_result == 0) {
break;
}
diff --git a/src/core/lib/support/tmpfile_posix.cc b/src/core/lib/support/tmpfile_posix.cc
index 2e14d28598..79c5c68874 100644
--- a/src/core/lib/support/tmpfile_posix.cc
+++ b/src/core/lib/support/tmpfile_posix.cc
@@ -34,14 +34,14 @@
#include "src/core/lib/support/string.h"
FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
- FILE* result = NULL;
+ FILE* result = nullptr;
char* filename_template;
int fd;
- if (tmp_filename != NULL) *tmp_filename = NULL;
+ if (tmp_filename != nullptr) *tmp_filename = nullptr;
gpr_asprintf(&filename_template, "/tmp/%s_XXXXXX", prefix);
- GPR_ASSERT(filename_template != NULL);
+ GPR_ASSERT(filename_template != nullptr);
fd = mkstemp(filename_template);
if (fd == -1) {
@@ -50,7 +50,7 @@ FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
goto end;
}
result = fdopen(fd, "w+");
- if (result == NULL) {
+ if (result == nullptr) {
gpr_log(GPR_ERROR, "Could not open file %s from fd %d (error = %s).",
filename_template, fd, strerror(errno));
unlink(filename_template);
@@ -59,7 +59,7 @@ FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
}
end:
- if (result != NULL && tmp_filename != NULL) {
+ if (result != nullptr && tmp_filename != nullptr) {
*tmp_filename = filename_template;
} else {
gpr_free(filename_template);