Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Feb 2026 00:31:52 +0000
From:      Alexander Ziaee <ziaee@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        Ingo Schwarze <schwarze@usta.de>
Subject:   git: 0d066d216681 - stable/14 - mandoc: Improve width calculation for GCC compat
Message-ID:  <69853678.320ba.3018fe2d@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by ziaee:

URL: https://cgit.FreeBSD.org/src/commit/?id=0d066d21668172aa7fc9bc38f9a0725ae31f0deb

commit 0d066d21668172aa7fc9bc38f9a0725ae31f0deb
Author:     Ingo Schwarze <schwarze@usta.de>
AuthorDate: 2025-08-25 22:58:48 +0000
Commit:     Alexander Ziaee <ziaee@FreeBSD.org>
CommitDate: 2026-02-06 00:31:06 +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
    
    (cherry picked from commit 93bc3d83a11a1dbebd264616d63af3dd32cc1c8c)
---
 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;
 }
 


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69853678.320ba.3018fe2d>