Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Aug 2019 06:27:40 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350742 - in head/sys: geom/uzip modules/geom/geom_uzip
Message-ID:  <201908080627.x786ReNW081537@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Thu Aug  8 06:27:39 2019
New Revision: 350742
URL: https://svnweb.freebsd.org/changeset/base/350742

Log:
  Update geom_uzip to use new zlib:
  
   - Use new zlib headers;
   - Removed z_alloc and z_free to use the common sys/dev/zlib version.
   - Replace z_compressBound with compressBound from zlib.
  
  While there, limit LZMA CFLAGS to apply only for g_uzip_lzma.c.
  
  PR:		229763
  Submitted by:	Yoshihiro Ota <ota j email ne jp> (with changes,
  		bugs are mine)
  Differential Revision:	https://reviews.freebsd.org/D20271

Modified:
  head/sys/geom/uzip/g_uzip_zlib.c
  head/sys/modules/geom/geom_uzip/Makefile

Modified: head/sys/geom/uzip/g_uzip_zlib.c
==============================================================================
--- head/sys/geom/uzip/g_uzip_zlib.c	Thu Aug  8 06:26:34 2019	(r350741)
+++ head/sys/geom/uzip/g_uzip_zlib.c	Thu Aug  8 06:27:39 2019	(r350742)
@@ -33,7 +33,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/malloc.h>
 
-#include <sys/zlib.h>
+#include <contrib/zlib/zlib.h>
+#include <dev/zlib/zcalloc.h>
 
 #include <geom/uzip/g_uzip.h>
 #include <geom/uzip/g_uzip_dapi.h>
@@ -46,8 +47,6 @@ struct g_uzip_zlib {
 	z_stream zs;
 };
 
-static void *z_alloc(void *, u_int, u_int);
-static void z_free(void *, void *);
 static int g_uzip_zlib_rewind(struct g_uzip_dapi *, const char *);
 
 static void
@@ -97,26 +96,17 @@ g_uzip_zlib_rewind(struct g_uzip_dapi *zpp, const char
 	return (err);
 }
 
-static int
-z_compressBound(int len)
-{
-
-	return (len + (len >> 12) + (len >> 14) + 11);
-}
-
 struct g_uzip_dapi *
 g_uzip_zlib_ctor(uint32_t blksz)
 {
 	struct g_uzip_zlib *zp;
 
-	zp = malloc(sizeof(struct g_uzip_zlib), M_GEOM_UZIP, M_WAITOK);
-	zp->zs.zalloc = z_alloc;
-	zp->zs.zfree = z_free;
+	zp = malloc(sizeof(struct g_uzip_zlib), M_GEOM_UZIP, M_WAITOK | M_ZERO);
 	if (inflateInit(&zp->zs) != Z_OK) {
 		goto e1;
 	}
 	zp->blksz = blksz;
-	zp->pub.max_blen = z_compressBound(blksz);
+	zp->pub.max_blen = compressBound(blksz);
 	zp->pub.decompress = &g_uzip_zlib_decompress;
 	zp->pub.free = &g_uzip_zlib_free;
 	zp->pub.rewind = &g_uzip_zlib_rewind;
@@ -125,21 +115,4 @@ g_uzip_zlib_ctor(uint32_t blksz)
 e1:
 	free(zp, M_GEOM_UZIP);
 	return (NULL);
-}
-
-static void *
-z_alloc(void *nil, u_int type, u_int size)
-{
-        void *ptr;
-
-        ptr = malloc(type * size, M_GEOM_UZIP, M_NOWAIT);
-
-        return (ptr);
-}
-
-static void
-z_free(void *nil, void *ptr)
-{
-
-        free(ptr, M_GEOM_UZIP);
 }

Modified: head/sys/modules/geom/geom_uzip/Makefile
==============================================================================
--- head/sys/modules/geom/geom_uzip/Makefile	Thu Aug  8 06:26:34 2019	(r350741)
+++ head/sys/modules/geom/geom_uzip/Makefile	Thu Aug  8 06:27:39 2019	(r350742)
@@ -10,7 +10,7 @@ SRCS+=	g_uzip.h g_uzip_dapi.h g_uzip_lzma.h g_uzip_zli
 
 .PATH:	${SRCTOP}/sys/net
 
-CFLAGS+= -I${SRCTOP}/sys/contrib/xz-embedded/freebsd \
+CFLAGS.g_uzip_lzma.c+= -I${SRCTOP}/sys/contrib/xz-embedded/freebsd \
 	-I${SRCTOP}/sys/contrib/xz-embedded/linux/lib/xz/
 SRCS+=	opt_geom.h
 



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