From 0155fe9552c470754e1c1919d3cf7f7df90a21ff Mon Sep 17 00:00:00 2001 From: kcgen <1557255+kcgen@users.noreply.github.com> Date: Thu, 16 Sep 2021 08:34:02 -0700 Subject: [PATCH] Assert two always-true conditions --- loguru.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/loguru.cpp b/loguru.cpp index 8ded665..c629b89 100644 --- a/loguru.cpp +++ b/loguru.cpp @@ -1247,7 +1247,8 @@ namespace loguru if (out_buff_size == 0) { return; } out_buff[0] = '\0'; size_t pos = 0; - if (g_preamble_date && pos < out_buff_size) { + assert(pos < out_buff_size); + if (g_preamble_date) { int bytes = snprintf(out_buff + pos, out_buff_size - pos, "date "); if (bytes > 0) { pos += bytes; @@ -1324,8 +1325,8 @@ namespace loguru } size_t pos = 0; - - if (g_preamble_date && pos < out_buff_size) { + assert(pos < out_buff_size); + if (g_preamble_date) { int bytes = snprintf(out_buff + pos, out_buff_size - pos, "%04d-%02d-%02d ", 1900 + time_info.tm_year, 1 + time_info.tm_mon, time_info.tm_mday); if (bytes > 0) {