summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Chyla <zbigniew@chyla.pl>2015-01-07 11:04:00 +0100
committerEric S. Raymond <esr@thyrsus.com>2015-01-07 22:30:23 -0500
commit1613b18bcf6e2b57977c10e18a4878adad6dc322 (patch)
tree391548e7dab4a7f822d0619ad0045e92bd8cfcbd
parent34b78ec3eb216221aff61f6f041f3aea8d6ffd65 (diff)
downloadgpsd-1613b18bcf6e2b57977c10e18a4878adad6dc322.tar.gz
Move side effects out of assert()
-rw-r--r--gpsd.h-tail6
-rw-r--r--gpsmon.c5
2 files changed, 8 insertions, 3 deletions
diff --git a/gpsd.h-tail b/gpsd.h-tail
index db25ca96..987ec768 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -1041,7 +1041,11 @@ void cfmakeraw(struct termios *);
#define DEVICEHOOKPATH "/"SYSCONFDIR"/gpsd/device-hook"
/* Needed because 4.x versions of GCC are really annoying */
-#define ignore_return(funcall) assert(funcall != -23)
+#define ignore_return(funcall) \
+ do { \
+ ssize_t result = (funcall); \
+ assert(result != -23); \
+ } while (0)
static /*@unused@*/ inline void memory_barrier(void)
{
diff --git a/gpsmon.c b/gpsmon.c
index a5ee0b2a..ab6da9fb 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -726,9 +726,10 @@ static void gpsmon_hook(struct gps_device_t *device, gps_mask_t changed UNUSED)
if (logfile != NULL && device->lexer.outbuflen > 0) {
/*@ -shiftimplementation -sefparams +charint @*/
- assert(fwrite
+ size_t written_count = fwrite
(device->lexer.outbuffer, sizeof(char),
- device->lexer.outbuflen, logfile) >= 1);
+ device->lexer.outbuflen, logfile);
+ assert(written_count >= 1);
/*@ +shiftimplementation +sefparams -charint @*/
}