diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-28 21:30:39 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-30 23:35:50 +0000 |
commit | 92ffad1a72bc8c422426d52ac408bd71242dd047 (patch) | |
tree | f592f353068dd2043525dd2cc04d6124a4ed4bc4 /other/bootstrap_daemon/src | |
parent | 623e9ac331df7323660e21c8a2226523a5ee713b (diff) |
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
Diffstat (limited to 'other/bootstrap_daemon/src')
-rw-r--r-- | other/bootstrap_daemon/src/command_line_arguments.c | 4 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/config.c | 14 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/log_backend_syslog.c | 2 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/tox-bootstrapd.c | 22 |
4 files changed, 22 insertions, 20 deletions
diff --git a/other/bootstrap_daemon/src/command_line_arguments.c b/other/bootstrap_daemon/src/command_line_arguments.c index dce828a7..d9747932 100644 --- a/other/bootstrap_daemon/src/command_line_arguments.c +++ b/other/bootstrap_daemon/src/command_line_arguments.c | |||
@@ -26,6 +26,8 @@ | |||
26 | 26 | ||
27 | #include "global.h" | 27 | #include "global.h" |
28 | 28 | ||
29 | #include "../../../toxcore/ccompat.h" | ||
30 | |||
29 | #include <getopt.h> | 31 | #include <getopt.h> |
30 | 32 | ||
31 | #include <stdlib.h> | 33 | #include <stdlib.h> |
@@ -87,7 +89,7 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, | |||
87 | 89 | ||
88 | int opt; | 90 | int opt; |
89 | 91 | ||
90 | while ((opt = getopt_long(argc, argv, ":", long_options, NULL)) != -1) { | 92 | while ((opt = getopt_long(argc, argv, ":", long_options, nullptr)) != -1) { |
91 | 93 | ||
92 | switch (opt) { | 94 | switch (opt) { |
93 | 95 | ||
diff --git a/other/bootstrap_daemon/src/config.c b/other/bootstrap_daemon/src/config.c index 64fc4d94..3f1592e6 100644 --- a/other/bootstrap_daemon/src/config.c +++ b/other/bootstrap_daemon/src/config.c | |||
@@ -49,7 +49,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por | |||
49 | 49 | ||
50 | config_setting_t *ports_array = config_lookup(cfg, NAME_TCP_RELAY_PORTS); | 50 | config_setting_t *ports_array = config_lookup(cfg, NAME_TCP_RELAY_PORTS); |
51 | 51 | ||
52 | if (ports_array == NULL) { | 52 | if (ports_array == nullptr) { |
53 | log_write(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file.\n", NAME_TCP_RELAY_PORTS); | 53 | log_write(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file.\n", NAME_TCP_RELAY_PORTS); |
54 | log_write(LOG_LEVEL_WARNING, "Using default '%s':\n", NAME_TCP_RELAY_PORTS); | 54 | log_write(LOG_LEVEL_WARNING, "Using default '%s':\n", NAME_TCP_RELAY_PORTS); |
55 | 55 | ||
@@ -83,7 +83,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por | |||
83 | *tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); | 83 | *tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); |
84 | } else { | 84 | } else { |
85 | free(*tcp_relay_ports); | 85 | free(*tcp_relay_ports); |
86 | *tcp_relay_ports = NULL; | 86 | *tcp_relay_ports = nullptr; |
87 | } | 87 | } |
88 | 88 | ||
89 | return; | 89 | return; |
@@ -109,7 +109,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por | |||
109 | for (i = 0; i < config_port_count; i ++) { | 109 | for (i = 0; i < config_port_count; i ++) { |
110 | config_setting_t *elem = config_setting_get_elem(ports_array, i); | 110 | config_setting_t *elem = config_setting_get_elem(ports_array, i); |
111 | 111 | ||
112 | if (elem == NULL) { | 112 | if (elem == nullptr) { |
113 | // it's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be | 113 | // it's NULL if `ports_array` is not an array (we have that check earlier) or if `i` is out of range, which should not be |
114 | log_write(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i); | 114 | log_write(LOG_LEVEL_WARNING, "Port #%d: Something went wrong while parsing the port. Stopping reading ports.\n", i); |
115 | break; | 115 | break; |
@@ -137,7 +137,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por | |||
137 | *tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); | 137 | *tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); |
138 | } else { | 138 | } else { |
139 | free(*tcp_relay_ports); | 139 | free(*tcp_relay_ports); |
140 | *tcp_relay_ports = NULL; | 140 | *tcp_relay_ports = nullptr; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
@@ -306,7 +306,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k | |||
306 | static uint8_t *hex_string_to_bin(const char *hex_string) | 306 | static uint8_t *hex_string_to_bin(const char *hex_string) |
307 | { | 307 | { |
308 | if (strlen(hex_string) % 2 != 0) { | 308 | if (strlen(hex_string) % 2 != 0) { |
309 | return NULL; | 309 | return nullptr; |
310 | } | 310 | } |
311 | 311 | ||
312 | size_t len = strlen(hex_string) / 2; | 312 | size_t len = strlen(hex_string) / 2; |
@@ -342,7 +342,7 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6) | |||
342 | 342 | ||
343 | config_setting_t *node_list = config_lookup(&cfg, NAME_BOOTSTRAP_NODES); | 343 | config_setting_t *node_list = config_lookup(&cfg, NAME_BOOTSTRAP_NODES); |
344 | 344 | ||
345 | if (node_list == NULL) { | 345 | if (node_list == nullptr) { |
346 | log_write(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file. Skipping bootstrapping.\n", | 346 | log_write(LOG_LEVEL_WARNING, "No '%s' setting in the configuration file. Skipping bootstrapping.\n", |
347 | NAME_BOOTSTRAP_NODES); | 347 | NAME_BOOTSTRAP_NODES); |
348 | config_destroy(&cfg); | 348 | config_destroy(&cfg); |
@@ -369,7 +369,7 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6) | |||
369 | 369 | ||
370 | node = config_setting_get_elem(node_list, 0); | 370 | node = config_setting_get_elem(node_list, 0); |
371 | 371 | ||
372 | if (node == NULL) { | 372 | if (node == nullptr) { |
373 | config_destroy(&cfg); | 373 | config_destroy(&cfg); |
374 | return 0; | 374 | return 0; |
375 | } | 375 | } |
diff --git a/other/bootstrap_daemon/src/log_backend_syslog.c b/other/bootstrap_daemon/src/log_backend_syslog.c index 88911a21..9fc6d18f 100644 --- a/other/bootstrap_daemon/src/log_backend_syslog.c +++ b/other/bootstrap_daemon/src/log_backend_syslog.c | |||
@@ -63,7 +63,7 @@ void log_backend_syslog_write(LOG_LEVEL level, const char *format, va_list args) | |||
63 | va_list args2; | 63 | va_list args2; |
64 | 64 | ||
65 | va_copy(args2, args); | 65 | va_copy(args2, args); |
66 | int size = vsnprintf(NULL, 0, format, args2); | 66 | int size = vsnprintf(nullptr, 0, format, args2); |
67 | va_end(args2); | 67 | va_end(args2); |
68 | 68 | ||
69 | assert(size >= 0); | 69 | assert(size >= 0); |
diff --git a/other/bootstrap_daemon/src/tox-bootstrapd.c b/other/bootstrap_daemon/src/tox-bootstrapd.c index e0472cba..bdf679c9 100644 --- a/other/bootstrap_daemon/src/tox-bootstrapd.c +++ b/other/bootstrap_daemon/src/tox-bootstrapd.c | |||
@@ -65,7 +65,7 @@ static int manage_keys(DHT *dht, char *keys_file_path) | |||
65 | // Check if file exits, proceed to open and load keys | 65 | // Check if file exits, proceed to open and load keys |
66 | keys_file = fopen(keys_file_path, "r"); | 66 | keys_file = fopen(keys_file_path, "r"); |
67 | 67 | ||
68 | if (keys_file != NULL) { | 68 | if (keys_file != nullptr) { |
69 | const size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keys_file); | 69 | const size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keys_file); |
70 | 70 | ||
71 | if (read_size != KEYS_SIZE) { | 71 | if (read_size != KEYS_SIZE) { |
@@ -131,7 +131,7 @@ static void daemonize(LOG_BACKEND log_backend, char *pid_file_path) | |||
131 | // Open the PID file for writing | 131 | // Open the PID file for writing |
132 | pid_file = fopen(pid_file_path, "a+"); | 132 | pid_file = fopen(pid_file_path, "a+"); |
133 | 133 | ||
134 | if (pid_file == NULL) { | 134 | if (pid_file == nullptr) { |
135 | log_write(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path); | 135 | log_write(LOG_LEVEL_ERROR, "Couldn't open the PID file for writing: %s. Exiting.\n", pid_file_path); |
136 | exit(1); | 136 | exit(1); |
137 | } | 137 | } |
@@ -226,16 +226,16 @@ int main(int argc, char *argv[]) | |||
226 | IP ip; | 226 | IP ip; |
227 | ip_init(&ip, enable_ipv6); | 227 | ip_init(&ip, enable_ipv6); |
228 | 228 | ||
229 | Networking_Core *net = new_networking(NULL, ip, port); | 229 | Networking_Core *net = new_networking(nullptr, ip, port); |
230 | 230 | ||
231 | if (net == NULL) { | 231 | if (net == nullptr) { |
232 | if (enable_ipv6 && enable_ipv4_fallback) { | 232 | if (enable_ipv6 && enable_ipv4_fallback) { |
233 | log_write(LOG_LEVEL_WARNING, "Couldn't initialize IPv6 networking. Falling back to using IPv4.\n"); | 233 | log_write(LOG_LEVEL_WARNING, "Couldn't initialize IPv6 networking. Falling back to using IPv4.\n"); |
234 | enable_ipv6 = 0; | 234 | enable_ipv6 = 0; |
235 | ip_init(&ip, enable_ipv6); | 235 | ip_init(&ip, enable_ipv6); |
236 | net = new_networking(NULL, ip, port); | 236 | net = new_networking(nullptr, ip, port); |
237 | 237 | ||
238 | if (net == NULL) { | 238 | if (net == nullptr) { |
239 | log_write(LOG_LEVEL_ERROR, "Couldn't fallback to IPv4. Exiting.\n"); | 239 | log_write(LOG_LEVEL_ERROR, "Couldn't fallback to IPv4. Exiting.\n"); |
240 | return 1; | 240 | return 1; |
241 | } | 241 | } |
@@ -245,9 +245,9 @@ int main(int argc, char *argv[]) | |||
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | DHT *dht = new_DHT(NULL, net, true); | 248 | DHT *dht = new_DHT(nullptr, net, true); |
249 | 249 | ||
250 | if (dht == NULL) { | 250 | if (dht == nullptr) { |
251 | log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox DHT instance. Exiting.\n"); | 251 | log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox DHT instance. Exiting.\n"); |
252 | return 1; | 252 | return 1; |
253 | } | 253 | } |
@@ -280,7 +280,7 @@ int main(int argc, char *argv[]) | |||
280 | 280 | ||
281 | free(keys_file_path); | 281 | free(keys_file_path); |
282 | 282 | ||
283 | TCP_Server *tcp_server = NULL; | 283 | TCP_Server *tcp_server = nullptr; |
284 | 284 | ||
285 | if (enable_tcp_relay) { | 285 | if (enable_tcp_relay) { |
286 | if (tcp_relay_port_count == 0) { | 286 | if (tcp_relay_port_count == 0) { |
@@ -293,7 +293,7 @@ int main(int argc, char *argv[]) | |||
293 | // tcp_relay_port_count != 0 at this point | 293 | // tcp_relay_port_count != 0 at this point |
294 | free(tcp_relay_ports); | 294 | free(tcp_relay_ports); |
295 | 295 | ||
296 | if (tcp_server != NULL) { | 296 | if (tcp_server != nullptr) { |
297 | log_write(LOG_LEVEL_INFO, "Initialized Tox TCP server successfully.\n"); | 297 | log_write(LOG_LEVEL_INFO, "Initialized Tox TCP server successfully.\n"); |
298 | } else { | 298 | } else { |
299 | log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox TCP server. Exiting.\n"); | 299 | log_write(LOG_LEVEL_ERROR, "Couldn't initialize Tox TCP server. Exiting.\n"); |
@@ -332,7 +332,7 @@ int main(int argc, char *argv[]) | |||
332 | do_TCP_server(tcp_server); | 332 | do_TCP_server(tcp_server); |
333 | } | 333 | } |
334 | 334 | ||
335 | networking_poll(dht_get_net(dht), NULL); | 335 | networking_poll(dht_get_net(dht), nullptr); |
336 | 336 | ||
337 | if (waiting_for_dht_connection && DHT_isconnected(dht)) { | 337 | if (waiting_for_dht_connection && DHT_isconnected(dht)) { |
338 | log_write(LOG_LEVEL_INFO, "Connected to another bootstrap node successfully.\n"); | 338 | log_write(LOG_LEVEL_INFO, "Connected to another bootstrap node successfully.\n"); |