From 31154c5cc6e2351ebcc979bea3b7c5dc6cf5923c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 30 Oct 2007 12:01:21 +0000 Subject: [PATCH] * Fixed the KASSERT() macro - it panicked without reason. * Fixed device_set_driver(): it needs to clear the allocated buffer (it's allocated with M_ZERO in FreeBSD). * The first mbuf buffer needs to have the M_PKTHDR flag set. * With these changes, the 3com driver now fails where it should have failed before, that is in the missing interrupt handling. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22769 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/compat/freebsd_network/compat.c | 6 +++--- src/libs/compat/freebsd_network/compat/sys/kernel.h | 4 ++-- src/libs/compat/freebsd_network/device.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/compat/freebsd_network/compat.c b/src/libs/compat/freebsd_network/compat.c index 9603d92145..4fa97739f9 100644 --- a/src/libs/compat/freebsd_network/compat.c +++ b/src/libs/compat/freebsd_network/compat.c @@ -283,6 +283,7 @@ device_set_driver(device_t dev, driver_t *driver) if (dev->softc == NULL) return -1; + memset(dev->softc, 0, driver->softc_size); dev->driver = driver; for (i = 0; method == NULL && driver->methods[i].name != NULL; i++) { @@ -387,10 +388,9 @@ __haiku_probe_miibus(device_t dev, driver_t *drivers[], int count) void bus_generic_attach(device_t dev) { - device_t child; + device_t child = NULL; - for (child = list_get_first_item(&dev->children); - child; child = list_get_next_item(&dev->children, child)) { + for (; child != NULL; child = list_get_next_item(&dev->children, child)) { if (child->driver == NULL) { if (dev->driver == &miibus_driver) { driver_t *driver = __haiku_select_miibus_driver(child); diff --git a/src/libs/compat/freebsd_network/compat/sys/kernel.h b/src/libs/compat/freebsd_network/compat/sys/kernel.h index 88188edc67..6731994198 100644 --- a/src/libs/compat/freebsd_network/compat/sys/kernel.h +++ b/src/libs/compat/freebsd_network/compat/sys/kernel.h @@ -14,9 +14,9 @@ #define bootverbose 1 #define KASSERT(cond,msg) do { \ - if (!cond) \ + if (!(cond)) \ panic msg; \ -} while(0) +} while (0) typedef void (*system_init_func_t)(void *); diff --git a/src/libs/compat/freebsd_network/device.c b/src/libs/compat/freebsd_network/device.c index 1e6a012831..f0d4b5f640 100644 --- a/src/libs/compat/freebsd_network/device.c +++ b/src/libs/compat/freebsd_network/device.c @@ -11,11 +11,11 @@ #include "device.h" #include +#include + #include #include -#include - #include #include @@ -239,7 +239,7 @@ compat_write(void *cookie, off_t position, const void *buffer, device_printf(DEVNET(dev), "compat_write(%lld, %p, [%lu])\n", position, buffer, *numBytes); - mb = m_getcl(0, MT_DATA, 0); + mb = m_getcl(0, MT_DATA, M_PKTHDR); if (mb == NULL) return ENOBUFS;