diff options
author | Fred Wright <fw@fwright.net> | 2019-03-20 11:50:55 -0700 |
---|---|---|
committer | Fred Wright <fw@fwright.net> | 2019-03-20 11:50:55 -0700 |
commit | 91d64f90a5b891fc9e79b0f356747ebbef1d3b89 (patch) | |
tree | b8ea7cc88f86672450821437d587d0f882b85e8e /gpsutils.c | |
parent | d0cfd46c14b94f2c175c3aa116a5014f9e267a2b (diff) | |
download | gpsd-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 */ |