Skip to content

Commit

Permalink
ZOOKEEPER-4201: C client: Disable SASL deprecation warnings on macOS
Browse files Browse the repository at this point in the history
This patch works around the numerous deprecation notices added to the CyrusSASL library on macOS.  It is a direct "port" of the solution to MESOS-3030, which hit exactly the same problem:

https://issues.apache.org/jira/browse/MESOS-3030

https://reviews.apache.org/r/39230/diff/3/

The PR also includes a fix for the the `clockid_t` compilation issue mentioned in the ticket description, but the test suite as a whole remains broken on macOS as its linker does not support the `--wrap` option.

Author: Damien Diederen <[email protected]>

Reviewers: Enrico Olivelli <[email protected]>, Mate Szalay-Beko <[email protected]>

Closes apache#1593 from ztzg/ZOOKEEPER-4201-catalina-c-client-fixes
  • Loading branch information
ztzg authored and RokLenarcic committed Aug 31, 2022
1 parent d0d93d9 commit 9cb9e3a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions zookeeper-client/zookeeper-client-c/src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,17 @@ int main(int argc, char **argv) {
zoo_deterministic_conn_order(1); // enable deterministic order

#ifdef HAVE_CYRUS_SASL_H
/*
* We need to disable the deprecation warnings as Apple has
* decided to deprecate all of CyrusSASL's functions with OS 10.11
* (see MESOS-3030, ZOOKEEPER-4201). We are using GCC pragmas also
* for covering clang.
*/
#ifdef __APPLE__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

if (mechlist) {
zoo_sasl_params_t sasl_params = { 0 };
int sr;
Expand Down Expand Up @@ -977,6 +988,11 @@ int main(int argc, char **argv) {
return errno;
}
}

#ifdef __APPLE__
#pragma GCC diagnostic pop
#endif

#endif /* HAVE_CYRUS_SASL_H */

if (!zh) {
Expand Down
15 changes: 15 additions & 0 deletions zookeeper-client/zookeeper-client-c/src/zk_sasl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
#include "zk_adaptor.h"
#include "zookeeper_log.h"

/*
* We need to disable the deprecation warnings as Apple has decided to
* deprecate all of CyrusSASL's functions with OS 10.11 (see
* MESOS-3030, ZOOKEEPER-4201). We are using GCC pragmas also for
* covering clang.
*/
#ifdef __APPLE__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

/*
* Store a duplicate of src, or NULL, into *target. Returns
* ZSYSTEMERROR if no memory could be allocated, ZOK otherwise.
Expand Down Expand Up @@ -539,3 +550,7 @@ sasl_callback_t *zoo_sasl_make_basic_callbacks(const char *user,
return xcallbacks;
}
}

#ifdef __APPLE__
#pragma GCC diagnostic pop
#endif
1 change: 1 addition & 0 deletions zookeeper-client/zookeeper-client-c/tests/LibCSymTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <dlfcn.h>
#include <cassert>
#include <poll.h>
#include <time.h>
#include <unistd.h> // needed for _POSIX_MONOTONIC_CLOCK

#ifdef THREADED
Expand Down
14 changes: 14 additions & 0 deletions zookeeper-client/zookeeper-client-c/tests/TestSASLAuth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ class Zookeeper_SASLAuth : public CPPUNIT_NS::TestFixture {
}

#ifdef HAVE_CYRUS_SASL_H

// We need to disable the deprecation warnings as Apple has
// decided to deprecate all of CyrusSASL's functions with OS 10.11
// (see MESOS-3030, ZOOKEEPER-4201). We are using GCC pragmas also
// for covering clang.
#ifdef __APPLE__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

void testClientSASLHelper(const char *hostPorts, const char *path) {
startServer();

Expand Down Expand Up @@ -260,6 +270,10 @@ class Zookeeper_SASLAuth : public CPPUNIT_NS::TestFixture {
stopServer();
}

#ifdef __APPLE__
#pragma GCC diagnostic pop
#endif

#endif /* HAVE_CYRUS_SASL_H */
};

Expand Down

0 comments on commit 9cb9e3a

Please sign in to comment.