From: Amos Jeffries Date: Mon, 4 Feb 2013 04:35:07 +0000 (-0700) Subject: Remove goto from daemon: logging module X-Git-Tag: SQUID_3_4_0_1~314 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98f484af2ccb23f3de02621475d0300f1fade323;p=thirdparty%2Fsquid.git Remove goto from daemon: logging module Also, this should remove a false-positive issue detected by Coverity Scan Issue 740453. --- diff --git a/src/log/ModDaemon.cc b/src/log/ModDaemon.cc index b89f46b47d..e9fbd8f0e8 100644 --- a/src/log/ModDaemon.cc +++ b/src/log/ModDaemon.cc @@ -113,26 +113,29 @@ logfileFreeBuffer(Logfile * lf, logfile_buffer_t * b) static void logfileHandleWrite(int fd, void *data) { - Logfile *lf = (Logfile *) data; - l_daemon_t *ll = (l_daemon_t *) lf->data; - int ret; - logfile_buffer_t *b; + Logfile *lf = static_cast(data); + l_daemon_t *ll = static_cast(lf->data); /* * We'll try writing the first entry until its done - if we * get a partial write then we'll re-schedule until its completed. * Its naive but it'll do for now. */ - b = static_cast(ll->bufs.head->data); + if (!ll->bufs.head) // abort if there is nothing pending right now. + return; + + logfile_buffer_t *b = static_cast(ll->bufs.head->data); assert(b != NULL); ll->flush_pending = 0; - ret = FD_WRITE_METHOD(ll->wfd, b->buf + b->written_len, b->len - b->written_len); - debugs(50, 3, "logfileHandleWrite: " << lf->path << ": write returned " << ret); + int ret = FD_WRITE_METHOD(ll->wfd, b->buf + b->written_len, b->len - b->written_len); + debugs(50, 3, lf->path << ": write returned " << ret); if (ret < 0) { if (ignoreErrno(errno)) { /* something temporary */ - goto reschedule; + Comm::SetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0); + ll->flush_pending = 1; + return; } debugs(50, DBG_IMPORTANT,"logfileHandleWrite: " << lf->path << ": error writing (" << xstrerror() << ")"); /* XXX should handle this better */ @@ -153,15 +156,12 @@ logfileHandleWrite(int fd, void *data) b = NULL; } /* Is there more to write? */ - if (ll->bufs.head == NULL) { - goto finish; - } + if (!ll->bufs.head) + return; /* there is, so schedule more */ -reschedule: Comm::SetSelect(ll->wfd, COMM_SELECT_WRITE, logfileHandleWrite, lf, 0); ll->flush_pending = 1; -finish: return; }