summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gpsd.c2
-rw-r--r--gpsd.h-tail4
-rw-r--r--ntpshm.c11
3 files changed, 11 insertions, 6 deletions
diff --git a/gpsd.c b/gpsd.c
index 0c7a7bc6..80a08cf9 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -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 {
diff --git a/ntpshm.c b/ntpshm.c
index 81f1778a..9ae0d491 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -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);