summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-04-28 18:07:54 -0700
committerGary E. Miller <gem@rellim.com>2015-04-28 18:09:29 -0700
commit838d9fefa4bef2469cf2c6e8ec908e949215d8ee (patch)
tree31959f15be5eb75e83585c0d86ce566fd4040cf0
parent8559faf6866ec954fde105c32e4b07cb69bba64b (diff)
downloadgpsd-838d9fefa4bef2469cf2c6e8ec908e949215d8ee.tar.gz
Revert "Copy structs using assignment, not memcpy()."
This reverts commit d1965788249d7e22cdde4021d452cf0dc6c6b9bd. This breaks my build on Gentoo running gcc 4.9.2 libgps_shm.c: In function 'int gps_shm_read(gps_data_t*)': libgps_shm.c:122:12: error: no match for 'operator=' (operand types are 'gps_data_t' and 'volatile gps_data_t') noclobber = shared->gpsdata; ^ libgps_shm.c:122:12: note: candidate is: In file included from gpsd.h:350:0, from libgps_shm.c:30: gps.h:1918:8: note: gps_data_t& gps_data_t::operator=(const gps_data_t&) struct gps_data_t { ^ gps.h:1918:8: note: no known conversion for argument 1 from 'volatile gps_data_t' to 'const gps_data_t&'
-rw-r--r--gps2udp.c2
-rw-r--r--gpsctl.c4
-rw-r--r--gpsd.c2
-rw-r--r--libgps_shm.c8
-rw-r--r--libgpsd_core.c4
-rw-r--r--ntpshmread.c2
-rw-r--r--serial.c3
7 files changed, 16 insertions, 9 deletions
diff --git a/gps2udp.c b/gps2udp.c
index e4f0ed4f..2bcb232d 100644
--- a/gps2udp.c
+++ b/gps2udp.c
@@ -240,7 +240,7 @@ static ssize_t read_gpsd(char *message, size_t len)
/* prepare for a blocking read with a 10s timeout */
tv.tv_sec = 10;
tv.tv_usec = 0;
- fds = master;
+ memcpy(&fds, &master, sizeof(fd_set));
result = select(gpsdata.gps_fd+1, &fds, NULL, NULL, &tv);
switch (result)
diff --git a/gpsctl.c b/gpsctl.c
index fc588123..655999ad 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -400,7 +400,9 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
devicelist_entry_matches:;
}
- gpsdata.dev = gpsdata.devices.list[i];
+ (void)memcpy(&gpsdata.dev,
+ &gpsdata.devices.list[i],
+ sizeof(struct devconfig_t));
devcount = gpsdata.devices.ndevices;
/* if the device has not identified, watch it until it does so */
diff --git a/gpsd.c b/gpsd.c
index 3154bfd7..ace2ed6c 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1747,7 +1747,7 @@ static void netgnss_autoconnect(struct gps_context_t *context,
&& (tp == NULL || hold.dist > tp->dist))
tp = sp;
if (tp != NULL)
- *tp = hold;
+ memcpy(tp, &hold, sizeof(struct dgps_server_t));
}
}
(void)fclose(sfp);
diff --git a/libgps_shm.c b/libgps_shm.c
index d32add79..34de8efa 100644
--- a/libgps_shm.c
+++ b/libgps_shm.c
@@ -119,14 +119,18 @@ int gps_shm_read(struct gps_data_t *gpsdata)
*/
before = shared->bookend1;
memory_barrier();
- noclobber = shared->gpsdata;
+ (void)memcpy((void *)&noclobber,
+ (void *)&shared->gpsdata,
+ sizeof(struct gps_data_t));
memory_barrier();
after = shared->bookend2;
if (before != after)
return 0;
else {
- *gpsdata = noclobber;
+ (void)memcpy((void *)gpsdata,
+ (void *)&noclobber,
+ sizeof(struct gps_data_t));
gpsdata->privdata = private_save;
PRIVATE(gpsdata)->tick = after;
if ((gpsdata->set & REPORT_IS)!=0) {
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 4c877aa9..c6ced73d 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -985,7 +985,7 @@ static void gpsd_error_model(struct gps_device_t *session,
/* save old fix for later error computations */
if (fix->mode >= MODE_2D)
- *oldfix = *fix;
+ (void)memcpy(oldfix, fix, sizeof(struct gps_fix_t));
}
#endif /* NOFLOATS_ENABLE */
@@ -999,7 +999,7 @@ int gpsd_await_data(fd_set *rfds,
int status;
FD_ZERO(efds);
- *rfds = *all_fds;
+ (void)memcpy((char *)rfds, (char *)all_fds, sizeof(fd_set));
gpsd_log(errout, LOG_RAW + 2, "select waits\n");
/*
* Poll for user commands or GPS data. The timeout doesn't
diff --git a/ntpshmread.c b/ntpshmread.c
index 498b78ee..c75410be 100644
--- a/ntpshmread.c
+++ b/ntpshmread.c
@@ -85,7 +85,7 @@ enum segstat_t ntp_read(struct shmTime *shm_in, struct shm_stat_t *shm_stat, con
* page size).
*/
memory_barrier();
- shmcopy = *shm;
+ memcpy((void *)&shmcopy, (void *)shm, sizeof(struct shmTime));
/*
* An update consumer such as ntpd should zero the valid flag at this point.
diff --git a/serial.c b/serial.c
index 4ae46bbb..29f14d17 100644
--- a/serial.c
+++ b/serial.c
@@ -542,7 +542,8 @@ int gpsd_serial_open(struct gps_device_t *session)
/* Save original terminal parameters */
if (tcgetattr(session->gpsdata.gps_fd, &session->ttyset_old) != 0)
return UNALLOCATED_FD;
- session->ttyset = session->ttyset_old;
+ (void)memcpy(&session->ttyset,
+ &session->ttyset_old, sizeof(session->ttyset));
memset(session->ttyset.c_cc, 0, sizeof(session->ttyset.c_cc));
//session->ttyset.c_cc[VTIME] = 1;
/*