Page MenuHomeFreeBSD

vm_domainset: Print correct function in KASSERT()/panic()
ClosedPublic

Authored by olce on Jul 11 2025, 7:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 17, 10:08 AM
Unknown Object (File)
Wed, Oct 15, 8:32 PM
Unknown Object (File)
Sun, Oct 12, 5:13 PM
Unknown Object (File)
Sun, Oct 12, 12:20 PM
Unknown Object (File)
Sat, Oct 11, 5:12 AM
Unknown Object (File)
Sat, Oct 11, 5:12 AM
Unknown Object (File)
Sat, Oct 11, 5:12 AM
Unknown Object (File)
Sat, Oct 11, 5:12 AM
Subscribers

Details

Summary

Some messages in vm_domainset_iter_next() would wrongly refer to
vm_domainset_iter_first(). While here, ensure that all assertion/panic
messages use 'func' to avoid this discrepancy in the future if code
is moved/copy-pasted again.

Diff Detail

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

Event Timeline

olce requested review of this revision.Jul 11 2025, 7:00 AM
This revision is now accepted and ready to land.Jul 11 2025, 12:48 PM

bde was very much against func, on the basis that it makes harder to look for the corresponding literal string using grep or indexing.
That said, might be func should be consumed by KASSERT internals.

In D51248#1170503, @kib wrote:

bde was very much against func, on the basis that it makes harder to look for the corresponding literal string using grep or indexing.
That said, might be func should be consumed by KASSERT internals.

That prevention is somewhat understandable, but overall the argument looks weak. With the correct function name, you can immediately jump to the definition thanks to source code indexing (or, given our formatting convention for functions, a simple grep). Also, it is not too hard in general to make printed messages mostly unique, if that matters in some corner cases.

Personally, I find having the wrong function printed quite annoying and easily error-inducing when quickly browsing through code. So, on the contrary, I would advise using __func__ as the default, except on specific cases, and would support your idea of integrating __func__ into KASSERT().