diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-09-30 06:30:42 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-09-30 06:30:42 -0400 |
commit | 34f69cc5d21caffe643a7faa9c045979a40cc792 (patch) | |
tree | ca21d9c3aa19c30b716c9253447c5e34f1b360e7 | |
parent | 82cd8cd019dec313938cba222871d32dbe5d449b (diff) | |
download | gpsd-34f69cc5d21caffe643a7faa9c045979a40cc792.tar.gz |
Magic-number elimination.
All three exports work.
-rw-r--r-- | libgps.h | 3 | ||||
-rw-r--r-- | libgps_core.c | 4 | ||||
-rw-r--r-- | libgps_dbus.c | 4 | ||||
-rw-r--r-- | libgps_shm.c | 4 |
4 files changed, 9 insertions, 6 deletions
@@ -23,6 +23,9 @@ enum export_t { #endif /* DBUS_EXPORT_ENABLE */ }; +/* values to poke in the gps_fd member if we get it via something special */ +#define SHM_PSEUDO_FD -1 +#define DBUS_PSEUDO_FD -2 extern int gps_sock_open(/*@null@*/const char *, /*@null@*/const char *, /*@out@*/struct gps_data_t *); diff --git a/libgps_core.c b/libgps_core.c index e6c85824..25600ea3 100644 --- a/libgps_core.c +++ b/libgps_core.c @@ -217,11 +217,11 @@ int gps_mainloop(struct gps_data_t *gpsdata, int timeout, /*@ -usedef -compdef -uniondef @*/ #ifdef SHM_EXPORT_ENABLE - if ((intptr_t)(gpsdata->gps_fd) == -1) + if ((intptr_t)(gpsdata->gps_fd) == SHM_PSEUDO_FD) status = gps_shm_mainloop(gpsdata, timeout, hook); #endif /* SHM_EXPORT_ENABLE */ #ifdef DBUS_EXPORT_ENABLE - if ((intptr_t)(gpsdata->gps_fd) == -2) + if ((intptr_t)(gpsdata->gps_fd) == DBUS_PSEUDO_FD) status = gps_dbus_mainloop(gpsdata, timeout, hook); #endif /* DBUS_EXPORT_ENABLE */ #ifdef SOCKET_EXPORT_ENABLE diff --git a/libgps_dbus.c b/libgps_dbus.c index c35afad1..79bddced 100644 --- a/libgps_dbus.c +++ b/libgps_dbus.c @@ -125,9 +125,9 @@ int gps_dbus_open(struct gps_data_t *gpsdata) } #ifndef USE_QT - gpsdata->gps_fd = -2; + gpsdata->gps_fd = DBUS_PSEUDO_FD; #else - gpsdata->gps_fd = (void *)(intptr_t)-2; + gpsdata->gps_fd = (void *)(intptr_t)DBUS_PSEUDO_FD; #endif /* USE_QT */ share_gpsdata = gpsdata; return 0; diff --git a/libgps_shm.c b/libgps_shm.c index 7704730a..4ba4d309 100644 --- a/libgps_shm.c +++ b/libgps_shm.c @@ -59,9 +59,9 @@ int gps_shm_open(/*@out@*/struct gps_data_t *gpsdata) return -2; } #ifndef USE_QT - gpsdata->gps_fd = -1; + gpsdata->gps_fd = SHM_PSEUDO_FD; #else - gpsdata->gps_fd = (void *)(intptr_t)-1; + gpsdata->gps_fd = (void *)(intptr_t)SHM_PSEUDO_FD; #endif /* USE_QT */ return 0; } |