The branch main has been updated by ziaee: URL: https://cgit.FreeBSD.org/src/commit/?id=93bc3d83a11a1dbebd264616d63af3dd32cc1c8c
commit 93bc3d83a11a1dbebd264616d63af3dd32cc1c8c Author: Ingo Schwarze <schwa...@usta.de> AuthorDate: 2025-08-25 22:58:48 +0000 Commit: Alexander Ziaee <zi...@freebsd.org> CommitDate: 2025-08-25 23:02:27 +0000 mandoc: Improve width calculation for GCC compat Avoid implicitly converting a potentially negative page offset to size_t and then back to int. While this was not a bug and the end result was portably correct, Alexander Ziaee@ privately reported to me that the GCC 14 in the FreeBSD Jenkins CI felt uneasy about it. For clarity and readability, rewrite the truncation statement to not mix signed and unsigned types, to not use explicit casts, and make handling of the lower and upper cutoff more similar to each other. Fixes: 6410c1b51637 (mandoc: vendor import of upstream at 2025-07-27) MFC after: 3 days Reported by: ivy Reviewed by: ivy Differential Revision: https://reviews.freebsd.org/D52127 --- contrib/mandoc/roff_term.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/mandoc/roff_term.c b/contrib/mandoc/roff_term.c index 8f95aa920790..85d2caeb2749 100644 --- a/contrib/mandoc/roff_term.c +++ b/contrib/mandoc/roff_term.c @@ -165,6 +165,7 @@ roff_term_pre_po(ROFF_TERM_ARGS) static int polast; /* Previously requested. */ static int po; /* Currently requested. */ static int pouse; /* Currently used. */ + int pomin; /* Minimum to be used. */ int pomax; /* Maximum to be used. */ int ponew; /* Newly requested. */ @@ -186,9 +187,9 @@ roff_term_pre_po(ROFF_TERM_ARGS) po = ponew; /* Truncate to the range [-offset, 60], remember, and apply it. */ + pomin = -p->tcol->offset; pomax = term_len(p, 60); - pouse = po >= pomax ? pomax : - po < -(int)p->tcol->offset ? -p->tcol->offset : po; + pouse = po > pomax ? pomax : po < pomin ? pomin : po; p->tcol->offset += pouse; }