diff options
author | Ian Bruene <ianbruene@gmail.com> | 2018-11-26 13:16:48 -0600 |
---|---|---|
committer | Ian Bruene <ianbruene@gmail.com> | 2018-11-26 13:16:48 -0600 |
commit | f258bb20c290e41fff4a74e08ad0e55304a3709a (patch) | |
tree | ae0ef4a046f3f9732422d186d1897cb706d4f5b8 | |
parent | 9e1b215838e3f8c0dc55d84d6d8fcdbfdf213b3b (diff) | |
download | gpsd-f258bb20c290e41fff4a74e08ad0e55304a3709a.tar.gz |
Removed variable length arrays, added -Wvla compiler option.vla-removal
-rw-r--r-- | SConstruct | 2 | ||||
-rw-r--r-- | driver_nmea2000.c | 2 | ||||
-rw-r--r-- | gpsmon.c | 2 | ||||
-rw-r--r-- | libgpsd_core.c | 6 | ||||
-rw-r--r-- | net_ntrip.c | 17 |
5 files changed, 13 insertions, 16 deletions
@@ -977,7 +977,7 @@ else: for option in ('-Wextra', '-Wall', '-Wno-uninitialized', '-Wno-missing-field-initializers', '-Wcast-align', '-Wmissing-declarations', - '-Wmissing-prototypes', + '-Wmissing-prototypes', "-Wvla", '-Wstrict-prototypes', '-Wpointer-arith', '-Wreturn-type'): if option not in config.env['CFLAGS']: config.CheckCompilerOption(option) diff --git a/driver_nmea2000.c b/driver_nmea2000.c index eb7b7d75..bab5c52c 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -1539,7 +1539,7 @@ static gps_mask_t nmea2000_parse_input(struct gps_device_t *session) int nmea2000_open(struct gps_device_t *session) { - char interface_name[strlen(session->gpsdata.dev.path)+1]; + char interface_name[GPS_PATH_MAX]; socket_t sock; int status; int unit_number; @@ -314,7 +314,7 @@ void monitor_fixframe(WINDOW * win) static void packet_dump(const char *buf, size_t buflen) { if (packetwin != NULL) { - char buf2[buflen * 2]; + char buf2[MAX_PACKET_LENGTH * 2]; cond_hexdump(buf2, buflen * 2, buf, buflen); (void)waddstr(packetwin, buf2); (void)waddch(packetwin, (chtype)'\n'); diff --git a/libgpsd_core.c b/libgpsd_core.c index b2ed639b..a752f10f 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -464,7 +464,7 @@ int gpsd_open(struct gps_device_t *session) return session->gpsdata.gps_fd; /* otherwise, could be an TCP data feed */ } else if (str_starts_with(session->gpsdata.dev.path, "tcp://")) { - char server[strlen(session->gpsdata.dev.path)+1], *port; + char server[GPS_PATH_MAX], *port; socket_t dsock; (void)strlcpy(server, session->gpsdata.dev.path + 6, sizeof(server)); INVALIDATE_SOCKET(session->gpsdata.gps_fd); @@ -491,7 +491,7 @@ int gpsd_open(struct gps_device_t *session) return session->gpsdata.gps_fd; /* or could be UDP */ } else if (str_starts_with(session->gpsdata.dev.path, "udp://")) { - char server[strlen(session->gpsdata.dev.path)+1], *port; + char server[GPS_PATH_MAX], *port; socket_t dsock; (void)strlcpy(server, session->gpsdata.dev.path + 6, sizeof(server)); INVALIDATE_SOCKET(session->gpsdata.gps_fd); @@ -520,7 +520,7 @@ int gpsd_open(struct gps_device_t *session) #endif /* NETFEED_ENABLE */ #ifdef PASSTHROUGH_ENABLE if (str_starts_with(session->gpsdata.dev.path, "gpsd://")) { - char server[strlen(session->gpsdata.dev.path)+1], *port; + char server[GPS_PATH_MAX], *port; socket_t dsock; (void)strlcpy(server, session->gpsdata.dev.path + 7, sizeof(server)); INVALIDATE_SOCKET(session->gpsdata.gps_fd); diff --git a/net_ntrip.c b/net_ntrip.c index 72f718e4..b10f34bb 100644 --- a/net_ntrip.c +++ b/net_ntrip.c @@ -457,8 +457,6 @@ int ntrip_open(struct gps_device_t *device, char *caster) char *stream = NULL; char *url = NULL; int ret = -1; - char t[strlen(caster) + 1]; - char *tmp = t; switch (device->ntrip.conn_state) { case ntrip_conn_init: @@ -467,14 +465,13 @@ int ntrip_open(struct gps_device_t *device, char *caster) device->ntrip.works = false; device->ntrip.sourcetable_parse = false; device->ntrip.stream.set = false; - (void)strlcpy(tmp, caster, sizeof(t)); - if ((amp = strchr(tmp, '@')) != NULL) { - if (((colon = strchr(tmp, ':')) != NULL) && colon < amp) { - auth = tmp; + if ((amp = strchr(caster, '@')) != NULL) { + if (((colon = strchr(caster, ':')) != NULL) && colon < amp) { + auth = caster; *amp = '\0'; - tmp = amp + 1; - url = tmp; + caster = amp + 1; + url = caster; } else { gpsd_log(&device->context->errout, LOG_ERROR, "can't extract user-ID and password from %s\n", @@ -483,7 +480,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) return -1; } } - if ((slash = strchr(tmp, '/')) != NULL) { + if ((slash = strchr(caster, '/')) != NULL) { *slash = '\0'; stream = slash + 1; } else { @@ -494,7 +491,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) device->ntrip.conn_state = ntrip_conn_err; return -1; } - if ((colon = strchr(tmp, ':')) != NULL) { + if ((colon = strchr(caster, ':')) != NULL) { port = colon + 1; *colon = '\0'; } |