Improve const use in zlib-using code
Now that we have effectively de-supported CentOS 6, by removing support
for its OpenSSL version, I think we could also modernize the use of some
other libraries, such as zlib.
If we define ZLIB_CONST before including zlib.h, zlib augments some
interfaces with const decorations. By doing that we can keep our own
interfaces cleaner and can remove some unconstify calls.
ZLIB_CONST was introduced in zlib 1.2.5.2 (17 Dec 2011); CentOS 6 has
zlib-1.2.3-29.el6.x86_64.
Note that if you use this patch and compile on CentOS 6, it still works,
you just get a few compiler warnings about discarding qualifiers. Old
environments tend to produce more compiler warnings anyway, so this
doesn't seem so bad.
Attachments:
0001-Improve-const-use-in-zlib-using-code.patchtext/plain; charset=UTF-8; name=0001-Improve-const-use-in-zlib-using-code.patchDownload+12-6
Peter,
I like the idea. Though the way you have it implemented at the moment
seems like a trap in that any time zlib.h is included someone also has
to remember to add this define. I would recommend adding the define to
the build systems instead.
Since you put in the work to find the version of zlib that added this,
You might also want to add `required: '>= 1.2.5.2'` to the
`dependency('zlib')` call in the main meson.build. I am wondering if we
could remove the `z_streamp` check too. The version that it was added
isn't obvious.
--
Tristan Partin
Neon (https://neon.tech)
On 02.08.23 16:39, Tristan Partin wrote:
I like the idea. Though the way you have it implemented at the moment
seems like a trap in that any time zlib.h is included someone also has
to remember to add this define. I would recommend adding the define to
the build systems instead.
Ok, moved to c.h.
Since you put in the work to find the version of zlib that added this,
You might also want to add `required: '>= 1.2.5.2'` to the
`dependency('zlib')` call in the main meson.build.
Well, it's not a hard requirement, so I think this is not necessary.
I am wondering if we
could remove the `z_streamp` check too. The version that it was added
isn't obvious.
Yeah, that appears to be very obsolete. I have made an additional patch
to remove that.
Both patches look good to me.
--
Tristan Partin
Neon (https://neon.tech)