freebsd_network: Style fixes pointed out by Korli.

- Did not see his comments before pushing my previous change.
- clear owning flag when passed value is NULL.

Change-Id: I493973aff2b107785c3734847c85a52f0f9da360
Reviewed-on: https://review.haiku-os.org/c/1443
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Bruno Albuquerque
2019-05-13 18:58:04 +00:00
committed by waddlesplash
parent 858e5775ab
commit 9888752db1
+9 -3
View File
@@ -268,13 +268,19 @@ device_get_softc(device_t dev)
void
device_set_softc(device_t dev, void *softc)
{
if (!(dev->flags & DEVICE_SOFTC_SET)) {
if (dev->softc == softc)
return;
if ((dev->flags & DEVICE_SOFTC_SET) != 0) {
// Not externally allocated. We own it so we must clean it up.
free(dev->softc);
}
dev->softc = softc;
dev->flags |= DEVICE_SOFTC_SET;
if (dev->softc != NULL)
dev->flags |= DEVICE_SOFTC_SET;
else
dev->flags &= ~DEVICE_SOFTC_SET;
}
@@ -452,7 +458,7 @@ device_delete_child(device_t parent, device_t child)
free((char *)parent->description);
// Delete softc if we were the ones to allocate it.
if (!(parent->flags & DEVICE_SOFTC_SET))
if ((parent->flags & DEVICE_SOFTC_SET) != 0)
free(parent->softc);
free(parent);