Page MenuHomeFreeBSD

rpcgen: Const correctness for C23
ClosedPublic

Authored by ivy on Mon, Jul 27, 10:37 PM.
Tags
None
Referenced Files
F164713473: D58489.id182851.diff
Mon, Aug 3, 7:45 AM
Unknown Object (File)
Sun, Aug 2, 10:34 PM
Unknown Object (File)
Sat, Aug 1, 9:38 PM
Unknown Object (File)
Sat, Aug 1, 11:18 AM
Unknown Object (File)
Fri, Jul 31, 6:46 AM
Unknown Object (File)
Fri, Jul 31, 6:25 AM
Unknown Object (File)
Fri, Jul 31, 2:33 AM
Unknown Object (File)
Thu, Jul 30, 10:53 PM
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.