Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Oct 2006 13:40:49 +0400
From:      Ruslan Ermilov <ru@freebsd.org>
To:        freebsd-net@freebsd.org, andre@freebsd.org
Subject:   Re: [PATCH] Make hash.h usable in the kernel
Message-ID:  <20061011094049.GA24964@rambler-co.ru>
In-Reply-To: <20061011090241.GA2831@FreeBSD.czest.pl>
References:  <20061011090241.GA2831@FreeBSD.czest.pl>

next in thread | previous in thread | raw e-mail | index | archive | help

--ZGiS0Q5IWpPtfppv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 11, 2006 at 11:02:41AM +0200, Wojciech A. Koszek wrote:
> Hello,
>=20
> I'm working on potential consumer of functions from sys/hash.h. Currently=
, I
> can't make them work without modyfication in my sample KLD. This is a pat=
ch
> which fixes the problem:
>=20
> 	http://people.freebsd.org/~wkoszek/patches/hash.h.0.patch
>=20
> It makes following program..
>=20
> 	http://people.freebsd.org/~wkoszek/hash.c
>=20
> ..compile without warnings with WARNS=3D5. If noone objects, I'd like to
> commit it.
>=20
This is a wrong fix.  A correct fix would be:

%%%
Index: sys/sys/hash.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/sys/sys/hash.h,v
retrieving revision 1.2
diff -u -p -r1.2 hash.h
--- sys/sys/hash.h	12 Mar 2006 15:34:33 -0000	1.2
+++ sys/sys/hash.h	11 Oct 2006 09:38:50 -0000
@@ -86,7 +86,7 @@ hash32_strn(const void *buf, size_t len,
  * namei() hashing of path name parts.
  */
 static __inline uint32_t
-hash32_stre(const void *buf, int end, char **ep, uint32_t hash)
+hash32_stre(const void *buf, int end, const char **ep, uint32_t hash)
 {
 	const unsigned char *p =3D buf;
=20
@@ -94,7 +94,7 @@ hash32_stre(const void *buf, int end, ch
 		hash =3D HASHSTEP(hash, *p++);
=20
 	if (ep)
-		*ep =3D (char *)p;
+		*ep =3D (const char *)p;
=20
 	return hash;
 }
@@ -105,7 +105,7 @@ hash32_stre(const void *buf, int end, ch
  * as a helper for the namei() hashing of path name parts.
  */
 static __inline uint32_t
-hash32_strne(const void *buf, size_t len, int end, char **ep, uint32_t has=
h)
+hash32_strne(const void *buf, size_t len, int end, const char **ep, uint32=
_t hash)
 {
 	const unsigned char *p =3D buf;
=20
@@ -113,7 +113,7 @@ hash32_strne(const void *buf, size_t len
 		hash =3D HASHSTEP(hash, *p++);
=20
 	if (ep)
-		*ep =3D (char *)p;
+		*ep =3D (const char *)p;
=20
 	return hash;
 }
Index: share/man/man9/hash.9
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/share/man/man9/hash.9,v
retrieving revision 1.2
diff -u -p -r1.2 hash.9
--- share/man/man9/hash.9	30 Sep 2006 17:09:59 -0000	1.2
+++ share/man/man9/hash.9	11 Oct 2006 09:39:43 -0000
@@ -47,9 +47,11 @@
 .Ft uint32_t
 .Fn hash32_strn "void *buf" "size_t len" "uint32_t hash"
 .Ft uint32_t
-.Fn hash32_stre "void *buf" "int end" "char **ep" "uint32_t hash"
+.Fn hash32_stre "void *buf" "int end" "const char **ep" "uint32_t hash"
 .Ft uint32_t
-.Fn hash32_strne "void *buf" "size_t len" "int end" "char **ep" "uint32_t =
hash"
+.Fo hash32_strne
+.Fa "void *buf" "size_t len" "int end" "const char **ep" "uint32_t hash"
+.Fc
 .Sh DESCRIPTION
 The
 .Fn hash32
%%%


Cheers,
--=20
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

--ZGiS0Q5IWpPtfppv
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFLLwhqRfpzJluFF4RArHFAKCavXGrFUiltnw+bTAEsuUsaMa12gCdHzSV
t+PLVfQnzeZYweUvFAVi9jI=
=mtKN
-----END PGP SIGNATURE-----

--ZGiS0Q5IWpPtfppv--



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