* @brief Print the name of the device followed by a colon, a space * and the result of calling vprintf() with the value of @p fmt and * the following arguments. * * @returns the number of characters printed */
| 2405 | * @returns the number of characters printed |
| 2406 | */ |
| 2407 | int |
| 2408 | device_printf(device_t dev, const char * fmt, ...) |
| 2409 | { |
| 2410 | char buf[128]; |
| 2411 | struct sbuf sb; |
| 2412 | const char *name; |
| 2413 | va_list ap; |
| 2414 | size_t retval; |
| 2415 | |
| 2416 | retval = 0; |
| 2417 | |
| 2418 | sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN); |
| 2419 | sbuf_set_drain(&sb, sbuf_printf_drain, &retval); |
| 2420 | |
| 2421 | name = device_get_name(dev); |
| 2422 | |
| 2423 | if (name == NULL) |
| 2424 | sbuf_cat(&sb, "unknown: "); |
| 2425 | else |
| 2426 | sbuf_printf(&sb, "%s%d: ", name, device_get_unit(dev)); |
| 2427 | |
| 2428 | va_start(ap, fmt); |
| 2429 | sbuf_vprintf(&sb, fmt, ap); |
| 2430 | va_end(ap); |
| 2431 | |
| 2432 | sbuf_finish(&sb); |
| 2433 | sbuf_delete(&sb); |
| 2434 | |
| 2435 | return (retval); |
| 2436 | } |
| 2437 | |
| 2438 | /** |
| 2439 | * @internal |
no test coverage detected