From 18d76d6bda59a9eb0a3f062fac91f481babcbdf4 Mon Sep 17 00:00:00 2001 From: Zbigniew Chyla Date: Wed, 7 Jan 2015 11:04:00 +0100 Subject: Always use sizeof to get array size Don't use constant/expression from an array's definition when referring to its size. Eliminates redundancy and avoids problems when array size changes. The change doesn't affect generated code. --- libgps_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libgps_core.c') diff --git a/libgps_core.c b/libgps_core.c index 9baeefd4..64bce379 100644 --- a/libgps_core.c +++ b/libgps_core.c @@ -40,7 +40,7 @@ void libgps_trace(int errlevel, const char *fmt, ...) char buf[BUFSIZ]; va_list ap; - (void)strlcpy(buf, "libgps: ", BUFSIZ); + (void)strlcpy(buf, "libgps: ", sizeof(buf)); va_start(ap, fmt); (void)vsnprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), fmt, ap); @@ -178,7 +178,7 @@ int gps_send(struct gps_data_t *gpsdata CONDITIONALLY_UNUSED, const char *fmt CO (void)vsnprintf(buf, sizeof(buf) - 2, fmt, ap); va_end(ap); if (buf[strlen(buf) - 1] != '\n') - (void)strlcat(buf, "\n", BUFSIZ); + (void)strlcat(buf, "\n", sizeof(buf)); #ifdef SOCKET_EXPORT_ENABLE status = gps_sock_send(gpsdata, buf); -- cgit v1.2.1