From: David Woodhouse <dwmw2@infradead.org>
Date: Tue, 13 Dec 2016 11:36:15 +0000 (+0000)
Subject: Stop using deprecated LZ4 functions
X-Git-Tag: v7.08~8
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=01d40d80d3bf212f951a5dd8131e7858a96d529d;p=users%2Fdwmw2%2Fopenconnect.git

Stop using deprecated LZ4 functions

../cstp.c:865:3: warning: ‘LZ4_compress_limitedOutput’ is deprecated: use LZ4_compress_default() instead [-Wdeprecated-declarations]
   ret = LZ4_compress_default((void*)this->data, (void*)vpninfo->deflate_pkt->data,
   ^~~

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
---

diff --git a/configure.ac b/configure.ac
index 202cc9cb..5bdbe479 100644
--- a/configure.ac
+++ b/configure.ac
@@ -591,6 +591,20 @@ PKG_CHECK_MODULES([LIBLZ4], [liblz4], [
 	AC_SUBST(LIBLZ4_PC, liblz4)
 	AC_DEFINE([HAVE_LZ4], [], [LZ4 was found])
 	lz4_pkg=yes
+	oldLIBS="$LIBS"
+	LIBS="$LIBS $LIBLZ4_LIBS"
+	oldCFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS $LIBLZ4_CFLAGS"
+	AC_MSG_CHECKING([for LZ4_compress_default()])
+	AC_LINK_IFELSE([AC_LANG_PROGRAM([
+		   #include <lz4.h>],[
+		   LZ4_compress_default("", (char *)0, 0, 0);])],
+		  [AC_MSG_RESULT(yes)
+		   AC_DEFINE([HAVE_LZ4_COMPRESS_DEFAULT], [], [From LZ4 r129])
+		  ],
+		  [AC_MSG_RESULT(no)])
+	LIBS="$oldLIBS"
+	CFLAGS="$oldCFLAGS"
 ],
 [
 	AC_MSG_WARN([[
diff --git a/cstp.c b/cstp.c
index d2fd4a62..2fd7a62e 100644
--- a/cstp.c
+++ b/cstp.c
@@ -30,6 +30,9 @@
 #include <stdarg.h>
 #ifdef HAVE_LZ4
 #include <lz4.h>
+#ifndef HAVE_LZ4_COMPRESS_DEFAULT
+#define LZ4_compress_default LZ4_compress_limitedOutput
+#endif
 #endif
 
 #if defined(__linux__)
@@ -859,8 +862,8 @@ int compress_packet(struct openconnect_info *vpninfo, int compr_type, struct pkt
 		if (this->len < 40)
 			return -EFBIG;
 
-		ret = LZ4_compress_limitedOutput((void*)this->data, (void*)vpninfo->deflate_pkt->data, this->len,
-				   this->len);
+		ret = LZ4_compress_default((void*)this->data, (void*)vpninfo->deflate_pkt->data,
+					   this->len, this->len);
 		if (ret <= 0) {
 			if (ret == 0)
 				ret = -EFBIG;