From d2a254286665d588e7b6d35e6ee7aeb80b0840d5 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 8 Apr 2019 08:59:08 +0200 Subject: [PATCH] refactor: NULL => nullptr --- lib/node.cpp | 20 ++++++++++---------- lib/node_direction.cpp | 8 ++++---- lib/node_type.cpp | 2 +- lib/path.cpp | 36 ++++++++++++++++++------------------ lib/path_source.cpp | 2 +- lib/plugin.cpp | 2 +- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/node.cpp b/lib/node.cpp index 5bcd28463..1a7e5cd32 100644 --- a/lib/node.cpp +++ b/lib/node.cpp @@ -50,10 +50,10 @@ int node_init(struct node *n, struct node_type *vt) n->_vt = vt; n->_vd = alloc(vt->size); - n->stats = NULL; - n->name = NULL; - n->_name = NULL; - n->_name_long = NULL; + n->stats = nullptr; + n->name = nullptr; + n->_name = nullptr; + n->_name_long = nullptr; n->enabled = 1; #ifdef __linux__ @@ -61,8 +61,8 @@ int node_init(struct node *n, struct node_type *vt) #endif /* __linux__ */ #ifdef WITH_NETEM - n->tc_qdisc = NULL; - n->tc_classifier = NULL; + n->tc_qdisc = nullptr; + n->tc_classifier = nullptr; #endif /* WITH_NETEM */ /* Default values */ @@ -114,7 +114,7 @@ int node_parse(struct node *n, json_t *json, const char *name) int ret; json_error_t err; - json_t *json_netem = NULL; + json_t *json_netem = nullptr; const char *type; @@ -153,7 +153,7 @@ int node_parse(struct node *n, json_t *json, const char *name) if (enabled) tc_netem_parse(&n->tc_qdisc, json_netem); else - n->tc_qdisc = NULL; + n->tc_qdisc = nullptr; #endif /* WITH_NETEM */ } @@ -423,7 +423,7 @@ int node_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *rel int rread = hook_list_process(&n->in.hooks, smps, nread); int skipped = nread - rread; - if (skipped > 0 && n->stats != NULL) { + if (skipped > 0 && n->stats != nullptr) { stats_update(n->stats, STATS_METRIC_SMPS_SKIPPED, skipped); } @@ -547,7 +547,7 @@ int node_list_parse(struct vlist *list, json_t *cfg, struct vlist *all) { struct node *node; const char *str; - char *allstr = NULL; + char *allstr = nullptr; size_t index; json_t *elm; diff --git a/lib/node_direction.cpp b/lib/node_direction.cpp index 6aac8122a..11707ad7c 100644 --- a/lib/node_direction.cpp +++ b/lib/node_direction.cpp @@ -37,7 +37,7 @@ int node_direction_prepare(struct node_direction *nd, struct node *n) int t = nd->direction == NODE_DIR_OUT ? HOOK_NODE_WRITE : HOOK_NODE_READ; int m = nd->builtin ? t | HOOK_BUILTIN : 0; - ret = hook_list_prepare(&nd->hooks, &nd->signals, m, NULL, n); + ret = hook_list_prepare(&nd->hooks, &nd->signals, m, nullptr, n); if (ret) return ret; #endif /* WITH_HOOKS */ @@ -104,8 +104,8 @@ int node_direction_parse(struct node_direction *nd, struct node *n, json_t *cfg) assert(nd->state == STATE_INITIALIZED); json_error_t err; - json_t *json_hooks = NULL; - json_t *json_signals = NULL; + json_t *json_hooks = nullptr; + json_t *json_signals = nullptr; nd->cfg = cfg; @@ -159,7 +159,7 @@ int node_direction_parse(struct node_direction *nd, struct node *n, json_t *cfg) if (json_hooks) { int m = nd->direction == NODE_DIR_OUT ? HOOK_NODE_WRITE : HOOK_NODE_READ; - ret = hook_list_parse(&nd->hooks, json_hooks, m, NULL, n); + ret = hook_list_parse(&nd->hooks, json_hooks, m, nullptr, n); if (ret < 0) return ret; } diff --git a/lib/node_type.cpp b/lib/node_type.cpp index cabc37329..8518e536b 100644 --- a/lib/node_type.cpp +++ b/lib/node_type.cpp @@ -71,7 +71,7 @@ struct node_type * node_type_lookup(const char *name) p = plugin_lookup(PLUGIN_TYPE_NODE, name); if (!p) - return NULL; + return nullptr; return &p->node; } diff --git a/lib/path.cpp b/lib/path.cpp index e00f10545..6004eec74 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -65,7 +65,7 @@ static void * path_run_single(void *arg) } } - return NULL; + return nullptr; } /** Main thread function per path: read samples -> write samples */ @@ -106,7 +106,7 @@ static void * path_run_poll(void *arg) } } - return NULL; + return nullptr; } int path_init(struct path *p) @@ -138,7 +138,7 @@ int path_init(struct path *p) return ret; #endif /* WITH_HOOKS */ - p->_name = NULL; + p->_name = nullptr; /* Default values */ p->mode = PATH_MODE_ANY; @@ -160,7 +160,7 @@ static int path_prepare_poll(struct path *p) { int fds[16], ret, n = 0, m; - p->reader.pfds = NULL; + p->reader.pfds = nullptr; p->reader.nfds = 0; for (unsigned i = 0; i < vlist_length(&p->sources); i++) { @@ -271,7 +271,7 @@ int path_prepare(struct path *p) return -1; } - vlist_extend(&p->signals, me->offset + j + 1, NULL); + vlist_extend(&p->signals, me->offset + j + 1, nullptr); vlist_set(&p->signals, me->offset + j, sig); } } @@ -281,7 +281,7 @@ int path_prepare(struct path *p) int m = p->builtin ? HOOK_PATH | HOOK_BUILTIN : 0; /* Add internal hooks if they are not already in the list */ - ret = hook_list_prepare(&p->hooks, &p->signals, m, p, NULL); + ret = hook_list_prepare(&p->hooks, &p->signals, m, p, nullptr); if (ret) return ret; #endif /* WITH_HOOKS */ @@ -312,11 +312,11 @@ int path_parse(struct path *p, json_t *cfg, struct vlist *nodes) json_error_t err; json_t *json_in; - json_t *json_out = NULL; - json_t *json_hooks = NULL; - json_t *json_mask = NULL; + json_t *json_out = nullptr; + json_t *json_hooks = nullptr; + json_t *json_mask = nullptr; - const char *mode = NULL; + const char *mode = nullptr; struct vlist sources = { .state = STATE_DESTROYED }; struct vlist destinations = { .state = STATE_DESTROYED }; @@ -369,7 +369,7 @@ int path_parse(struct path *p, json_t *cfg, struct vlist *nodes) for (size_t i = 0; i < vlist_length(&sources); i++) { struct mapping_entry *me = (struct mapping_entry *) vlist_at(&sources, i); - struct path_source *ps = NULL; + struct path_source *ps = nullptr; /* Check if there is already a path_source for this source */ for (size_t j = 0; j < vlist_length(&p->sources); j++) { @@ -430,7 +430,7 @@ int path_parse(struct path *p, json_t *cfg, struct vlist *nodes) json_array_foreach(json_mask, i, json_entry) { const char *name; struct node *node; - struct path_source *ps = NULL; + struct path_source *ps = nullptr; name = json_string_value(json_entry); if (!name) { @@ -473,7 +473,7 @@ int path_parse(struct path *p, json_t *cfg, struct vlist *nodes) #ifdef WITH_HOOKS if (json_hooks) { - ret = hook_list_parse(&p->hooks, json_hooks, HOOK_PATH, p, NULL); + ret = hook_list_parse(&p->hooks, json_hooks, HOOK_PATH, p, nullptr); if (ret) return ret; } @@ -489,11 +489,11 @@ int path_parse(struct path *p, json_t *cfg, struct vlist *nodes) p->poll = 0; } - ret = vlist_destroy(&sources, NULL, false); + ret = vlist_destroy(&sources, nullptr, false); if (ret) return ret; - ret = vlist_destroy(&destinations, NULL, false); + ret = vlist_destroy(&destinations, nullptr, false); if (ret) return ret; @@ -638,7 +638,7 @@ int path_start(struct path *p) * does not offer a file descriptor for polling, we will use a special * thread function. */ - ret = pthread_create(&p->tid, NULL, p->poll ? path_run_poll : path_run_single, p); + ret = pthread_create(&p->tid, nullptr, p->poll ? path_run_poll : path_run_single, p); if (ret) return ret; @@ -667,7 +667,7 @@ int path_stop(struct path *p) if (ret && ret != ESRCH) return ret; - ret = pthread_join(p->tid, NULL); + ret = pthread_join(p->tid, nullptr); if (ret) return ret; @@ -780,7 +780,7 @@ int path_uses_node(struct path *p, struct node *n) bool path_is_simple(const struct path *p) { int ret; - const char *in = NULL, *out = NULL; + const char *in = nullptr, *out = nullptr; json_error_t err; ret = json_unpack_ex(p->cfg, &err, 0, "{ s: s, s: s }", "in", &in, "out", &out); diff --git a/lib/path_source.cpp b/lib/path_source.cpp index e31fe4721..2279b0d11 100644 --- a/lib/path_source.cpp +++ b/lib/path_source.cpp @@ -52,7 +52,7 @@ int path_source_destroy(struct path_source *ps) if (ret) return ret; - ret = vlist_destroy(&ps->mappings, NULL, true); + ret = vlist_destroy(&ps->mappings, nullptr, true); if (ret) return ret; diff --git a/lib/plugin.cpp b/lib/plugin.cpp index 2a3da5101..6ddbaf6c3 100644 --- a/lib/plugin.cpp +++ b/lib/plugin.cpp @@ -39,7 +39,7 @@ struct plugin * plugin_lookup(enum plugin_type type, const char *name) return p; } - return NULL; + return nullptr; } void plugin_dump(enum plugin_type type)