diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-04-16 09:43:16 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-04-16 09:43:16 -0400 |
commit | a48f7b85d096e68919b4eae8eba5607fe35e3c93 (patch) | |
tree | 95562c145e4fe3f29e314fc7e01dc2ca5342b875 /libgps_json.c | |
parent | 51c343c366942b073680b278091355369a126934 (diff) | |
download | gpsd-a48f7b85d096e68919b4eae8eba5607fe35e3c93.tar.gz |
Use t_time consistently for timestamps.
All regression tests pass. Livetesting with cgps looks good.
Diffstat (limited to 'libgps_json.c')
-rw-r--r-- | libgps_json.c | 56 |
1 files changed, 8 insertions, 48 deletions
diff --git a/libgps_json.c b/libgps_json.c index b1333fa3..cebd7961 100644 --- a/libgps_json.c +++ b/libgps_json.c @@ -34,8 +34,6 @@ PERMISSIONS static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata, /*@null@*/ const char **endptr) { - int status; - char tbuf[JSON_DATE_MAX+1]; /*@ -fullinitblock @*/ const struct json_attr_t json_attrs_1[] = { /* *INDENT-OFF* */ @@ -44,8 +42,8 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata, .len = sizeof(gpsdata->dev.path)}, {"tag", t_string, .addr.string = gpsdata->tag, .len = sizeof(gpsdata->tag)}, - {"time", t_string, .addr.string = tbuf, - .len = sizeof(tbuf)}, + {"time", t_time, .addr.real = &gpsdata->fix.time, + .dflt.real = NAN}, {"time", t_real, .addr.real = &gpsdata->fix.time, .dflt.real = NAN}, {"ept", t_real, .addr.real = &gpsdata->fix.ept, @@ -81,27 +79,12 @@ static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata, }; /*@ +fullinitblock @*/ - tbuf[0] = '\0'; - status = json_read_object(buf, json_attrs_1, endptr); - - if (status == 0) { - /*@-usedef@*/ - if (isnan(gpsdata->fix.time)!=0) { - if (tbuf[0] == '\0') - gpsdata->fix.time = NAN; - else - gpsdata->fix.time = iso8601_to_unix(tbuf); - } - /*@+usedef@*/ - } - return status; + return json_read_object(buf, json_attrs_1, endptr); } static int json_noise_read(const char *buf, struct gps_data_t *gpsdata, /*@null@*/ const char **endptr) { - int status; - char tbuf[JSON_DATE_MAX+1]; /*@ -fullinitblock @*/ const struct json_attr_t json_attrs_1[] = { /* *INDENT-OFF* */ @@ -110,8 +93,8 @@ static int json_noise_read(const char *buf, struct gps_data_t *gpsdata, .len = sizeof(gpsdata->dev.path)}, {"tag", t_string, .addr.string = gpsdata->tag, .len = sizeof(gpsdata->tag)}, - {"time", t_string, .addr.string = tbuf, - .len = sizeof(tbuf)}, + {"time", t_time, .addr.real = &gpsdata->gst.utctime, + .dflt.real = NAN}, {"time", t_real, .addr.real = &gpsdata->gst.utctime, .dflt.real = NAN}, {"rms", t_real, .addr.real = &gpsdata->gst.rms_deviation, @@ -133,27 +116,13 @@ static int json_noise_read(const char *buf, struct gps_data_t *gpsdata, }; /*@ +fullinitblock @*/ - tbuf[0] = '\0'; - status = json_read_object(buf, json_attrs_1, endptr); - if (status != 0) - return status; - - /*@-usedef@*/ - if (isnan(gpsdata->fix.time)!=0) { - if (tbuf[0] == '\0') - gpsdata->gst.utctime = NAN; - else - gpsdata->gst.utctime = iso8601_to_unix(tbuf); - } - /*@+usedef@*/ - return 0; + return json_read_object(buf, json_attrs_1, endptr); } static int json_sky_read(const char *buf, struct gps_data_t *gpsdata, /*@null@*/ const char **endptr) { bool usedflags[MAXCHANNELS]; - char tbuf[JSON_DATE_MAX+1]; /*@ -fullinitblock @*/ const struct json_attr_t json_attrs_2_1[] = { /* *INDENT-OFF* */ @@ -172,8 +141,8 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata, .len = sizeof(gpsdata->dev.path)}, {"tag", t_string, .addr.string = gpsdata->tag, .len = sizeof(gpsdata->tag)}, - {"time", t_string, .addr.string = tbuf, - .len = sizeof(tbuf)}, + {"time", t_time, .addr.real = &gpsdata->skyview_time, + .dflt.real = NAN}, {"time", t_real, .addr.real = &gpsdata->skyview_time, .dflt.real = NAN}, {"hdop", t_real, .addr.real = &gpsdata->dop.hdop, @@ -205,19 +174,10 @@ static int json_sky_read(const char *buf, struct gps_data_t *gpsdata, usedflags[i] = false; } - tbuf[0] = '\0'; status = json_read_object(buf, json_attrs_2, endptr); if (status != 0) return status; - /*@-usedef@*/ - if (isnan(gpsdata->fix.time)!=0) { - if (tbuf[0] == '\0') - gpsdata->skyview_time = NAN; - else - gpsdata->skyview_time = iso8601_to_unix(tbuf); - } - /*@+usedef@*/ gpsdata->satellites_used = 0; gpsdata->satellites_visible = 0; (void)memset(gpsdata->used, '\0', sizeof(gpsdata->used)); |