]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.c
Ensure everything compiles with -Wall without giving warnings.
[meshlink] / src / meshlink.c
index 4aadaaa9b0ef9c557ab4cb17a3bce030be82fdce..2aa79def7d47c6762e01f30715cb14e277933991 100644 (file)
@@ -426,6 +426,7 @@ static bool finalize_join(meshlink_handle_t *mesh) {
        FILE *fh = fopen(filename, "w");
        if(!fh) {
                fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno));
+               fclose(f);
                return false;
        }
 
@@ -548,7 +549,7 @@ static bool finalize_join(meshlink_handle_t *mesh) {
        return true;
 }
 
-static bool invitation_send(void *handle, uint8_t type, const char *data, size_t len) {
+static bool invitation_send(void *handle, uint8_t type, const void *data, size_t len) {
        meshlink_handle_t* mesh = handle;
        while(len) {
                int result = send(mesh->sock, data, len, 0);
@@ -562,7 +563,7 @@ static bool invitation_send(void *handle, uint8_t type, const char *data, size_t
        return true;
 }
 
-static bool invitation_receive(void *handle, uint8_t type, const char *msg, uint16_t len) {
+static bool invitation_receive(void *handle, uint8_t type, const void *msg, uint16_t len) {
        meshlink_handle_t* mesh = handle;
        switch(type) {
                case SPTPS_HANDSHAKE:
@@ -885,7 +886,15 @@ meshlink_node_t *meshlink_get_node(meshlink_handle_t *mesh, const char *name) {
 }
 
 size_t meshlink_get_all_nodes(meshlink_handle_t *mesh, meshlink_node_t **nodes, size_t nmemb) {
-       return 0;
+       size_t i = 0;
+
+       for splay_each(node_t, n, mesh->nodes) {
+               if(i < nmemb)
+                       nodes[i] = (meshlink_node_t *)n;
+               i++;
+       }
+
+       return i;
 }
 
 char *meshlink_sign(meshlink_handle_t *mesh, const char *data, size_t len) {