X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=examples%2Fmanynodes.c;h=3d82bd31d921f32dea1ad789f84b0d070fc02636;hb=ad87362afd13c4f14ce9a4b2cf0586a753b5a422;hp=2cfe818033e371bc673b37a35920d5f880674a5c;hpb=668664d0ea90dc81670cccd7b7d56b36b8360eaa;p=meshlink diff --git a/examples/manynodes.c b/examples/manynodes.c index 2cfe8180..3d82bd31 100644 --- a/examples/manynodes.c +++ b/examples/manynodes.c @@ -53,7 +53,7 @@ static void testmesh() { } else { printf("%zu known nodes:\n", nnodes); - for(int i = 0; i < nnodes; i++) { + for(size_t i = 0; i < nnodes; i++) { //printf(" %s\n", nodes[i]->name); if(!meshlink_send(mesh[nindex], nodes[i], "magic", strlen("magic") + 1)) { fprintf(stderr, "Could not send message to '%s': %s\n", nodes[i]->name, meshlink_strerror(meshlink_errno)); @@ -115,6 +115,8 @@ static bool exportmeshgraph(const char *path) { void exportmeshgraph_timer(int signum) { + (void)signum; + struct timeval ts; gettimeofday(&ts, NULL); @@ -127,12 +129,12 @@ void exportmeshgraph_timer(int signum) { #ifndef _WIN32 static bool exportmeshgraph_started = false; -static bool exportmeshgraph_end(const char *none) { +static bool exportmeshgraph_end(void) { if(!exportmeshgraph_started) { return false; } - struct itimerval zero_timer = { 0 }; + struct itimerval zero_timer; setitimer(ITIMER_REAL, &zero_timer, NULL); @@ -147,7 +149,7 @@ static bool exportmeshgraph_begin(const char *timeout_str) { } if(exportmeshgraph_started) { - if(!exportmeshgraph_end(NULL)) { + if(!exportmeshgraph_end()) { return false; } } @@ -182,7 +184,7 @@ static bool exportmeshgraph_begin(const char *timeout_str) { return true; } #else -static bool exportmeshgraph_end(const char *none) { +static bool exportmeshgraph_end(void) { return false; } @@ -206,7 +208,7 @@ static void parse_command(char *buf) { return; } - invitation = meshlink_invite(mesh[nodeindex], arg); + invitation = meshlink_invite(mesh[nodeindex], NULL, arg); if(!invitation) { fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno)); @@ -258,7 +260,7 @@ static void parse_command(char *buf) { } else { printf("%zu known nodes:", nnodes); - for(int i = 0; i < nnodes; i++) { + for(size_t i = 0; i < nnodes; i++) { printf(" %s", nodes[i]->name); } @@ -270,7 +272,7 @@ static void parse_command(char *buf) { if(!node) { fprintf(stderr, "Unknown node '%s'\n", arg); } else { - printf("Node %s found, pmtu %zd\n", arg, meshlink_get_pmtu(mesh[nodeindex], node)); + printf("Node %s found, pmtu %ld\n", arg, (long int)meshlink_get_pmtu(mesh[nodeindex], node)); } } } else if(!strcasecmp(buf, "link")) { @@ -280,7 +282,7 @@ static void parse_command(char *buf) { } else if(!strcasecmp(buf, "egb")) { exportmeshgraph_begin(arg); } else if(!strcasecmp(buf, "ege")) { - exportmeshgraph_end(NULL); + exportmeshgraph_end(); } else if(!strcasecmp(buf, "test")) { testmesh(); } else if(!strcasecmp(buf, "select")) { @@ -345,7 +347,8 @@ static void parse_input(char *buf) { // Commands start with '/' if(*buf == '/') { - return parse_command(buf + 1); + parse_command(buf + 1); + return; } // Lines in the form "name: message..." set the destination node. @@ -465,7 +468,7 @@ int main(int argc, char *argv[]) { parse_input(buf); } - exportmeshgraph_end(NULL); + exportmeshgraph_end(); printf("Nodes stopping.\n");