]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Don't have code with side effects in assert()
authorAndreas Öman <andreas@lonelycoder.com>
Fri, 19 Oct 2012 08:50:22 +0000 (10:50 +0200)
committerAndreas Öman <andreas@lonelycoder.com>
Thu, 25 Oct 2012 11:06:05 +0000 (13:06 +0200)
Including code with side effects in assert() is bad because
it won't be executed if compiled with NDEBUG

src/dvb/dvb_adapter.c

index f58eb1b54185abe2e0b5b40ebb9933b9b962ad61..e4973be33eb17c7c275a81cbb915508359381faf 100644 (file)
@@ -498,7 +498,9 @@ dvb_adapter_start ( th_dvb_adapter_t *tda )
 
   /* Start DVR thread */
   if (tda->tda_dvr_pipe[0] == -1) {
-    assert(pipe(tda->tda_dvr_pipe) != -1);
+    int err = pipe(tda->tda_dvr_pipe);
+    assert(err != -1);
+
     fcntl(tda->tda_dvr_pipe[0], F_SETFD, fcntl(tda->tda_dvr_pipe[0], F_GETFD) | FD_CLOEXEC);
     fcntl(tda->tda_dvr_pipe[0], F_SETFL, fcntl(tda->tda_dvr_pipe[0], F_GETFL) | O_NONBLOCK);
     fcntl(tda->tda_dvr_pipe[1], F_SETFD, fcntl(tda->tda_dvr_pipe[1], F_GETFD) | FD_CLOEXEC);
@@ -526,7 +528,8 @@ dvb_adapter_stop ( th_dvb_adapter_t *tda )
   /* Stop DVR thread */
   if (tda->tda_dvr_pipe[0] != -1) {
     tvhlog(LOG_DEBUG, "dvb", "%s stopping thread", tda->tda_rootpath);
-    assert(write(tda->tda_dvr_pipe[1], "", 1) == 1);
+    int err = write(tda->tda_dvr_pipe[1], "", 1);
+    assert(err != -1);
     pthread_join(tda->tda_dvr_thread, NULL);
     close(tda->tda_dvr_pipe[0]);
     close(tda->tda_dvr_pipe[1]);