Page MenuHomeFreeBSD

dev_refthread: Do not initialize *ref when reference was not acquired
ClosedPublic

Authored by cem on Aug 24 2018, 7:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 3:10 AM
Unknown Object (File)
Jan 4 2024, 1:02 AM
Unknown Object (File)
Dec 22 2023, 10:57 PM
Unknown Object (File)
Dec 9 2023, 12:16 AM
Unknown Object (File)
Nov 25 2023, 9:42 PM
Unknown Object (File)
Nov 15 2023, 1:22 PM
Unknown Object (File)
Nov 15 2023, 12:23 AM
Unknown Object (File)
Nov 12 2023, 2:52 AM
Subscribers

Details

Summary

Like the companion API devvn_refthread, leave *ref uninitialized when a
reference was not acquired. Initializing to 1 provides a vaguely
correct-looking but bogus value for broken callers to (mistakenly) pass to
dev_relthread() when refthread fails.

Make it even more clear to consumers that dev_relthread is only valid when
dev_refthread succeeds.

Test Plan

I have some other changes I want to make in this area, but this is the only one
that changes API (slightly). I'll include the same reviewers on those future
patches as well.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I do not object but I must note that unconditional *ref = 1 looks strange to me. And since I am the author of that line, I believe that I added it that way for some reason which I cannot remember now. Most likely it was a compatibility issue with some third-party code. At least I looked at all in-tree callers and they looks fine.

This revision is now accepted and ready to land.Aug 24 2018, 8:06 PM
In D16885#359928, @kib wrote:

I do not object but I must note that unconditional *ref = 1 looks strange to me. And since I am the author of that line, I believe that I added it that way for some reason which I cannot remember now. Most likely it was a compatibility issue with some third-party code. At least I looked at all in-tree callers and they looks fine.

Maybe the atomic_add_long was in a different place at the time. I did not investigate history thoroughly. Thanks for the quick review!

This revision was automatically updated to reflect the committed changes.