From: Kaj-Michael Lang Date: Fri, 1 Aug 2008 12:04:51 +0000 (+0300) Subject: Gps: NULL checks for simulator. Add some more comments. Warning fixes. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=649e5137da51fc06ee0e6c77524316241bf48d24;p=mapper Gps: NULL checks for simulator. Add some more comments. Warning fixes. --- diff --git a/src/gps.c b/src/gps.c index d326f3d..c87779e 100644 --- a/src/gps.c +++ b/src/gps.c @@ -206,6 +206,7 @@ if (gps->io.conn==RCVR_DOWN && gps->io.address) { #endif /** + * * Place a request to connect about 1 second after the function is called. */ void @@ -213,6 +214,7 @@ gps_connect_later(Gps *gps) { g_assert(gps); g_assert(gps->io.clater_sid==0); + gps->io.clater_sid=g_timeout_add(1000, (GSourceFunc)gps_connect_now, gps); } @@ -260,6 +262,7 @@ static gboolean gps_connect_socket(Gps *gps) { gint r, e; + g_assert(gps); switch (gps->io.type) { @@ -400,7 +403,7 @@ static void gps_simulate_start(Gps *gps, Position *p_from) { g_assert(gps); -if (p_from->valid) { +if (p_from && p_from->valid) { gps->data.lat=p_from->lat; gps->data.lon=p_from->lon; } else { @@ -409,7 +412,7 @@ if (p_from->valid) { } gps->io.conn=RCVR_FIXED; -gps->data.fix=FIX_2D; +gps->data.fix=FIX_3D; gps->data.satinview=0; gps->data.satinuse=0; gps_data_integerize(&gps->data); @@ -424,7 +427,7 @@ gfloat h; g_assert(gps); -if (p_to->valid) { +if (p_to && p_to->valid) { gdouble c; c=calculate_course_rad(p_to->lat, p_to->lon, gps->data.lat, gps->data.lon); @@ -462,6 +465,9 @@ return gps->io.conn==RCVR_FIXED ? TRUE : FALSE; } /** + * gps_read_buffer_prepare: + * @gps + * * Reset GPS read buffer */ static void @@ -473,6 +479,9 @@ gps->io.last=gps->io.buffer+GPS_READ_BUF_SIZE-1; } /** + * gps_connect_channel_connect: + * @gps + * * Connect file descriptor to channel and add watches. */ static void @@ -489,6 +498,9 @@ gps->io.clater_sid=0; } /** + * gps_connect_now: + * @gps + * * Connect to the receiver. * This method assumes that fd is -1 and _channel is NULL. If unsure, call * gps_disconnect() first. @@ -544,7 +556,7 @@ switch (gps->io.type) { perror("TCP:"); return FALSE; } - ip=ip = inet_ntop (AF_INET, (struct in_addr *)hostinfo->h_addr_list[0], ipbuf, sizeof (ipbuf)); + ip=inet_ntop (AF_INET, (struct in_addr *)hostinfo->h_addr_list[0], ipbuf, sizeof (ipbuf)); } if (inet_pton(AF_INET, ip, &gps->io.rcvr_addr_in.sin_addr.s_addr)<1) { @@ -569,6 +581,7 @@ switch (gps->io.type) { g_warning("Failed to start gpsd: %d (%s) %s\n", errno, strerror(errno), errbuf); return FALSE; } else { + /* XXX: Use timer cb instead to flag it's ok to connect */ g_debug("Waiting for gpsd"); sleep(2); g_debug("Done wating");