diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2015-02-26 14:28:33 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-02-26 14:28:33 -0500 |
commit | bab8757bc9e0b64883c8eeaa9ce5bd1909bbdcd4 (patch) | |
tree | 9f8a539fcdefa2e964c9573a28ade569977aa98c /ntpshmread.c | |
parent | 6313827df2a9a0067132626a886e628990715064 (diff) | |
download | gpsd-bab8757bc9e0b64883c8eeaa9ce5bd1909bbdcd4.tar.gz |
Pre-release splint/cppcheck/coverity cleanup. All regression tests pass.
Diffstat (limited to 'ntpshmread.c')
-rw-r--r-- | ntpshmread.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/ntpshmread.c b/ntpshmread.c index 5d39dad6..880ef542 100644 --- a/ntpshmread.c +++ b/ntpshmread.c @@ -12,16 +12,19 @@ #include <sys/types.h> #include <sys/stat.h> #include <assert.h> -#include <unistd.h> #include <stdio.h> #include <stdint.h> +#ifndef S_SPLINT_S +#include <unistd.h> +#endif /* S_SPLINT_S*/ #include "ntpshm.h" #include "compiler.h" -struct shmTime *shm_get(const int unit, const bool create, const bool forall) +struct shmTime /*@null@*/ *shm_get(const int unit, const bool create, const bool forall) /* initialize an initial segment */ { + /*@-mustfreefresh@*/ struct shmTime *p = NULL; int shmid; @@ -29,7 +32,7 @@ struct shmTime *shm_get(const int unit, const bool create, const bool forall) * Big units will give non-ascii but that's OK * as long as everybody does it the same way. */ - shmid = shmget(NTPD_BASE + unit, sizeof(struct shmTime), + shmid = shmget((key_t)(NTPD_BASE + unit), sizeof(struct shmTime), (create ? IPC_CREAT : 0) | (forall ? 0666 : 0600)); if (shmid == -1) { /* error */ return NULL; @@ -39,19 +42,22 @@ struct shmTime *shm_get(const int unit, const bool create, const bool forall) return NULL; } return p; + /*@+mustfreefresh@*/ } +/*@-statictrans@*/ char *shm_name(const int unit) /* return the name of a specified segment */ { static char name[5] = "NTP\0"; - name[3] = '0' + (char)unit; + /*@i2@*/name[3] = '0' + (char)unit; return name; } +/*@+statictrans@*/ -enum segstat_t shm_query(struct shmTime *shm_in, struct shm_stat_t *shm_stat) +enum segstat_t shm_query(/*@null@*/struct shmTime *shm_in, /*@out@*/struct shm_stat_t *shm_stat) /* try to grab a sample from the specified SHM segment */ { volatile struct shmTime shmcopy, *shm = shm_in; @@ -64,6 +70,7 @@ enum segstat_t shm_query(struct shmTime *shm_in, struct shm_stat_t *shm_stat) return NO_SEGMENT; } + /*@-type@*//* splint is confused about struct timespec */ shm_stat->tvc.tv_sec = shm_stat->tvc.tv_nsec = 0; clock_gettime(CLOCK_REALTIME, &shm_stat->tvc); @@ -155,6 +162,7 @@ enum segstat_t shm_query(struct shmTime *shm_in, struct shm_stat_t *shm_stat) shm_stat->status = BAD_MODE; break; } + /*@-type@*/ /* * leap field is not a leap offset but a leap notification code. |