From: Timo Sirainen Date: Sun, 1 Jul 2018 09:58:05 +0000 (+0300) Subject: lib: i_close_fd_path() - Replace assert with more descriptive panic X-Git-Tag: 2.3.9~1641 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71a93cf0f0db755dd6e9f8688f2ef460c68c756d;p=thirdparty%2Fdovecot%2Fcore.git lib: i_close_fd_path() - Replace assert with more descriptive panic Since this function can be called from so many places, it's easier to figure out the bug if the panic message contains what called it. --- diff --git a/src/lib/fd-util.c b/src/lib/fd-util.c index a57419fc62..45dcfcf2d9 100644 --- a/src/lib/fd-util.c +++ b/src/lib/fd-util.c @@ -140,7 +140,13 @@ void i_close_fd_path(int *fd, const char *path, const char *arg, if (*fd == -1) return; - i_assert(*fd > 0); + if (unlikely(*fd <= 0)) { + i_panic("%s: close(%s%s%s) @ %s:%d attempted with fd=%d", + func, arg, + (path == NULL) ? "" : " = ", + (path == NULL) ? "" : path, + file, line, *fd); + } saved_errno = errno; if (unlikely(close(*fd) < 0))