From 75d16ca647b14ba9c60565e70920460ecd72d6c1 Mon Sep 17 00:00:00 2001 From: Fred Wright Date: Wed, 7 Mar 2018 17:00:34 -0800 Subject: 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. --- cgps.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cgps.c') 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') -- cgit v1.2.1