Thu, 13 Nov 2025 17:39:36 +0100
exclude almost impossible negative return values for snprintf() from code coverage
| src/printf.c | file | annotate | diff | comparison | revisions |
--- a/src/printf.c Tue Nov 11 18:47:48 2025 +0100 +++ b/src/printf.c Thu Nov 13 17:39:36 2025 +0100 @@ -61,8 +61,10 @@ va_copy(ap2, ap); int ret = vsnprintf(buf, CX_PRINTF_SBO_SIZE, fmt, ap); if (ret < 0) { + // LCOV_EXCL_START va_end(ap2); return ret; + // LCOV_EXCL_STOP } else if (ret < CX_PRINTF_SBO_SIZE) { va_end(ap2); return (int) wfc(buf, 1, ret, stream); @@ -121,8 +123,10 @@ if (s.ptr) { ret = vsnprintf(s.ptr, len, fmt, ap2); if (ret < 0) { + // LCOV_EXCL_START cxFree(a, s.ptr); s.ptr = NULL; + // LCOV_EXCL_STOP } else { s.length = (size_t) ret; } @@ -162,7 +166,7 @@ if (ptr) { int newret = vsnprintf(ptr, newlen, fmt, ap2); if (newret < 0) { - cxFree(alloc, ptr); + cxFree(alloc, ptr); // LCOV_EXCL_LINE } else { *len = newlen; *str = ptr; @@ -207,7 +211,7 @@ if (ptr) { int newret = vsnprintf(ptr, newlen, fmt, ap2); if (newret < 0) { - cxFree(alloc, ptr); + cxFree(alloc, ptr); // LCOV_EXCL_LINE } else { *len = newlen; *str = ptr;