[haiku-commits] haiku: hrev53114 - src/libs/compat/freebsd_network

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 13 May 2019 14:58:08 -0400 (EDT)

hrev53114 adds 1 changeset to branch 'master'
old head: 858e5775ab6c58deed1c1280beae6267b581b8bc
new head: 9888752db1e1e543a24d3ca9286ac7979bae576d
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=9888752db1e1+%5E858e5775ab6c

----------------------------------------------------------------------------

9888752db1e1: 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 <waddlesplash@xxxxxxxxx>

                                   [ Bruno Albuquerque <bga@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53114
Commit:      9888752db1e1e543a24d3ca9286ac7979bae576d
URL:         https://git.haiku-os.org/haiku/commit/?id=9888752db1e1
Author:      Bruno Albuquerque <bga@xxxxxxxxxxxxx>
Date:        Thu May  9 03:02:04 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Mon May 13 18:58:04 2019 UTC

----------------------------------------------------------------------------

1 file changed, 9 insertions(+), 3 deletions(-)
src/libs/compat/freebsd_network/compat.c | 12 +++++++++---

----------------------------------------------------------------------------

diff --git a/src/libs/compat/freebsd_network/compat.c 
b/src/libs/compat/freebsd_network/compat.c
index ae3adf783c..932227fbde 100644
--- a/src/libs/compat/freebsd_network/compat.c
+++ b/src/libs/compat/freebsd_network/compat.c
@@ -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);


Other related posts: