From b5a8aaba0ae78e93f8a972c9c7911fc2bc664b4e Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 5 Jun 2018 20:33:08 +0200 Subject: [PATCH] Code reformatting. --- src/conf.c | 4 ++-- src/meshlink++.h | 39 ++++++++++++++++++++++++++++++++------- src/net_setup.c | 6 +++++- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/conf.c b/src/conf.c index 771abe58..5d5c46c1 100644 --- a/src/conf.c +++ b/src/conf.c @@ -431,12 +431,12 @@ bool modify_config_file(struct meshlink_handle *mesh, const char *name, const ch char tmpname[PATH_MAX]; bool error = false; - if (snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name) >= PATH_MAX) { + if(snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name) >= PATH_MAX) { logger(mesh, MESHLINK_ERROR, "Filename too long: %s" SLASH "hosts" SLASH "%s", mesh->confbase, name); return false; } - if (snprintf(tmpname, sizeof(tmpname), "%s.tmp", filename) >= PATH_MAX) { + if(snprintf(tmpname, sizeof(tmpname), "%s.tmp", filename) >= PATH_MAX) { logger(mesh, MESHLINK_ERROR, "Filename too long: %s.tmp", filename); return false; } diff --git a/src/meshlink++.h b/src/meshlink++.h index b09ad75b..83eafdfa 100644 --- a/src/meshlink++.h +++ b/src/meshlink++.h @@ -174,13 +174,26 @@ public: */ /// This function is called whenever another node sends data to the local node. - virtual void receive(node *source, const void *data, size_t length) { /* do nothing */ (void)source; (void)data; (void) length; } + virtual void receive(node *source, const void *data, size_t length) { + /* do nothing */ + (void)source; + (void)data; + (void) length; + } /// This functions is called whenever another node's status changed. - virtual void node_status(node *peer, bool reachable) { /* do nothing */ (void)peer; (void)reachable; } + virtual void node_status(node *peer, bool reachable) { + /* do nothing */ + (void)peer; + (void)reachable; + } /// This functions is called whenever MeshLink has some information to log. - virtual void log(log_level_t level, const char *message) { /* do nothing */ (void)level; (void)message; } + virtual void log(log_level_t level, const char *message) { + /* do nothing */ + (void)level; + (void)message; + } /// This functions is called whenever another node attemps to open a channel to the local node. /** @@ -203,7 +216,10 @@ public: */ virtual bool channel_accept(channel *channel, uint16_t port, const void *data, size_t len) { /* by default reject all channels */ - (void)channel; (void)port; (void)data; (void)len; + (void)channel; + (void)port; + (void)data; + (void)len; return false; } @@ -218,7 +234,12 @@ public: * @param data A pointer to a buffer containing data sent by the source. * @param len The length of the data. */ - virtual void channel_receive(channel *channel, const void *data, size_t len) { /* do nothing */ (void)channel; (void)data; (void)len; } + virtual void channel_receive(channel *channel, const void *data, size_t len) { + /* do nothing */ + (void)channel; + (void)data; + (void)len; + } /// This function is called by Meshlink when data can be send on a channel. /** @@ -230,7 +251,11 @@ public: * @param channel A handle for the channel. * @param len The maximum length of data that is guaranteed to be accepted by a call to channel_send(). */ - virtual void channel_poll(channel *channel, size_t len) { /* do nothing */ (void)channel; (void)len; } + virtual void channel_poll(channel *channel, size_t len) { + /* do nothing */ + (void)channel; + (void)len; + } /// Start MeshLink. /** This function causes MeshLink to open network sockets, make outgoing connections, and @@ -578,7 +603,7 @@ public: private: // non-copyable: mesh(const mesh &) /* TODO: C++11: = delete */; - void operator=(const mesh &) /* TODO: C++11: = delete */ ; + void operator=(const mesh &) /* TODO: C++11: = delete */; /// static callback trampolines: static void receive_trampoline(meshlink_handle_t *handle, meshlink_node_t *source, const void *data, size_t length) { diff --git a/src/net_setup.c b/src/net_setup.c index f2621f3b..10fb37b0 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -274,6 +274,7 @@ static bool add_listen_address(meshlink_handle_t *mesh, char *address, bool bind } struct addrinfo *ai; + struct addrinfo hint = { .ai_family = addressfamily, .ai_socktype = SOCK_STREAM, @@ -364,8 +365,11 @@ bool setup_myself(meshlink_handle_t *mesh) { if(!get_config_string(lookup_config(mesh->config, "Port"), &mesh->myport)) { int port = check_port(mesh); - if (port == 0) + + if(port == 0) { return false; + } + xasprintf(&mesh->myport, "%d", port); } -- 2.39.2