Hi, On 22/02/17 03:27, David Sommerseth wrote: > +#if defined LZ4_VERSION_NUMBER && LZ4_VERSION_NUMBER >= 10700 > + zlen = LZ4_compress_default((const char *)BPTR(buf), (char > *)BPTR(work), BLEN(buf), zlen_max ); > +#else > zlen = LZ4_compress_limitedOutput((const char *)BPTR(buf), (char > *)BPTR(work), BLEN(buf), zlen_max ); > +#endif
Instead of cluttering the code with these ifdefs directly in the main codebase, how about doing it in compat.h, like this (it's a copy/paste - code might be wrapper by the mail client): diff --git a/src/compat/compat.h b/src/compat/compat.h index d5228989..fa1b096e 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -70,4 +70,13 @@ int inet_pton(int af, const char *src, void *dst); #endif +int ovpn_lz4_compress(const char *src, char *dst, int src_len, int src_max_len) +{ +#if defined LZ4_VERSION_NUMBER && LZ4_VERSION_NUMBER >= 10700 + return LZ4_compress_default(src, dst, src_len, src_max_len); +#else + return LZ4_compress_limitedOutput(src, dst, src_len, src_max_len); +#endif +} + #endif /* COMPAT_H */ diff --git a/src/openvpn/comp-lz4.c b/src/openvpn/comp-lz4.c index 6e40c325..a23a43c4 100644 --- a/src/openvpn/comp-lz4.c +++ b/src/openvpn/comp-lz4.c @@ -86,8 +86,8 @@ do_lz4_compress(struct buffer *buf, return false; } - zlen = LZ4_compress_limitedOutput((const char *)BPTR(buf), (char *)BPTR(work), BLEN(buf), zlen_max ); - + zlen = ovpn_lz4_compress((const char *)BPTR(buf), (char *)BPTR(work), + BLEN(buf), zlen_max ); if (zlen <= 0) { dmsg(D_COMP_ERRORS, "LZ4 compression error"); This way we can put all similar changes in the same file and keep them under control (IMHO we should avoid having #ifdefs directly in the middle of the code as much as possible). Cheers, -- Antonio Quartulli
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel