diff options
-rw-r--r-- | gpsd.c | 2 | ||||
-rw-r--r-- | gpsd.h-tail | 4 | ||||
-rw-r--r-- | ntpshm.c | 11 |
3 files changed, 11 insertions, 6 deletions
@@ -1541,7 +1541,7 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed) //gpsd_report(&context.errout, LOG_PROG, "NTP: Not a new time\n"); } else if (!device->ship_to_ntpd) { //gpsd_report(&context.errout, LOG_PROG, "NTP: No precision time report\n"); - } else { + } else if (device->shm_clock != NULL) { /*@-compdef@*/ struct timedrift_t td; ntpshm_latch(device, &td); diff --git a/gpsd.h-tail b/gpsd.h-tail index a361f403..3865fc29 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -490,9 +490,9 @@ struct gps_device_t { #endif /* TIMING_ENABLE */ #ifdef NTPSHM_ENABLE bool ship_to_ntpd; - volatile struct shmTime *shm_clock; + volatile /*@null@*/ struct shmTime *shm_clock; # ifdef PPS_ENABLE - volatile struct shmTime *shm_pps; + volatile /*@null@*/ struct shmTime *shm_pps; # endif /* PPS_ENABLE */ #endif /* NTPSHM_ENABLE */ volatile struct { @@ -220,6 +220,7 @@ static bool ntpshm_free(struct gps_context_t * context, volatile struct shmTime void ntpshm_session_init(struct gps_device_t *session) { + /*@-mustfreeonly@*/ #ifdef NTPSHM_ENABLE /* mark NTPD shared memory segments as unused */ session->shm_clock = NULL; @@ -227,6 +228,7 @@ void ntpshm_session_init(struct gps_device_t *session) #ifdef PPS_ENABLE session->shm_pps = NULL; #endif /* PPS_ENABLE */ + /*@+mustfreeonly@*/ } int ntpshm_put(struct gps_device_t *session, volatile struct shmTime *shmseg, struct timedrift_t *td) @@ -414,7 +416,8 @@ static /*@observer@*/ char *report_hook(struct gps_device_t *session, log1 = "accepted chrony sock"; chrony_send(session, td); } - (void)ntpshm_put(session, session->shm_pps, td); + if (session->shm_pps != NULL) + (void)ntpshm_put(session, session->shm_pps, td); return log1; } @@ -423,8 +426,10 @@ static /*@observer@*/ char *report_hook(struct gps_device_t *session, void ntpshm_link_deactivate(struct gps_device_t *session) /* release ntpshm storage for a session */ { - (void)ntpshm_free(session->context, session->shm_clock); - session->shm_clock = NULL; + if (session->shm_clock != NULL) { + (void)ntpshm_free(session->context, session->shm_clock); + session->shm_clock = NULL; + } #if defined(PPS_ENABLE) if (session->shm_pps != NULL) { pps_thread_deactivate(session); |