Page MenuHomeFreeBSD

mandoc: Improve width calculation for GCC compat
ClosedPublic

Authored by ziaee on Aug 22 2025, 5:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 22, 3:54 AM
Unknown Object (File)
Fri, Oct 10, 11:59 PM
Unknown Object (File)
Fri, Oct 10, 11:59 PM
Unknown Object (File)
Fri, Oct 10, 11:59 PM
Unknown Object (File)
Fri, Oct 10, 5:34 PM
Unknown Object (File)
Tue, Sep 23, 10:19 PM
Unknown Object (File)
Tue, Sep 23, 1:50 PM
Unknown Object (File)
Sep 17 2025, 2:15 AM
Subscribers
None

Details

Summary

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)
Reported by: Ivy

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ziaee requested review of this revision.Aug 22 2025, 5:26 PM
ziaee created this revision.

It says authored by Ziaee but Ingo Shwarze (the upstream mandoc maintainer) wrote this, although I did type it by hand because I didn't understand the diff format he sent me ^.^ The commit message is as he sent it, except they don't use titles or trailers so I made those up.

the change looks fine assuming you tested it with the gcc build.

the commit message is a little odd since it reads like you reported the issue to yourself, and doesn't say who "me" is. you might want to reword it to just describe the fix. (i would suggest including Obtained from:, except i don't see this commit in the mandoc CVS repository.)

also, "ivy" is written in lower case :-)

This revision is now accepted and ready to land.Aug 23 2025, 12:47 AM