]> git.meshlink.io Git - meshlink/blobdiff - test/trio.c
Fix all compiler warnings found using -Wall -W -pedantic.
[meshlink] / test / trio.c
index fbf7255c0b30aeadd1bdbb02a45a3fd23650061e..2cb14bd301af273c37c9948a6efc58cd80be96c8 100644 (file)
 #include "utils.h"
 
 static void log_cb(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+       (void)mesh;
+
        static struct timeval tv0;
        struct timeval tv;
 
-       if(tv0.tv_sec == 0)
+       if(tv0.tv_sec == 0) {
                gettimeofday(&tv0, NULL);
+       }
+
        gettimeofday(&tv, NULL);
        fprintf(stderr, "%u.%.03u ", (unsigned int)(tv.tv_sec - tv0.tv_sec), (unsigned int)tv.tv_usec / 1000);
 
-       if(mesh)
+       if(mesh) {
                fprintf(stderr, "(%s) ", mesh->name);
+       }
+
        fprintf(stderr, "[%d] %s\n", level, text);
 }
 
 static bool received = false;
 
 static void receive_cb(meshlink_handle_t *mesh, meshlink_node_t *source, const void *data, size_t len) {
+       (void)mesh;
+       (void)source;
+
        fprintf(stderr, "RECEIVED SOMETHING\n");
-       if(len == 5 && !memcmp(data, "Hello", 5))
+
+       if(len == 5 && !memcmp(data, "Hello", 5)) {
                received = true;
+       }
 }
 
-int main(int argc, char *argv[]) {
+int main() {
        // Create three instances.
 
        const char *name[3] = {"foo", "bar", "baz"};
@@ -69,8 +80,9 @@ int main(int argc, char *argv[]) {
 
        // start the nodes
 
-       for(int i = 0; i < 3; i++)
+       for(int i = 0; i < 3; i++) {
                meshlink_start(mesh[i]);
+       }
 
        // the nodes should now learn about each other
 
@@ -99,8 +111,9 @@ int main(int argc, char *argv[]) {
 
        // Stop the other nodes
 
-       for(int i = 1; i < 3; i++)
+       for(int i = 1; i < 3; i++) {
                meshlink_stop(mesh[i]);
+       }
 
        sleep(1);
 
@@ -108,8 +121,9 @@ int main(int argc, char *argv[]) {
 
        meshlink_set_log_cb(mesh[1], MESHLINK_DEBUG, log_cb);
 
-       for(int i = 1; i < 3; i++)
+       for(int i = 1; i < 3; i++) {
                meshlink_start(mesh[i]);
+       }
 
        assert(meshlink_get_node(mesh[1], name[2]));
        assert(meshlink_get_node(mesh[2], name[1]));
@@ -121,6 +135,7 @@ int main(int argc, char *argv[]) {
 
        // Clean up.
 
-       for(int i = 0; i < 3; i++)
+       for(int i = 0; i < 3; i++) {
                meshlink_close(mesh[i]);
+       }
 }