| 378 | } |
| 379 | |
| 380 | static void |
| 381 | sysctl_warn_reuse(const char *func, struct sysctl_oid *leaf) |
| 382 | { |
| 383 | struct sysctl_oid *nodes[CTL_MAXNAME]; |
| 384 | char buf[128]; |
| 385 | struct sbuf sb; |
| 386 | int rc, i; |
| 387 | |
| 388 | (void)sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN | SBUF_INCLUDENUL); |
| 389 | sbuf_set_drain(&sb, sbuf_printf_drain, NULL); |
| 390 | |
| 391 | sbuf_printf(&sb, "%s: can't re-use a leaf (", __func__); |
| 392 | |
| 393 | memset(nodes, 0, sizeof(nodes)); |
| 394 | rc = sysctl_search_oid(nodes, leaf); |
| 395 | if (rc > 0) { |
| 396 | for (i = 0; i < rc; i++) |
| 397 | sbuf_printf(&sb, "%s%.*s", nodes[i]->oid_name, |
| 398 | i != (rc - 1), "."); |
| 399 | } else { |
| 400 | sbuf_printf(&sb, "%s", leaf->oid_name); |
| 401 | } |
| 402 | sbuf_printf(&sb, ")!\n"); |
| 403 | |
| 404 | (void)sbuf_finish(&sb); |
| 405 | } |
| 406 | |
| 407 | #ifdef SYSCTL_DEBUG |
| 408 | static int |
no test coverage detected