From 3230c766b2db1550d5c4d7669f11c1a69d75bc86 Mon Sep 17 00:00:00 2001 From: Michael Tatarinov Date: Fri, 30 Sep 2011 06:47:10 -0400 Subject: Remove duplicate code. Signed-off-by: Eric S. Raymond --- gpxlogger.c | 7 ------- libgps.h | 1 + libgps_core.c | 4 +++- libgps_dbus.c | 1 - libgps_shm.c | 1 - libgps_sock.c | 1 - 6 files changed, 4 insertions(+), 11 deletions(-) diff --git a/gpxlogger.c b/gpxlogger.c index c46df2ff..2576a847 100644 --- a/gpxlogger.c +++ b/gpxlogger.c @@ -294,12 +294,6 @@ int main(int argc, char **argv) source.server, source.port, source.device); #endif - /* initializes the gpsdata fields */ - gpsdata.status = STATUS_NO_FIX; - gpsdata.satellites_used = 0; - gps_clear_fix(&(gpsdata.fix)); - gps_clear_dop(&(gpsdata.dop)); - /* catch all interesting signals */ (void)signal(SIGTERM, quit_handler); (void)signal(SIGQUIT, quit_handler); @@ -316,7 +310,6 @@ int main(int argc, char **argv) //syslog (LOG_INFO, "---------- STARTED ----------"); - /* initialize for some export method */ if (gps_open(source.server, source.port, &gpsdata) != 0) { (void)fprintf(stderr, "%s: no gpsd running or network error: %d, %s\n", diff --git a/libgps.h b/libgps.h index fb26ac2c..5901ea89 100644 --- a/libgps.h +++ b/libgps.h @@ -48,5 +48,6 @@ extern int gps_dbus_open(struct gps_data_t *); extern int gps_dbus_mainloop(struct gps_data_t *, int, void (*)(struct gps_data_t *)); +#define PRIVATE(gpsdata) ((struct privdata_t *)(gpsdata)->privdata) #endif /* _GPSD_LIBGPS_H_ */ diff --git a/libgps_core.c b/libgps_core.c index f8edff46..1759e6a5 100644 --- a/libgps_core.c +++ b/libgps_core.c @@ -94,7 +94,9 @@ int gps_open(/*@null@*/const char *host, gpsdata->set = 0; gpsdata->status = STATUS_NO_FIX; - gps_clear_fix(&gpsdata->fix); + gpsdata->satellites_used = 0; + gps_clear_fix(&(gpsdata->fix)); + gps_clear_dop(&(gpsdata->dop)); return status; /*@ +branchstate +compdef @*/ diff --git a/libgps_dbus.c b/libgps_dbus.c index 79bddced..4a6e2f71 100644 --- a/libgps_dbus.c +++ b/libgps_dbus.c @@ -22,7 +22,6 @@ struct privdata_t { void (*handler)(struct gps_data_t *); }; -#define PRIVATE(gpsdata) ((struct privdata_t *)(gpsdata)->privdata) #include #include diff --git a/libgps_shm.c b/libgps_shm.c index 4ba4d309..b28b13a7 100644 --- a/libgps_shm.c +++ b/libgps_shm.c @@ -33,7 +33,6 @@ struct privdata_t void *shmseg; }; /*@+matchfields@*/ -#define PRIVATE(gpsdata) ((struct privdata_t *)(gpsdata)->privdata) int gps_shm_open(/*@out@*/struct gps_data_t *gpsdata) diff --git a/libgps_sock.c b/libgps_sock.c index 7a34a75b..04796850 100644 --- a/libgps_sock.c +++ b/libgps_sock.c @@ -51,7 +51,6 @@ struct privdata_t #endif /* LIBGPS_DEBUG */ }; /*@+matchfields@*/ -#define PRIVATE(gpsdata) ((struct privdata_t *)gpsdata->privdata) /*@-branchstate@*/ int gps_sock_open(/*@null@*/const char *host, /*@null@*/const char *port, -- cgit v1.2.1