From: Guus Sliepen Date: Mon, 14 Aug 2017 20:31:31 +0000 (+0200) Subject: Fix compiler warnings. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=78d7a5e98ff6569ef977bc4c72bd965b706b6e7c;p=meshlink Fix compiler warnings. --- diff --git a/examples/manynodes.c b/examples/manynodes.c index bdc99bcf..a0781ba6 100644 --- a/examples/manynodes.c +++ b/examples/manynodes.c @@ -382,7 +382,6 @@ int main(int argc, char *argv[]) { for(int i = 0; i < n; i++) { snprintf(nodename, sizeof(nodename), "%snode%d", namesprefix, i); snprintf(filename, sizeof(filename), "%s/%s", basebase, nodename); - bool itsnew = access(filename, R_OK); if(n / (i + 1) > n / 4) mesh[i] = meshlink_open(filename, nodename, "manynodes", DEV_CLASS_BACKBONE); else diff --git a/src/devtools.c b/src/devtools.c index 7068c726..ca59ad9b 100644 --- a/src/devtools.c +++ b/src/devtools.c @@ -10,16 +10,6 @@ #include "devtools.h" -static int node_compare(const void *a, const void *b) { - if(a < b) - return -1; - - if(a > b) - return 1; - - return 0; -} - static bool fstrwrite(const char *str, FILE *stream) { size_t len = strlen(str); diff --git a/src/discovery.c b/src/discovery.c index 8248e9e7..0ef1001d 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -389,6 +389,7 @@ static void discovery_log_cb(CattaLogLevel level, const char *txt) { break; case CATTA_LOG_DEBUG: + default: mlevel = MESHLINK_DEBUG; break; } diff --git a/src/meshlink++.h b/src/meshlink++.h index a949f761..bfc7173d 100644 --- a/src/meshlink++.h +++ b/src/meshlink++.h @@ -624,7 +624,7 @@ private: meshlink_handle_t *handle; }; -static const char *strerror(errno_t err = meshlink_errno) { +static inline const char *strerror(errno_t err = meshlink_errno) { return meshlink_strerror(err); } @@ -638,7 +638,7 @@ static const char *strerror(errno_t err = meshlink_errno) { * * @return This function will return true if the MeshLink instance was succesfully destroyed, false otherwise. */ -static bool destroy(const char *confbase) { +static inline bool destroy(const char *confbase) { return meshlink_destroy(confbase); } } diff --git a/src/meshlink.c b/src/meshlink.c index 5d75e068..f038043f 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1208,8 +1208,8 @@ bool meshlink_send(meshlink_handle_t *mesh, meshlink_node_t *destination, const memset(hdr, 0, sizeof(*hdr)); // leave the last byte as 0 to make sure strings are always // null-terminated if they are longer than the buffer - strncpy(hdr->destination, destination->name, (sizeof(hdr)->destination) - 1); - strncpy(hdr->source, mesh->self->name, (sizeof(hdr)->source) - 1); + strncpy((char *)hdr->destination, destination->name, (sizeof(hdr)->destination) - 1); + strncpy((char *)hdr->source, mesh->self->name, (sizeof(hdr)->source) - 1); memcpy(packet->data + sizeof(*hdr), data, len); diff --git a/src/meshlink.h b/src/meshlink.h index be929c29..e85be2ff 100644 --- a/src/meshlink.h +++ b/src/meshlink.h @@ -37,10 +37,10 @@ extern "C" { #endif /// The length in bytes of a signature made with meshlink_sign() -#define MESHLINK_SIGLEN (64) +#define MESHLINK_SIGLEN (64ul) // The maximum length of fingerprints -#define MESHLINK_FINGERPRINTLEN (64) +#define MESHLINK_FINGERPRINTLEN (64ul) /// A handle for an instance of MeshLink. typedef struct meshlink_handle meshlink_handle_t; diff --git a/test/channels-fork.c b/test/channels-fork.c index 673760e2..faa16c6e 100644 --- a/test/channels-fork.c +++ b/test/channels-fork.c @@ -184,7 +184,7 @@ int main2(int rfd, int wfd) { int main(int argc, char *argv[]) { - int fda[2], fdb[2], result; + int fda[2], fdb[2]; pipe2(fda, 0); pipe2(fdb, 0); diff --git a/test/trio.c b/test/trio.c index 0a494c28..486aac3e 100644 --- a/test/trio.c +++ b/test/trio.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "meshlink.h" #include "utils.h"