diff options
author | Zbigniew Chyla <zbigniew.chyla@nokia.com> | 2015-04-24 17:46:49 +0200 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-04-28 08:25:03 -0400 |
commit | d1965788249d7e22cdde4021d452cf0dc6c6b9bd (patch) | |
tree | f643affa49296021751ab98d1420c9d2a1edb16f | |
parent | 9db980e35547d00c17064ab95ec0986bb2b86081 (diff) | |
download | gpsd-d1965788249d7e22cdde4021d452cf0dc6c6b9bd.tar.gz |
Copy structs using assignment, not memcpy().
-rw-r--r-- | gps2udp.c | 2 | ||||
-rw-r--r-- | gpsctl.c | 4 | ||||
-rw-r--r-- | gpsd.c | 2 | ||||
-rw-r--r-- | libgps_shm.c | 8 | ||||
-rw-r--r-- | libgpsd_core.c | 4 | ||||
-rw-r--r-- | ntpshmread.c | 2 | ||||
-rw-r--r-- | serial.c | 3 |
7 files changed, 9 insertions, 16 deletions
@@ -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; - memcpy(&fds, &master, sizeof(fd_set)); + fds = master; result = select(gpsdata.gps_fd+1, &fds, NULL, NULL, &tv); switch (result) @@ -400,9 +400,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); devicelist_entry_matches:; } - (void)memcpy(&gpsdata.dev, - &gpsdata.devices.list[i], - sizeof(struct devconfig_t)); + gpsdata.dev = gpsdata.devices.list[i]; devcount = gpsdata.devices.ndevices; /* if the device has not identified, watch it until it does so */ @@ -1747,7 +1747,7 @@ static void netgnss_autoconnect(struct gps_context_t *context, && (tp == NULL || hold.dist > tp->dist)) tp = sp; if (tp != NULL) - memcpy(tp, &hold, sizeof(struct dgps_server_t)); + *tp = hold; } } (void)fclose(sfp); diff --git a/libgps_shm.c b/libgps_shm.c index 34de8efa..d32add79 100644 --- a/libgps_shm.c +++ b/libgps_shm.c @@ -119,18 +119,14 @@ int gps_shm_read(struct gps_data_t *gpsdata) */ before = shared->bookend1; memory_barrier(); - (void)memcpy((void *)&noclobber, - (void *)&shared->gpsdata, - sizeof(struct gps_data_t)); + noclobber = shared->gpsdata; memory_barrier(); after = shared->bookend2; if (before != after) return 0; else { - (void)memcpy((void *)gpsdata, - (void *)&noclobber, - sizeof(struct gps_data_t)); + *gpsdata = noclobber; 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 c6ced73d..4c877aa9 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) - (void)memcpy(oldfix, fix, sizeof(struct gps_fix_t)); + *oldfix = *fix; } #endif /* NOFLOATS_ENABLE */ @@ -999,7 +999,7 @@ int gpsd_await_data(fd_set *rfds, int status; FD_ZERO(efds); - (void)memcpy((char *)rfds, (char *)all_fds, sizeof(fd_set)); + *rfds = *all_fds; 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 c75410be..498b78ee 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(); - memcpy((void *)&shmcopy, (void *)shm, sizeof(struct shmTime)); + shmcopy = *shm; /* * An update consumer such as ntpd should zero the valid flag at this point. @@ -542,8 +542,7 @@ 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; - (void)memcpy(&session->ttyset, - &session->ttyset_old, sizeof(session->ttyset)); + session->ttyset = session->ttyset_old; memset(session->ttyset.c_cc, 0, sizeof(session->ttyset.c_cc)); //session->ttyset.c_cc[VTIME] = 1; /* |