MCPcopy Create free account
hub / github.com/F-Stack/f-stack / device_set_desc_internal

Function device_set_desc_internal

freebsd/kern/subr_bus.c:2441–2462  ·  view source on GitHub ↗

* @internal */

Source from the content-addressed store, hash-verified

2439 * @internal
2440 */
2441static void
2442device_set_desc_internal(device_t dev, const char* desc, int copy)
2443{
2444 if (dev->desc && (dev->flags & DF_DESCMALLOCED)) {
2445 free(dev->desc, M_BUS);
2446 dev->flags &= ~DF_DESCMALLOCED;
2447 dev->desc = NULL;
2448 }
2449
2450 if (copy && desc) {
2451 dev->desc = malloc(strlen(desc) + 1, M_BUS, M_NOWAIT);
2452 if (dev->desc) {
2453 strcpy(dev->desc, desc);
2454 dev->flags |= DF_DESCMALLOCED;
2455 }
2456 } else {
2457 /* Avoid a -Wcast-qual warning */
2458 dev->desc = (char *)(uintptr_t) desc;
2459 }
2460
2461 bus_data_generation_update();
2462}
2463
2464/**
2465 * @brief Set the device's description

Callers 2

device_set_descFunction · 0.85
device_set_desc_copyFunction · 0.85

Calls 3

mallocFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected