DEVICE_SET_DESC(9)

✨ DEVICE_SET_DESC ✨

okay bestie, this is a kernel developer's manual page for DEVICE_SET_DESC(9) β€” yes, section 9, we're in the deep kernel lore today 🫢


πŸ’– NAME πŸ’–

device_set_desc, device_set_desc_copy, device_get_desc β€” the trio that handles the description of a device ✨


πŸŽ€ SYNOPSIS πŸŽ€

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

void
device_set_desc(device_t dev, const char *desc);

void
device_set_desc_copy(device_t dev, const char *desc);

const char *
device_get_desc(device_t dev);

🌸 DESCRIPTION 🌸

So here's the vibe: these three functions manipulate the verbose description of a device. That's it, that's the whole job πŸ’…

That description β€” if it's present β€” gets printed as part of the message when the device is attached during autoconfiguration. So it's like the device's little name tag at the party πŸŽ‰

Now, the plot twist: device_set_desc_copy() is the variation you reach for when the string you're passing is a temporary buffer that's gonna get overwritten. In that case, the system copies the string for you. Otherwise β€” meaning with plain old device_set_desc() β€” the pointer you passed gets used directly. no copy, no safety net, just vibes (and also the responsibility of keeping that memory alive, iykyk 😭).

fr fr, that pointer thing is not a joke. if your buffer is temporary, use the _copy one. periodt.

πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Doug Rabson πŸ’œ


and that's the whole page, bestie, you ate it πŸ“ This cutie came to you from Debian, dated June 16, 1998 β€” yeah, this page is older than most of us and it's still iconic πŸ¦‹πŸ’– go forth and describe your devices, main character 🌈✨

πŸ“¦ where this page comes from