Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jun 2004 17:38:13 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Nate Lawson <nate@root.org>
Cc:        cvs-all@freebsd.org
Subject:   Re: cvs commit: src/sys/i386/include/pc bios.h src/sys/i386/i386   bios.c
Message-ID:  <20040604172728.X33153@gamplex.bde.org>
In-Reply-To: <20040603160405.E45592@root.org>
References:  <20040603223638.2187316A54D@hub.freebsd.org> <20040603160405.E45592@root.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 3 Jun 2004, Nate Lawson wrote:

> On Thu, 3 Jun 2004, Poul-Henning Kamp wrote:
> > phk         2004/06/03 15:36:24 PDT
> > ...
> > +const u_char *
> > +bios_string(u_int from, u_int to, const u_char *string, int len)
> > +{
> > +	const char *t, *te;
> > +
> > +	if (len == 0)
> > +		len = strlen(string);
> > +	t = (const char *)(KERNBASE + from);
> > +	te = (const char *)(KERNBASE + to);
> > +	for (; t <= te; t++)
> > +		if (!memcmp(string, t, len))
> > +			return (t);
> > +	return (NULL);
> >  }

This has some style bugs:
- dubious types for `from' and `to',  Should probably be vm_offset_t.
- wrong type for `len'.  Should be size_t.
- memcmp() should not be used in the kernel.  It doesn't exist in some of
  my kernels.  In -current, it is just a just a broken wrapper for
  bcmp() in the kernel.  (memcmp() cannot be implemented using just
  bcmp(), since bcmp() returns a 2-state value while memcmp() returns
  a 3-state value.)
- boolean comparison for the non-boolean value that should be returned by
  memcmp().

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040604172728.X33153>