Page MenuHomeFreeBSD

rpcgen: Const correctness for C23
ClosedPublic

Authored by ivy on Mon, Jul 27, 10:37 PM.
Tags
None
Referenced Files
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
Unknown Object (File)
Mon, Aug 10, 5:34 PM
Unknown Object (File)
Sun, Aug 9, 8:27 AM
Unknown Object (File)
Sat, Aug 8, 6:53 PM
Unknown Object (File)
Sat, Aug 8, 5:59 PM
Unknown Object (File)
Sat, Aug 8, 9:21 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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

ivy requested review of this revision.Mon, Jul 27, 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.Tue, Jul 28, 1:54 PM
This revision was automatically updated to reflect the committed changes.