summaryrefslogtreecommitdiff
path: root/other/bootstrap_daemon/src/config.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-09-05 16:10:48 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-09-06 11:54:37 +0100
commitad2656051697899e960694bb68ac104fcc5e92f1 (patch)
tree7e69fcd03db88b3839ee523f5d1b51ef9a38c372 /other/bootstrap_daemon/src/config.c
parent4e6c86d1cb228308678f89ff6e4e09b3f46347aa (diff)
Improve static and const correctness.
- Any non-externally-visible declarations should be `static`. - Casting away the `const` qualifier from pointers-to-const is dangerous. All but one instance of this are now correct. The one instance where we can't keep `const` is one where toxav code actually writes to a chunk of memory marked as `const`. This code also assumes 4 byte alignment of data packets. I don't know whether that is a valid assumption, but it's likely unportable, and *not* obviously correct. - Replaced empty parameter lists with `(void)` to avoid passing parameters to it. Empty parameter lists are old style declarations for unknown number and type of arguments. - Commented out (as `#if DHT_HARDENING` block) the hardening code that was never executed. - Minor style fix: don't use `default` in enum-switches unless the number of enumerators in the default case is very large. In this case, it was 2, so we want to list them both explicitly to be warned about missing one if we add one in the future. - Removed the only two function declarations from nTox.h and put them into nTox.c. They are not used outside and nTox is not a library.
Diffstat (limited to 'other/bootstrap_daemon/src/config.c')
-rw-r--r--other/bootstrap_daemon/src/config.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/other/bootstrap_daemon/src/config.c b/other/bootstrap_daemon/src/config.c
index dc0a251c..a0c6045d 100644
--- a/other/bootstrap_daemon/src/config.c
+++ b/other/bootstrap_daemon/src/config.c
@@ -41,7 +41,7 @@
41 * 41 *
42 * Important: iff `tcp_relay_port_count` > 0, then you are responsible for freeing `tcp_relay_ports`. 42 * Important: iff `tcp_relay_port_count` > 0, then you are responsible for freeing `tcp_relay_ports`.
43 */ 43 */
44void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int *tcp_relay_port_count) 44static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int *tcp_relay_port_count)
45{ 45{
46 const char *NAME_TCP_RELAY_PORTS = "tcp_relay_ports"; 46 const char *NAME_TCP_RELAY_PORTS = "tcp_relay_ports";
47 47
@@ -303,7 +303,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
303 * @return binary on success, 303 * @return binary on success,
304 * NULL on failure. 304 * NULL on failure.
305 */ 305 */
306uint8_t *hex_string_to_bin(char *hex_string) 306static 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 NULL;
@@ -312,7 +312,7 @@ uint8_t *hex_string_to_bin(char *hex_string)
312 size_t len = strlen(hex_string) / 2; 312 size_t len = strlen(hex_string) / 2;
313 uint8_t *ret = malloc(len); 313 uint8_t *ret = malloc(len);
314 314
315 char *pos = hex_string; 315 const char *pos = hex_string;
316 size_t i; 316 size_t i;
317 317
318 for (i = 0; i < len; ++i, pos += 2) { 318 for (i = 0; i < len; ++i, pos += 2) {
@@ -403,7 +403,7 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
403 goto next; 403 goto next;
404 } 404 }
405 405
406 uint8_t *bs_public_key_bin = hex_string_to_bin((char *)bs_public_key); 406 uint8_t *bs_public_key_bin = hex_string_to_bin((const char *)bs_public_key);
407 const int address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, htons(bs_port), 407 const int address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, htons(bs_port),
408 bs_public_key_bin); 408 bs_public_key_bin);
409 free(bs_public_key_bin); 409 free(bs_public_key_bin);