summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ais_json.c4
-rw-r--r--driver_aivdm.c6
-rw-r--r--driver_evermore.c2
-rw-r--r--gps_json.h8
-rw-r--r--gpsctl.c12
-rw-r--r--gpsd.c10
-rw-r--r--gpsd.h-tail4
-rw-r--r--gpsd_json.c6
-rw-r--r--gpsdclient.h2
-rw-r--r--hex.c4
-rw-r--r--json.c12
-rw-r--r--json.h4
-rw-r--r--libgps_json.c15
-rw-r--r--net_remotegpsd.c4
14 files changed, 57 insertions, 36 deletions
diff --git a/ais_json.c b/ais_json.c
index 3556377e..ff32b665 100644
--- a/ais_json.c
+++ b/ais_json.c
@@ -20,15 +20,17 @@ representations to libgps structures.
#include "gpsd.h"
#include "gps_json.h"
+/*@ -mustdefine @*/
static void lenhex_unpack(const char *from,
size_t *plen, /*@out@*/char *to, size_t maxlen)
{
char *colon = strchr(from, ':');
- *plen = (unsigned)atoi(from);
+ *plen = (size_t)atoi(from);
if (colon != NULL)
(void)gpsd_hexpack(colon+1, to, maxlen);
}
+/*@ +mustdefine @*/
int json_ais_read(const char *buf,
char *path, size_t pathlen,
diff --git a/driver_aivdm.c b/driver_aivdm.c
index 1b26fbda..f4a91e12 100644
--- a/driver_aivdm.c
+++ b/driver_aivdm.c
@@ -237,7 +237,7 @@ bool aivdm_decode(char *buf, size_t buflen,
(void)memcpy(ais->type6.bitdata,
(char *)ais_context->bits+11,
(ais->type6.bitcount + 7) / 8);
- gpsd_report(LOG_INF, "seqno=%d, dest=%u, id=%u, cnt=%u\n",
+ gpsd_report(LOG_INF, "seqno=%d, dest=%u, id=%u, cnt=%zd\n",
ais->type6.seqno,
ais->type6.dest_mmsi,
ais->type6.app_id,
@@ -252,10 +252,12 @@ bool aivdm_decode(char *buf, size_t buflen,
mmsi[i] = UBITS(40 + 32*i, 30);
else
mmsi[i] = 0;
+ /*@ -usedef @*/
ais->type7.mmsi1 = mmsi[0];
ais->type7.mmsi2 = mmsi[1];
ais->type7.mmsi3 = mmsi[2];
ais->type7.mmsi4 = mmsi[3];
+ /*@ +usedef @*/
gpsd_report(LOG_INF, "\n");
break;
}
@@ -266,7 +268,7 @@ bool aivdm_decode(char *buf, size_t buflen,
(void)memcpy(ais->type8.bitdata,
(char *)ais_context->bits+7,
(ais->type8.bitcount + 7) / 8);
- gpsd_report(LOG_INF, "id=%u, cnt=%u\n",
+ gpsd_report(LOG_INF, "id=%u, cnt=%zd\n",
ais->type8.app_id,
ais->type8.bitcount);
break;
diff --git a/driver_evermore.c b/driver_evermore.c
index 8889238f..6a6b09c7 100644
--- a/driver_evermore.c
+++ b/driver_evermore.c
@@ -155,6 +155,7 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size
datalen -= 2;
+ /*@ -usedef @*/
for (i = 0; i < (size_t)datalen; i++) {
*tp = *cp++;
if (*tp == 0x10) cp++;
@@ -162,6 +163,7 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size
}
type = getub(buf2, 1);
+ /*@ +usedef @*/
/*@ -usedef -compdef @*/
gpsd_report(LOG_RAW, "EverMore packet type 0x%02x, length %zd: %s\n",
diff --git a/gps_json.h b/gps_json.h
index 40dba1e0..2f27900e 100644
--- a/gps_json.h
+++ b/gps_json.h
@@ -6,15 +6,15 @@
#define GPS_JSON_RESPONSE_MAX 1024
char *json_stringify(/*@out@*/char *, size_t, /*@in@*/const char *);
-int json_watch_read(const char *, struct policy_t *, const char **);
-int json_device_read(const char *, struct devconfig_t *, const char **);
+int json_watch_read(const char *, struct policy_t *, /*@null@*/const char **);
+int json_device_read(const char *, struct devconfig_t *, /*@null@*/const char **);
void json_version_dump(/*@out@*/char *, size_t);
void json_tpv_dump(struct gps_data_t *, struct gps_fix_t *, char *, size_t);
void json_sky_dump(struct gps_data_t *, char *, size_t);
void json_device_dump(struct gps_device_t *, char *, size_t);
void json_watch_dump(struct policy_t *, char *, size_t);
-int json_rtcm2_read(const char *, char *, size_t, struct rtcm2_t *, const char **);
-int json_ais_read(const char *, char *, size_t, struct ais_t *, const char **);
+int json_rtcm2_read(const char *, char *, size_t, struct rtcm2_t *, /*@null@*/const char **);
+int json_ais_read(const char *, char *, size_t, struct ais_t *, /*@null@*/const char **);
int libgps_json_unpack(const char *, struct gps_data_t *);
/* gps_json.h ends here */
diff --git a/gpsctl.c b/gpsctl.c
index 0b2fb87b..b11414c6 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -288,12 +288,12 @@ int main(int argc, char **argv)
}
if (to_nmea) {
- (void)gps_query(gpsdata, "?DEVICE={\"device\":%s,\"mode\":0}\r\n", device);
- if (gpsdata->dev.driver_mode != MODE_NMEA) {
- gpsd_report(LOG_ERROR, "%s mode change to NMEA failed\n", gpsdata->dev.path);
- status = 1;
- } else
- gpsd_report(LOG_PROG, "%s mode change succeeded\n", gpsdata->dev.path);
+ (void)gps_query(gpsdata, "?DEVICE={\"device\":%s,\"mode\":0}\r\n", device);
+ if (gpsdata->dev.driver_mode != MODE_NMEA) {
+ gpsd_report(LOG_ERROR, "%s mode change to NMEA failed\n", gpsdata->dev.path);
+ status = 1;
+ } else
+ gpsd_report(LOG_PROG, "%s mode change succeeded\n", gpsdata->dev.path);
}
else if (to_binary) {
(void)gps_query(gpsdata, "?DEVICE={\"device\":%s,\"mode\":1}\r\n", device);
diff --git a/gpsd.c b/gpsd.c
index f1b4ce85..b4c9d274 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -515,7 +515,7 @@ static void detach_client(struct subscriber_t *sub)
sub->fd = -1;
}
-static ssize_t throttled_write(struct subscriber_t *sub, char *buf, ssize_t len)
+static ssize_t throttled_write(struct subscriber_t *sub, char *buf, size_t len)
/* write to client -- throttle if it's gone or we're close to buffer overrun */
{
ssize_t status;
@@ -534,8 +534,8 @@ static ssize_t throttled_write(struct subscriber_t *sub, char *buf, ssize_t len)
}
}
- status = write(sub->fd, buf, (size_t)len);
- if (status == len )
+ status = write(sub->fd, buf, len);
+ if (status == (ssize_t)len)
return status;
else if (status > -1) {
gpsd_report(LOG_INF, "short write disconnecting client(%d)\n",
@@ -570,7 +570,7 @@ static void notify_watchers(struct gps_device_t *device, bool newstyle, char *se
struct subscriber_t *sub = channel->subscriber;
/*@-boolcompare@*/
if (channel->device==device && sub != NULL && (newstyle(sub) == newstyle))
- (void)throttled_write(sub, buf, (ssize_t)strlen(buf));
+ (void)throttled_write(sub, buf, strlen(buf));
/*@+boolcompare@*/
}
}
@@ -613,7 +613,7 @@ static void raw_hook(struct gps_data_t *ud,
/* copy raw NMEA sentences from GPS to clients in raw mode */
if (sub != NULL && channel->device != NULL &&
strcmp(ud->dev.path, channel->device->gpsdata.dev.path)==0)
- (void)throttled_write(sub, sentence, (ssize_t)len);
+ (void)throttled_write(sub, sentence, len);
}
}
diff --git a/gpsd.h-tail b/gpsd.h-tail
index eaf381b4..e3d00825 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -450,8 +450,8 @@ extern void gpsd_interpret_subframe(struct gps_device_t *, unsigned int[]);
extern int gpsd_hexdump_level;
extern /*@ observer @*/ char *gpsd_hexdump(/*@null@*/const void *, size_t);
extern /*@ observer @*/ char *gpsd_hexdump_wrapper(/*@null@*/const void *, size_t, int);
-extern int gpsd_hexpack(/*@in@*/char *, /*@out@*/char *, size_t);
-extern int hex2bin(char *);
+extern int gpsd_hexpack(/*@in@*/const char *, /*@out@*/char *, size_t);
+extern int hex2bin(const char *);
extern ssize_t hex_escapes(/*@out@*/char *cooked, const char *raw);
extern void ntpd_link_activate(struct gps_device_t *session);
extern char /*@observer@*/ *gpsd_id(/*@in@*/struct gps_device_t *);
diff --git a/gpsd_json.c b/gpsd_json.c
index cc9ac985..fe22835b 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -66,7 +66,7 @@ char *json_stringify(/*@out@*/char *to, size_t len, /*@in@*/const char *from)
return to;
}
-void json_version_dump(/*@out*/char *reply, size_t replylen)
+void json_version_dump(/*@out@*/char *reply, size_t replylen)
{
(void)snprintf(reply, replylen,
"{\"class\":\"VERSION\",\"release\":\"" VERSION "\",\"rev\":\"$Id: gpsd.c 5957 2009-08-23 15:45:54Z esr $\",\"api_major\":%d,\"api_minor\":%d}\r\n",
@@ -223,6 +223,7 @@ int json_device_read(const char *buf,
struct devconfig_t *dev, const char **endptr)
{
char serialmode[4];
+ /*@ -fullinitblock @*/
const struct json_attr_t json_attrs_device[] = {
{"class", check, .dflt.check = "DEVICE"},
@@ -248,6 +249,7 @@ int json_device_read(const char *buf,
.dflt.real = NAN},
{NULL},
};
+ /*@ +fullinitblock @*/
int status;
status = json_read_object(buf, json_attrs_device, endptr);
@@ -313,6 +315,7 @@ int json_watch_read(const char *buf,
const char **endptr)
{
int intcasoc;
+ /*@ -fullinitblock @*/
struct json_attr_t chanconfig_attrs[] = {
{"enable", boolean, .addr.boolean = &ccp->watcher,
.dflt.boolean = true},
@@ -323,6 +326,7 @@ int json_watch_read(const char *buf,
{"scaled", boolean, .addr.boolean = &ccp->scaled},
{NULL},
};
+ /*@ +fullinitblock @*/
int status;
status = json_read_object(buf, chanconfig_attrs, endptr);
diff --git a/gpsdclient.h b/gpsdclient.h
index 63fe0f16..fb3fe0c5 100644
--- a/gpsdclient.h
+++ b/gpsdclient.h
@@ -9,7 +9,7 @@ struct fixsource_t
char *spec; /* pointer to actual storage */
char *server;
char *port;
- char *device;
+ /*@null@*/char *device;
};
enum unit {unspecified, imperial, nautical, metric};
diff --git a/hex.c b/hex.c
index 97192c5b..41afcf17 100644
--- a/hex.c
+++ b/hex.c
@@ -52,7 +52,7 @@ char /*@ observer @*/ *gpsd_hexdump(const void *binbuf, size_t binbuflen)
return hexbuf;
}
-int gpsd_hexpack(char *src, char *dst, size_t len){
+int gpsd_hexpack(/*@in@*/const char *src, /*@out@*/char *dst, size_t len){
/* hex2bin source string to destination - destination can be same as source */
int i, k, l;
@@ -72,7 +72,7 @@ int gpsd_hexpack(char *src, char *dst, size_t len){
}
/*@ +charint -shiftimplementation @*/
-int hex2bin(char *s)
+int hex2bin(const char *s)
{
int a, b;
diff --git a/json.c b/json.c
index 6ce3010e..923ddd05 100644
--- a/json.c
+++ b/json.c
@@ -63,7 +63,7 @@ has to be inline in the struct.
#endif /* JSONDEBUG */
static char *json_target_address(const struct json_attr_t *cursor,
- const struct json_array_t *parent,
+ /*@null@*/const struct json_array_t *parent,
int offset)
{
if (parent == NULL || parent->element_type != structobject) {
@@ -91,7 +91,11 @@ static char *json_target_address(const struct json_attr_t *cursor,
return parent->arr.objects.base + (offset * parent->arr.objects.stride) + cursor->addr.offset;
}
-static int json_internal_read_object(const char *cp, const struct json_attr_t *attrs, const struct json_array_t *parent, int offset, const char **end)
+static int json_internal_read_object(const char *cp,
+ const struct json_attr_t *attrs,
+ const struct json_array_t *parent,
+ int offset,
+ /*@null@*/const char **end)
{
enum {init, await_attr, in_attr, await_value,
in_val_string, in_escape, in_val_token, post_val} state = 0;
@@ -448,7 +452,9 @@ breakout:
return 0;
}
-int json_read_object(const char *cp, const struct json_attr_t *attrs, const char **end)
+int json_read_object(const char *cp,
+ const struct json_attr_t *attrs,
+ /*@null@*/const char **end)
{
return json_internal_read_object(cp, attrs, NULL, 0, end);
}
diff --git a/json.h b/json.h
index 8ba5c1a2..69d48d94 100644
--- a/json.h
+++ b/json.h
@@ -60,8 +60,8 @@ struct json_attr_t {
#define JSON_ATTR_MAX 31 /* max chars in JSON attribute name */
#define JSON_VAL_MAX 120 /* max chars in JSON value part */
-int json_read_object(const char *, const struct json_attr_t *, const char **);
-int json_read_array(const char *, const struct json_array_t *, const char **);
+int json_read_object(const char *, const struct json_attr_t *, /*@null@*/const char **);
+int json_read_array(const char *, const struct json_array_t *, /*@null@*/const char **);
const /*@observer@*/char *json_error_string(int);
#define JSON_ERR_OBSTART 1 /* non-WS when expecting object start */
diff --git a/libgps_json.c b/libgps_json.c
index f57e72db..608a490b 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -20,7 +20,8 @@ representations to libgps structures.
#include "gps_json.h"
static int json_tpv_read(const char *buf,
- struct gps_data_t *gpsdata, const char **endptr)
+ struct gps_data_t *gpsdata,
+ /*@null@*/const char **endptr)
{
int status;
/*@ -fullinitblock @*/
@@ -102,7 +103,8 @@ static int json_tpv_read(const char *buf,
}
static int json_sky_read(const char *buf,
- struct gps_data_t *gpsdata, const char **endptr)
+ struct gps_data_t *gpsdata,
+ /*@null@*/const char **endptr)
{
bool usedflags[MAXCHANNELS];
/*@ -fullinitblock @*/
@@ -149,7 +151,8 @@ static int json_sky_read(const char *buf,
}
static int json_devicelist_read(const char *buf,
- struct gps_data_t *gpsdata, const char **endptr)
+ struct gps_data_t *gpsdata,
+ /*@null@*/const char **endptr)
{
/*@ -fullinitblock @*/
const struct json_attr_t json_attrs_subdevices[] = {
@@ -197,7 +200,8 @@ static int json_devicelist_read(const char *buf,
}
static int json_version_read(const char *buf,
- struct gps_data_t *gpsdata, const char **endptr)
+ struct gps_data_t *gpsdata,
+ /*@null@*/const char **endptr)
{
/*@ -fullinitblock @*/
const struct json_attr_t json_attrs_version[] = {
@@ -223,7 +227,8 @@ static int json_version_read(const char *buf,
}
static int json_error_read(const char *buf,
- struct gps_data_t *gpsdata, const char **endptr)
+ struct gps_data_t *gpsdata,
+ /*@null@*/const char **endptr)
{
/*@ -fullinitblock @*/
const struct json_attr_t json_attrs_error[] = {
diff --git a/net_remotegpsd.c b/net_remotegpsd.c
index 53640a4c..53e08dcd 100644
--- a/net_remotegpsd.c
+++ b/net_remotegpsd.c
@@ -40,9 +40,9 @@ static int remotegpsd_device_probe(const char *host,
gpsd_report(LOG_WARN, "remotegpsd device probe write error %d\n", dsock);
return -1;
}
- ret = read(dsock, buf, sizeof(buf));
+ ret = (int)read(dsock, buf, sizeof(buf));
(void)close(dsock);
- if (strlen(devpath) && (NULL == strstr(buf, devpath)))
+ if (strlen(devpath) > 0 && (NULL == strstr(buf, devpath)))
return 1;
else
return 0;