Re: Latest Broadcom NDIS driver requires 4 additional functions

From: Scot Hetzel <swhetzel_at_gmail.com>
Date: Mon, 11 Dec 2006 23:56:04 -0600
On 11/25/06, Scot Hetzel <swhetzel_at_gmail.com> wrote:
> Unimplemented Functions:
>       memchr - implemented but causes "cast discards qualifiers from pointer target type"
:
>
> Any ideas as to how to fix memchr, ... ?
>

I was able to fix memchr with the help of one of my college
professors, he provided me with two different solutions to get rid of
the cast problem.

#ifdef BROKEN_MEMCHR
static void *ntoskrnl_memchr(const void *, int, size_t);

/*
 * /usr/src/sys/modules/ndis/../../compat/ndis/subr_ntoskrnl.c: In
function `ntoskrnl_memchr':
 * /usr/src/sys/modules/ndis/../../compat/ndis/subr_ntoskrnl.c:465:
warning: cast discards qualifiers from pointer target type
 * *** Error code 1
 */

static void *
ntoskrnl_memchr(buf, ch, len)
        const void      *buf;
        unsigned char   ch;
        size_t          len;
{
        if (len != 0) {
                const unsigned char *p = buf;

                do {
                        if (*p++ == ch) {
                                return ((void *)(p - 1)); /* error
occurs here */
                        }
                } while (--len != 0);
        }
        return (NULL);
}
#endif

#ifdef FIX1_MEMCHR
static void *ntoskrnl_memchr(void *, int, size_t);

static void *
ntoskrnl_memchr(buf, ch, len)
        void            *buf;
        unsigned char   ch;
        size_t          len;
{
        if (len != 0) {
                unsigned char *p = buf;

                do {
                        if (*p++ == ch) {
                                return ((void *)(p - 1));
                        }
                } while (--len != 0);
        }
        return (NULL);
}
#endif

#ifdef FIX2_MEMCHR
static const void *ntoskrnl_memchr(const void *, int, size_t);

static const void *
ntoskrnl_memchr(buf, ch, len)
        const void      *buf;
        unsigned char   ch;
        size_t          len;
{
        if (len != 0) {
                const unsigned char *p = buf;

                do {
                        if (*p++ == ch) {
                                return ((const void *)(p - 1));
                        }
                } while (--len != 0);
        }
        return (NULL);
}
#endif

Which version should I use as a follow up to PR 106131.

http://www.freebsd.org/cgi/query-pr.cgi?pr=106131

Scot
-- 
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.
Received on Tue Dec 12 2006 - 04:56:09 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:03 UTC