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


The following commit(s) were added to refs/heads/master by this push:
     new ee9e0f04b [util] fix compilation warning
ee9e0f04b is described below

commit ee9e0f04b8e9163898c032edeac65d143cc5195f
Author: Alexey Serbin <ale...@apache.org>
AuthorDate: Mon Nov 6 17:59:48 2023 -0800

    [util] fix compilation warning
    
    This patch fixes compilation warning produced by GCC:
    
      src/kudu/util/env_posix.cc:484:22: warning: format ‘%x’ expects
          argument of type ‘unsigned int’, but argument 2 has type
          ‘kudu::{anonymous}::EncryptionAlgorithm’ [-Wformat=]
              StringPrintf("no cipher for algorithm 0x%02x", eh->algorithm));
    
    I also wrapped the results of GetEVPCipher() into PREDICT_FALSE() macro.
    
    Change-Id: I040c26a3d6d0e9b5350053848a12b4860ab9be4a
    Reviewed-on: http://gerrit.cloudera.org:8080/20671
    Reviewed-by: Yifan Zhang <chinazhangyi...@163.com>
    Tested-by: Kudu Jenkins
    Reviewed-by: Mahesh Reddy <mre...@cloudera.com>
---
 src/kudu/util/env_posix.cc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/kudu/util/env_posix.cc b/src/kudu/util/env_posix.cc
index 9ac97a9ba..0c5a48a85 100644
--- a/src/kudu/util/env_posix.cc
+++ b/src/kudu/util/env_posix.cc
@@ -479,9 +479,10 @@ Status DoEncryptV(const EncryptionHeader* eh,
   InlineBigEndianEncodeFixed64(&iv[8], offset / kEncryptionBlockSize);
 
   const auto* cipher = GetEVPCipher(eh->algorithm);
-  if (!cipher) {
+  if (PREDICT_FALSE(!cipher)) {
     return Status::RuntimeError(
-        StringPrintf("no cipher for algorithm 0x%02x", eh->algorithm));
+        StringPrintf("no cipher for algorithm 0x%02x",
+                     static_cast<uint16_t>(eh->algorithm)));
   }
   auto ctx = ssl_make_unique(EVP_CIPHER_CTX_new());
   OPENSSL_RET_IF_NULL(ctx, "failed to create cipher context");
@@ -528,9 +529,10 @@ Status DoDecryptV(const EncryptionHeader* eh, uint64_t 
offset, ArrayView<Slice>
   InlineBigEndianEncodeFixed64(&iv[8], offset / kEncryptionBlockSize);
 
   const auto* cipher = GetEVPCipher(eh->algorithm);
-  if (!cipher) {
+  if (PREDICT_FALSE(!cipher)) {
     return Status::RuntimeError(
-        StringPrintf("no cipher for algorithm 0x%02x", eh->algorithm));
+        StringPrintf("no cipher for algorithm 0x%02x",
+                     static_cast<uint16_t>(eh->algorithm)));
   }
   auto ctx = ssl_make_unique(EVP_CIPHER_CTX_new());
   OPENSSL_RET_IF_NULL(ctx, "failed to create cipher context");

Reply via email to