diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2014-08-27 16:26:52 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2014-08-27 16:26:52 -0400 |
commit | 6203e5b8fcac9d78ea54b7b3c53cb8d084e8a219 (patch) | |
tree | d8611d8e44267151c29ab8920702cc94e86063c5 /driver_garmin_txt.c | |
parent | b53db1322c70f8b86dfe72e982d6097304a749ae (diff) | |
download | gpsd-6203e5b8fcac9d78ea54b7b3c53cb8d084e8a219.tar.gz |
Introduce struct errout_t to encapsulate error-reporting hooks.
A major step towards eliminating reverse linkage.
All regression tests pass.
Diffstat (limited to 'driver_garmin_txt.c')
-rw-r--r-- | driver_garmin_txt.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/driver_garmin_txt.c b/driver_garmin_txt.c index e708354a..2be5ce1a 100644 --- a/driver_garmin_txt.c +++ b/driver_garmin_txt.c @@ -127,7 +127,7 @@ invalid data. * -1: data error * -2: data not valid * - * examples with context->debug == 0: + * examples with context->errout.debug == 0: * gar_decode(context, cbuf, 9, "EW", 100000.0, &result); * E01412345 -> +14.12345 @@ -153,13 +153,13 @@ static int gar_decode(const struct gps_context_t *context, /* splint is buggy here, thinks buf can be a null pointer */ /*@ -mustdefine -nullderef -nullpass @*/ if (length >= sizeof(buf)) { - gpsd_report(context->debug, LOG_ERROR, "internal buffer too small\n"); + gpsd_report(context->errout.debug, LOG_ERROR, "internal buffer too small\n"); return -1; } bzero(buf, (int)sizeof(buf)); (void)strlcpy(buf, data, length); - gpsd_report(context->debug, LOG_RAW + 2, "Decoded string: %s\n", buf); + gpsd_report(context->errout.debug, LOG_RAW + 2, "Decoded string: %s\n", buf); if (strchr(buf, '_') != NULL) { /* value is not valid, ignore it */ @@ -186,14 +186,14 @@ static int gar_decode(const struct gps_context_t *context, break; } } - gpsd_report(context->debug, LOG_WARN, + gpsd_report(context->errout.debug, LOG_WARN, "Unexpected char \"%c\" in data \"%s\"\n", buf[0], buf); return -1; } while (0); if (strspn(buf + offset, "0123456789") != length - offset) { - gpsd_report(context->debug, LOG_WARN, "Invalid value %s\n", buf); + gpsd_report(context->errout.debug, LOG_WARN, "Invalid value %s\n", buf); return -1; } /*@ +mustdefine +nullderef +nullpass @*/ @@ -223,13 +223,13 @@ static int gar_int_decode(const struct gps_context_t *context, /*@ -mustdefine @*/ if (length >= sizeof(buf)) { - gpsd_report(context->debug, LOG_ERROR, "internal buffer too small\n"); + gpsd_report(context->errout.debug, LOG_ERROR, "internal buffer too small\n"); return -1; } bzero(buf, (int)sizeof(buf)); (void)strlcpy(buf, data, length); - gpsd_report(context->debug, LOG_RAW + 2, "Decoded string: %s\n", buf); + gpsd_report(context->errout.debug, LOG_RAW + 2, "Decoded string: %s\n", buf); if (strchr(buf, '_') != NULL) { /* value is not valid, ignore it */ @@ -238,7 +238,7 @@ static int gar_int_decode(const struct gps_context_t *context, /*@ -nullpass @*//* splint bug */ if (strspn(buf, "0123456789") != length) { - gpsd_report(context->debug, LOG_WARN, "Invalid value %s\n", buf); + gpsd_report(context->errout.debug, LOG_WARN, "Invalid value %s\n", buf); return -1; } @@ -247,7 +247,7 @@ static int gar_int_decode(const struct gps_context_t *context, *result = res; return 0; /* SUCCESS */ } else { - gpsd_report(context->debug, LOG_WARN, + gpsd_report(context->errout.debug, LOG_WARN, "Value %u out of range <%u, %u>\n", res, min, max); return -1; @@ -268,13 +268,13 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session) gps_mask_t mask = 0; - gpsd_report(session->context->debug, LOG_PROG, + gpsd_report(session->context->errout.debug, LOG_PROG, "Garmin Simple Text packet, len %zd: %s\n", session->lexer.outbuflen, (char*)session->lexer.outbuffer); if (session->lexer.outbuflen < 54) { /* trailing CR and LF can be ignored; ('@' + 54x 'DATA' + '\r\n') has length 57 */ - gpsd_report(session->context->debug, LOG_WARN, + gpsd_report(session->context->errout.debug, LOG_WARN, "Message is too short, rejected.\n"); return ONLINE_SET; } @@ -286,7 +286,7 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session) do { unsigned int result; char *buf = (char *)session->lexer.outbuffer + 1; - gpsd_report(session->context->debug, LOG_PROG, "Timestamp: %.12s\n", buf); + gpsd_report(session->context->errout.debug, LOG_PROG, "Timestamp: %.12s\n", buf); /* year */ if (0 != gar_int_decode(session->context, @@ -460,7 +460,7 @@ gps_mask_t garmintxt_parse(struct gps_device_t * session) mask |= CLIMB_SET; } while (0); - gpsd_report(session->context->debug, LOG_DATA, + gpsd_report(session->context->errout.debug, LOG_DATA, "GTXT: time=%.2f, lat=%.2f lon=%.2f alt=%.2f speed=%.2f track=%.2f climb=%.2f exp=%.2f epy=%.2f mode=%d status=%d\n", session->newdata.time, session->newdata.latitude, session->newdata.longitude, session->newdata.altitude, |