| 553 | } |
| 554 | |
| 555 | void |
| 556 | sysctl_unregister_oid(struct sysctl_oid *oidp) |
| 557 | { |
| 558 | struct sysctl_oid *p; |
| 559 | int error; |
| 560 | |
| 561 | SYSCTL_ASSERT_WLOCKED(); |
| 562 | if (oidp->oid_number == OID_AUTO) { |
| 563 | error = EINVAL; |
| 564 | } else { |
| 565 | error = ENOENT; |
| 566 | SLIST_FOREACH(p, oidp->oid_parent, oid_link) { |
| 567 | if (p == oidp) { |
| 568 | SLIST_REMOVE(oidp->oid_parent, oidp, |
| 569 | sysctl_oid, oid_link); |
| 570 | error = 0; |
| 571 | break; |
| 572 | } |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | /* |
| 577 | * This can happen when a module fails to register and is |
| 578 | * being unloaded afterwards. It should not be a panic() |
| 579 | * for normal use. |
| 580 | */ |
| 581 | if (error) { |
| 582 | printf("%s: failed(%d) to unregister sysctl(%s)\n", |
| 583 | __func__, error, oidp->oid_name); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | /* Initialize a new context to keep track of dynamically added sysctls. */ |
| 588 | int |
no test coverage detected