]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Stop using deprecated LZ4 functions
authorDavid Woodhouse <dwmw2@infradead.org>
Tue, 13 Dec 2016 11:36:15 +0000 (11:36 +0000)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 13 Dec 2016 11:36:50 +0000 (11:36 +0000)
../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>
configure.ac
cstp.c

index 202cc9cbf2e693a3debd51780b03a36867f069c2..5bdbe479ee0b53e0d370ea106218d419e8a2ea2e 100644 (file)
@@ -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 d2fd4a62d0ac5ade70f2a34655fea323a93f7ade..2fd7a62e3085f4661654eaf56c082e70243cdb65 100644 (file)
--- 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;