Page MenuHomeFreeBSD

rpcgen: Const correctness for C23
ClosedPublic

Authored by ivy on Jul 27 2026, 10:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Sep 6, 1:10 AM
Unknown Object (File)
Sat, Sep 5, 9:54 AM
Unknown Object (File)
Tue, Sep 1, 11:29 PM
Unknown Object (File)
Fri, Aug 28, 11:33 PM
Unknown Object (File)
Fri, Aug 28, 11:30 PM
Unknown Object (File)
Sat, Aug 15, 6:44 PM
Unknown Object (File)
Tue, Aug 11, 10:38 AM
Unknown Object (File)
Tue, Aug 11, 12:16 AM
Subscribers

Details

Summary

On some platforms, e.g. Linux Clang 22.1.8 / glibc 2.43, strchr()
now implements the C23 behaviour where passing a const pointer to
strchr() also returns a const pointer. This breaks rpcgen during
the bootstrap build, since it assumes the return value is always
a mutable pointer.

For mkfile_output(), the pointed-to value is never modified, so
fix this by making the pointer const as well.

For open_log_file(), the current code modifies the supposedly const
value in-place to remove the filename suffix, which happens to work
but is wrong even in older versions of C. Change the code to use a
printf "%.*s" format specifier to strip the suffix instead.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75183
Build 72066: arc lint + arc unit

Event Timeline

ivy requested review of this revision.Jul 27 2026, 10:37 PM

Seems reasonable to me.

usr.bin/rpcgen/rpc_svcout.c
943

It seems a little odd to output anything for file names longer than PATH_MAX, but I guess the target could be have a different PATH_MAX build host.

This revision is now accepted and ready to land.Jul 28 2026, 1:54 PM
This revision was automatically updated to reflect the committed changes.