This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit d8c315782bcd64e6c512885cc3ba578acbd6f45c
Author: Alexey Serbin <ale...@apache.org>
AuthorDate: Thu Apr 4 13:04:13 2024 -0700

    [c++17] fix unsorted compilation warnings with CLANG15
    
    As a follow-up to a few prior patches, this patch addresses the rest
    of warnings output by CLANG15 when compiling the Kudu project
    on macOS Sonoma.
    
    There are still some warnings from the linker, e.g. warnings about
    the difference between target OS versions of the LLVM libraries
    from 3rd-party and Kudu binaries being linked.  I think it's better
    to address them in a separate patch, if ever doing so.
    
    Change-Id: Iab094ec0766994d4e4d399a4ae1eb112ec16e5ee
    Reviewed-on: http://gerrit.cloudera.org:8080/21242
    Tested-by: Alexey Serbin <ale...@apache.org>
    Reviewed-by: Abhishek Chennaka <achenn...@cloudera.com>
---
 src/kudu/gutil/strings/escaping.cc     | 6 ++++++
 src/kudu/gutil/sysinfo.cc              | 5 +++--
 src/kudu/server/webserver.cc           | 6 ++++++
 src/kudu/tablet/ops/op_tracker-test.cc | 3 ++-
 src/kudu/tablet/tablet.cc              | 2 --
 5 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/kudu/gutil/strings/escaping.cc 
b/src/kudu/gutil/strings/escaping.cc
index 6ad75035a..b9b0401a6 100644
--- a/src/kudu/gutil/strings/escaping.cc
+++ b/src/kudu/gutil/strings/escaping.cc
@@ -492,6 +492,11 @@ bool CUnescapeForNullTerminatedString(const StringPiece& 
source,
   return CUnescapeInternal(source, kLeaveNullsEscaped, dest, error);
 }
 
+// Avoid warnings about sprintf() deprecation from contemporary compilers.
+// Silencing warnings seems to be a good option because this code has been
+// imported to Kudu from an external project repo and doesn't change much.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 // ----------------------------------------------------------------------
 // CEscapeString()
 // CHexEscapeString()
@@ -551,6 +556,7 @@ int CEscapeInternal(const char* src, int src_len, char* 
dest,
   dest[used] = '\0';   // doesn't count towards return value though
   return used;
 }
+#pragma GCC diagnostic pop
 
 int CEscapeString(const char* src, int src_len, char* dest, int dest_len) {
   return CEscapeInternal(src, src_len, dest, dest_len, false, false);
diff --git a/src/kudu/gutil/sysinfo.cc b/src/kudu/gutil/sysinfo.cc
index 539d37a52..610c7db93 100644
--- a/src/kudu/gutil/sysinfo.cc
+++ b/src/kudu/gutil/sysinfo.cc
@@ -101,6 +101,7 @@ void SleepForMilliseconds(int64_t milliseconds) {
   SleepForNanoseconds(milliseconds * 1000 * 1000);
 }
 
+#if !(defined(__MACH__) && defined(__APPLE__))
 // Helper function estimates cycles/sec by observing cycles elapsed during
 // sleep(). Using small sleep time decreases accuracy significantly.
 static int64 EstimateCyclesPerSecond(const int estimate_time_ms) {
@@ -114,6 +115,7 @@ static int64 EstimateCyclesPerSecond(const int 
estimate_time_ms) {
   const int64 guess = int64(multiplier * (CycleClock::Now() - start_ticks));
   return guess;
 }
+#endif
 
 // ReadIntFromFile is only called on linux and cygwin platforms.
 #if defined(__linux__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
@@ -236,8 +238,8 @@ static void InitializeSystemInfo() {
   if (already_called)  return;
   already_called = true;
 
+#if defined(__linux__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
   bool saw_mhz = false;
-
   if (RunningOnValgrind()) {
     // Valgrind may slow the progress of time artificially (--scale-time=N
     // option). We thus can't rely on CPU Mhz info stored in /sys or /proc
@@ -246,7 +248,6 @@ static void InitializeSystemInfo() {
     saw_mhz = true;
   }
 
-#if defined(__linux__) || defined(__CYGWIN__) || defined(__CYGWIN32__)
   char line[1024];
   char* err;
   int freq;
diff --git a/src/kudu/server/webserver.cc b/src/kudu/server/webserver.cc
index b920f2b95..c5c18715f 100644
--- a/src/kudu/server/webserver.cc
+++ b/src/kudu/server/webserver.cc
@@ -365,7 +365,13 @@ Status Webserver::Start() {
       return Status::InvalidArgument("Unable to configure web server for 
SPNEGO authentication: "
                                      "must configure a keytab file for the 
server");
     }
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+    // NOTE: this call is wrapped into 'ignored' pragma to suppress compilation
+    //       warnings on macOS with Xcode where many gssapi_krb5 functions are
+    //       deprecated in favor of GSS.framework.
     krb5_gss_register_acceptor_identity(kt_file);
+#pragma GCC diagnostic pop
   }
 
   options.emplace_back("listening_ports");
diff --git a/src/kudu/tablet/ops/op_tracker-test.cc 
b/src/kudu/tablet/ops/op_tracker-test.cc
index c948041a9..c3c15d938 100644
--- a/src/kudu/tablet/ops/op_tracker-test.cc
+++ b/src/kudu/tablet/ops/op_tracker-test.cc
@@ -22,6 +22,7 @@
 #include <ostream>
 #include <string>
 #include <thread>
+#include <type_traits>
 #include <utility>
 #include <vector>
 
@@ -256,7 +257,7 @@ TEST_P(OpTrackerTest, TestTooManyOps) {
                      d->Abort(Status::Aborted(""));
                    }
                  });
-  for (int i = 0; s.ok(); i++) {
+  while (s.ok()) {
     s = AddDrivers(1, &drivers);
   }
 
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index 2131590bc..c7da4a58d 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -3057,7 +3057,6 @@ Status Tablet::DeleteAncientDeletedRowsets() {
   // We'll take our the rowsets' locks to ensure we don't GC the rowsets while
   // they're being compacted.
   RowSetVector to_delete;
-  int num_unavailable_for_delete = 0;
   vector<std::unique_lock<std::mutex>> rowset_locks;
   int64_t bytes_deleted = 0;
   {
@@ -3066,7 +3065,6 @@ Status Tablet::DeleteAncientDeletedRowsets() {
       // Check if this rowset has been locked by a compaction. If so, we
       // shouldn't attempt to delete it.
       if (!rowset->IsAvailableForCompaction()) {
-        num_unavailable_for_delete++;
         continue;
       }
       bool deleted_and_empty = false;

Reply via email to