From: Andreas Ă–man Date: Fri, 19 Oct 2012 08:50:22 +0000 (+0200) Subject: Don't have code with side effects in assert() X-Git-Tag: v3.5~326 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd52d7c2169f85b7bbfface42bff8f451d8f9929;p=thirdparty%2Ftvheadend.git Don't have code with side effects in assert() Including code with side effects in assert() is bad because it won't be executed if compiled with NDEBUG --- diff --git a/src/dvb/dvb_adapter.c b/src/dvb/dvb_adapter.c index f58eb1b54..e4973be33 100644 --- a/src/dvb/dvb_adapter.c +++ b/src/dvb/dvb_adapter.c @@ -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]);