summaryrefslogtreecommitdiff
path: root/gpsutils.c
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2019-03-20 11:50:55 -0700
committerFred Wright <fw@fwright.net>2019-03-20 11:50:55 -0700
commit91d64f90a5b891fc9e79b0f356747ebbef1d3b89 (patch)
treeb8ea7cc88f86672450821437d587d0f882b85e8e /gpsutils.c
parentd0cfd46c14b94f2c175c3aa116a5014f9e267a2b (diff)
downloadgpsd-91d64f90a5b891fc9e79b0f356747ebbef1d3b89.tar.gz
gpsutils: Fix unix_to_iso8601 NaN case.
Since the return type of unix_to_iso8601 is non-const, it's illegal to return a pointer to a string constant. Some compilers report a warning for this. The fix is to copy the string to the provided buffer. It would be nice to add a test case for this, but there doesn't seem to be any portable way to get NaN as a constant in C. TESTED: The warning is gone, and the tests still pass.
Diffstat (limited to 'gpsutils.c')
-rw-r--r--gpsutils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gpsutils.c b/gpsutils.c
index 3ae49e4d..d4a2a5fe 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -532,7 +532,7 @@ char *unix_to_iso8601(timestamp_t fixtime, char isotime[], size_t len)
char fractstr[10];
if (!isfinite(fixtime)) {
- return "NaN";
+ return strncpy(isotime, "NaN", len);
}
fractional = modf(fixtime, &integral);
/* snprintf rounding of %3f can get ugly, so pre-round */