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

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 3c49cb5a Fix modernize-use-nullptr warning reported by clang-tidy 
(#1156)
3c49cb5a is described below

commit 3c49cb5af39ee6fadb1063f0e3484985b6266906
Author: Maxim Smolskiy <[email protected]>
AuthorDate: Sun Dec 4 05:03:01 2022 +0300

    Fix modernize-use-nullptr warning reported by clang-tidy (#1156)
---
 .clang-tidy             | 2 +-
 src/storage/redis_db.cc | 2 +-
 src/storage/storage.cc  | 4 ++--
 src/types/geohash.cc    | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.clang-tidy b/.clang-tidy
index 5653281b..7950de5f 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,7 +1,7 @@
 # refer to https://clang.llvm.org/extra/clang-tidy/checks/list.html
 Checks: -*, clang-analyzer-core.*, clang-analyzer-cplusplus.*, 
clang-analyzer-deadcode.*, clang-analyzer-nullability.*, 
clang-analyzer-security.*, clang-analyzer-unix.*, clang-analyzer-valist.*, 
cppcoreguidelines-init-variables, cppcoreguidelines-macro-usage, 
cppcoreguidelines-interfaces-global-init, 
cppcoreguidelines-narrowing-conversions, cppcoreguidelines-no-malloc, 
cppcoreguidelines-prefer-member-initializer, 
cppcoreguidelines-special-member-functions, cppcoreguidelines-slicing, goog 
[...]
 
-WarningsAsErrors: clang-analyzer-*, -clang-analyzer-security.insecureAPI.rand, 
cppcoreguidelines-interfaces-global-init, cppcoreguidelines-no-malloc, 
cppcoreguidelines-slicing, google-*, modernize-use-emplace, 
modernize-use-equals-default, modernize-use-equals-delete, 
performance-implicit-conversion-in-loop, performance-inefficient-algorithm, 
performance-move-constructor-init, performance-no-automatic-move, 
performance-trivially-destructible, performance-type-promotion-in-math-fn, 
perfor [...]
+WarningsAsErrors: clang-analyzer-*, -clang-analyzer-security.insecureAPI.rand, 
cppcoreguidelines-interfaces-global-init, cppcoreguidelines-no-malloc, 
cppcoreguidelines-slicing, google-*, modernize-use-emplace, 
modernize-use-equals-default, modernize-use-equals-delete, 
performance-implicit-conversion-in-loop, performance-inefficient-algorithm, 
performance-move-constructor-init, performance-no-automatic-move, 
performance-trivially-destructible, performance-type-promotion-in-math-fn, 
perfor [...]
 
 CheckOptions:
   - key:           
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
diff --git a/src/storage/redis_db.cc b/src/storage/redis_db.cc
index a871ef65..b80614e0 100644
--- a/src/storage/redis_db.cc
+++ b/src/storage/redis_db.cc
@@ -334,7 +334,7 @@ rocksdb::Status Database::RandomKey(const std::string 
&cursor, std::string *key)
     }
   }
   if (!keys.empty()) {
-    unsigned int seed = time(NULL);
+    unsigned int seed = time(nullptr);
     *key = keys.at(rand_r(&seed) % keys.size());
   }
   return rocksdb::Status::OK();
diff --git a/src/storage/storage.cc b/src/storage/storage.cc
index c45736e9..b5f38a67 100644
--- a/src/storage/storage.cc
+++ b/src/storage/storage.cc
@@ -338,7 +338,7 @@ Status Storage::CreateBackup() {
   rocksdb::DestroyDB(tmpdir, rocksdb::Options());
 
   // 1) Create checkpoint of rocksdb for backup
-  rocksdb::Checkpoint *checkpoint = NULL;
+  rocksdb::Checkpoint *checkpoint = nullptr;
   rocksdb::Status s = rocksdb::Checkpoint::Create(db_, &checkpoint);
   if (!s.ok()) {
     LOG(WARNING) << "Fail to create checkpoint for backup, error:" << 
s.ToString();
@@ -731,7 +731,7 @@ Status 
Storage::ReplDataManager::GetFullReplDataInfo(Storage *storage, std::stri
 
   // Create checkpoint if not exist
   if (!storage->env_->FileExists(data_files_dir).ok()) {
-    rocksdb::Checkpoint *checkpoint = NULL;
+    rocksdb::Checkpoint *checkpoint = nullptr;
     rocksdb::Status s = rocksdb::Checkpoint::Create(storage->db_, &checkpoint);
     if (!s.ok()) {
       LOG(WARNING) << "Fail to create checkpoint, error:" << s.ToString();
diff --git a/src/types/geohash.cc b/src/types/geohash.cc
index bbfc5256..89d4e054 100644
--- a/src/types/geohash.cc
+++ b/src/types/geohash.cc
@@ -166,7 +166,7 @@ void geohashGetCoordRange(GeoHashRange *long_range, 
GeoHashRange *lat_range) {
 int geohashEncode(const GeoHashRange *long_range, const GeoHashRange 
*lat_range, double longitude, double latitude,
                   uint8_t step, GeoHashBits *hash) {
   /* Check basic arguments sanity. */
-  if (hash == NULL || step > 32 || step == 0 || RANGEPISZERO(lat_range) || 
RANGEPISZERO(long_range)) return 0;
+  if (!hash || step > 32 || step == 0 || RANGEPISZERO(lat_range) || 
RANGEPISZERO(long_range)) return 0;
 
   /* Return an error when trying to index outside the supported
    * constraints. */
@@ -203,7 +203,7 @@ int geohashEncodeWGS84(double longitude, double latitude, 
uint8_t step, GeoHashB
 
 int geohashDecode(const GeoHashRange &long_range, const GeoHashRange 
&lat_range, const GeoHashBits &hash,
                   GeoHashArea *area) {
-  if (HASHISZERO(hash) || NULL == area || RANGEISZERO(lat_range) || 
RANGEISZERO(long_range)) {
+  if (HASHISZERO(hash) || !area || RANGEISZERO(lat_range) || 
RANGEISZERO(long_range)) {
     return 0;
   }
 

Reply via email to