diff --git a/http.c b/http.c index cfa63c8..ae9ca0f 100644 --- a/http.c +++ b/http.c @@ -33,6 +33,7 @@ #include "geohash.h" #include "udata.h" #include "version.h" +#include #ifdef WITH_HTTP # include "http.h" #endif @@ -288,7 +289,8 @@ static void send_last(struct mg_connection *conn) JsonNode *user_array, *o, *one; char *u = NULL, *d = NULL, *ghash; double lat, lon; - + lat = DBL_MAX; + lon = DBL_MAX; u = field(conn, "user"); d = field(conn, "device"); @@ -334,10 +336,10 @@ static void send_last(struct mg_connection *conn) if ((f = json_find_member(one, "topic")) != NULL) json_copy_element_to_object(o, "topic", f); - if ((ghash = geohash_encode(lat, lon, geohash_prec())) != NULL) { + if ((ghash = geohash_encode(lat, lon, geohash_prec())) != NULL) { json_append_member(o, "ghash", json_mkstring(ghash)); free(ghash); - } + } http_ws_push_json(ud->mgserver, o); json_delete(o); @@ -1586,4 +1588,3 @@ int ev_handler(struct mg_connection *conn, enum mg_event ev) } #endif /* WITH_HTTP */ - diff --git a/mongoose.c b/mongoose.c index 274ec50..5b23db5 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1,3 +1,4 @@ +#pragma GCC diagnostic ignored "-Wunused-result" // Copyright (c) 2004-2013 Sergey Lyubka // Copyright (c) 2013-2014 Cesanta Software Limited // All rights reserved diff --git a/util.c b/util.c index fdce2b4..74a6f40 100644 --- a/util.c +++ b/util.c @@ -535,7 +535,9 @@ int safewrite(char *filename, char *buf) } /* Ensure NL-terminated */ if (buf[strlen(buf) - 1] != '\n') { - write(fd, "\n", 1); + if (write(fd, "\n", 1) != 1) { + return (-1); + } } close(fd); @@ -595,7 +597,7 @@ double haversine_dist(double th1, double ph1, double th2, double ph2) void chomp(char *s) { char *p; - + if (!s || *s == 0) return;