DEVCLASS_GET_MAXUNIT(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… DEVCLASS_GET_MAXUNIT β€” kernel developer's manual, but make it make sense

okay bestie, so this is a page from the Kernel Developer's Manual, and the function we're stanning today is devclass_get_maxunit. it's giving "small function, big confusion" energy, but don't worry β€” we're gonna get through it together 🫢


✨ NAME ✨

devclass_get_maxunit β€” find the maximum unit number in the class πŸ”’


πŸŽ€ SYNOPSIS πŸŽ€

#include <sys/param.h>
#include <sys/bus.h>

int
devclass_get_maxunit(devclass_t dc);

so you include those two headers, and then you call it with a devclass_t dc. that's the whole vibe. πŸ¦‹


🌸 DESCRIPTION 🌸

okay so here's the tea β˜• β€” this function returns the next unit number to be allocated to device instances in the devclass.

and like, read that carefully bestie: it's one greater than the highest currently allocated unit. not the highest one, the one after the highest one. the way that's a whole plot twist, i know 😭


πŸ’– RETURN VALUES πŸ’–

  • if dc is NULL, it returns -1 πŸ™ˆ
  • otherwise, it returns the next unit number in dc's devclass ✨

🧚 ERRORS 🧚

None. literally none. not a single one. slay πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

go read those too, iykyk πŸ‘‘


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Doug Rabson. iconic behavior, thank you Doug 🫢


πŸ’€ BUGS πŸ’€

okay so the name is confusing, because it's actually one greater than the maximum unit 😭 like the naming committee really said "let's make it a little evil" and honestly? it's giving misleading. so just remember: it's not the max, it's max + 1. periodt. 🌈


ngl, this one's tiny but the name will absolutely trip you up if you don't read the BUGS section. so like… read it. please. for me. πŸŽ€

and that's the whole page, bestie! this one came from the Debian flavor of the Kernel Developer's Manual, dated September 10, 2010, and it's the DEVCLASS_GET_MAXUNIT(9) page β€” go forth and allocate responsibly πŸ’œβ­

πŸ“¦ where this page comes from