summaryrefslogtreecommitdiff
path: root/cgps.c
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2018-03-07 17:00:34 -0800
committerFred Wright <fw@fwright.net>2018-03-07 17:29:26 -0800
commit75d16ca647b14ba9c60565e70920460ecd72d6c1 (patch)
treeea92a4ae90b16388751c6ae61031082826216f1f /cgps.c
parent89251b800ff837233fca9318854380c2cf7a2138 (diff)
downloadgpsd-75d16ca647b14ba9c60565e70920460ecd72d6c1.tar.gz
cgps: fixes compiler warning.
The fix to avoid writing into a read-only buffer copies a const char pointer to a non-const char pointer, provoking a warning. For some reason, the old code failed to get a similar warning from the cast, which would have caught the original bug. This fix just adds a const char variable to accept the pointer. TESTED: Now cgps builds without warning, and still works.
Diffstat (limited to 'cgps.c')
-rw-r--r--cgps.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/cgps.c b/cgps.c
index 85e42414..7790d134 100644
--- a/cgps.c
+++ b/cgps.c
@@ -713,11 +713,12 @@ static void update_gps_panel(struct gps_data_t *gpsdata)
if ( raw_flag) {
/* Be quiet if the user requests silence. */
- if (!silent_flag && (s = gps_data(gpsdata)) != NULL) {
+ const char *sr;
+ if (!silent_flag && (sr = gps_data(gpsdata)) != NULL) {
char *p, *pe;
/* make a copy of the const char *, then trim trailing spaces */
- p = strdup(s);
+ p = strdup(sr);
if ( NULL != p ) {
pe = p + strlen(p);
for ( ; --pe > p && isspace((int) *pe); *pe = '\0')