]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: fix NULL references to be acceptable by Clang 12880/head
authorWillem Jan Withagen <wjw@digiware.nl>
Wed, 11 Jan 2017 10:18:32 +0000 (11:18 +0100)
committerWillem Jan Withagen <wjw@digiware.nl>
Wed, 11 Jan 2017 16:14:59 +0000 (17:14 +0100)
 - On some platforms NULL evaluates to nullptr, which will require a
   cast to the right type to be able to compile.
      error: reinterpret_cast from 'nullptr_t' to 'ContextWQ *'

 - It is a delicate change since otherwise GCC will start complaining
   about the reverse:
      error: invalid static_cast from type 'const long int' to type 'ContextWQ*'

 By casting right at the instance of NULL both compilers are happy.

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc
src/test/librbd/journal/test_mock_OpenRequest.cc
src/test/librbd/journal/test_mock_PromoteRequest.cc
src/test/librbd/operation/test_mock_ResizeRequest.cc
src/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc
src/test/librbd/test_mock_Journal.cc

index 4cf9c2254aa079039bff3c8a5ba19bfe80945926..29cded8ca40e456c084304bb63b2595db863e7a0 100644 (file)
@@ -93,7 +93,7 @@ public:
                                int r) {
     if (mock_image_ctx.object_cacher != nullptr) {
       EXPECT_CALL(mock_image_ctx, invalidate_cache(purge, _))
-                    .WillOnce(WithArg<1>(CompleteContext(r, NULL)));
+                    .WillOnce(WithArg<1>(CompleteContext(r, static_cast<ContextWQ*>(NULL)))); 
     }
   }
 
index 98bc429c4001194db99b92bc253056891159b52e..72fdb14a9c7d65ce63c31341e347cb88258f77e7 100644 (file)
@@ -54,7 +54,7 @@ public:
 
   void expect_init_journaler(::journal::MockJournaler &mock_journaler, int r) {
     EXPECT_CALL(mock_journaler, init(_))
-                  .WillOnce(CompleteContext(r, NULL));
+                  .WillOnce(CompleteContext(r, static_cast<ContextWQ*>(NULL)));
   }
 
   void expect_get_journaler_cached_client(::journal::MockJournaler &mock_journaler,
index 5f27ca8c649ff85b43aa1584b61f9125c53e97d3..5e57331c6548ee0f19e3ddae7deae3b7e06da5d0 100644 (file)
@@ -92,13 +92,13 @@ public:
 
     EXPECT_CALL(mock_journaler, allocate_tag(456, ContentsEqual(tag_data_bl),
                                              _, _))
-      .WillOnce(WithArg<3>(CompleteContext(r, NULL)));
+      .WillOnce(WithArg<3>(CompleteContext(r, static_cast<ContextWQ*>(NULL))));
   }
 
   void expect_shut_down_journaler(::journal::MockJournaler &mock_journaler,
                                   int r) {
     EXPECT_CALL(mock_journaler, shut_down(_))
-      .WillOnce(CompleteContext(r, NULL));
+      .WillOnce(CompleteContext(r, static_cast<ContextWQ*>(NULL)));
   }
 
 };
index a2145fcedc237a92e351c5144ff3786b9cebea0a..ac72459e620cbe5d0de574176e5e279cbbefae3f 100644 (file)
@@ -114,13 +114,14 @@ public:
   }
 
   void expect_flush_cache(MockImageCtx &mock_image_ctx, int r) {
-    EXPECT_CALL(mock_image_ctx, flush_cache(_)).WillOnce(CompleteContext(r, NULL));
+    EXPECT_CALL(mock_image_ctx, flush_cache(_))
+                  .WillOnce(CompleteContext(r, static_cast<ContextWQ*>(NULL)));
     expect_op_work_queue(mock_image_ctx);
   }
 
   void expect_invalidate_cache(MockImageCtx &mock_image_ctx, int r) {
     EXPECT_CALL(mock_image_ctx, invalidate_cache(false, _))
-                  .WillOnce(WithArg<1>(CompleteContext(r, NULL)));
+                   .WillOnce(WithArg<1>(CompleteContext(r, static_cast<ContextWQ*>(NULL))));
     expect_op_work_queue(mock_image_ctx);
   }
 
index 4000eb9b052037c691958fcef6b603245babc3be..fea236bea0a3586919bf09a6e832706659145707 100644 (file)
@@ -166,7 +166,7 @@ public:
   void expect_invalidate_cache(MockOperationImageCtx &mock_image_ctx, int r) {
     if (mock_image_ctx.object_cacher != nullptr) {
       EXPECT_CALL(mock_image_ctx, invalidate_cache(true, _))
-                    .WillOnce(WithArg<1>(CompleteContext(r, NULL)));
+                    .WillOnce(WithArg<1>(CompleteContext(r, static_cast<ContextWQ*>(NULL))));
     }
   }
 
index 78b498958961f4495f505b4c2f4bb080559427b9..a95fb5fb4618dcb2d5fe4f7fa820890d13fc3b9f 100644 (file)
@@ -280,7 +280,7 @@ public:
   void expect_shut_down_journaler(::journal::MockJournaler &mock_journaler) {
     EXPECT_CALL(mock_journaler, remove_listener(_));
     EXPECT_CALL(mock_journaler, shut_down(_))
-                  .WillOnce(CompleteContext(0, NULL));
+                  .WillOnce(CompleteContext(0, static_cast<ContextWQ*>(NULL)));
   }
 
   void expect_get_max_append_size(::journal::MockJournaler &mock_journaler,
@@ -324,7 +324,7 @@ public:
 
   void expect_stop_replay(::journal::MockJournaler &mock_journaler) {
     EXPECT_CALL(mock_journaler, stop_replay(_))
-                  .WillOnce(CompleteContext(0, NULL));
+                  .WillOnce(CompleteContext(0, static_cast<ContextWQ*>(NULL)));
   }
 
   void expect_shut_down_replay(MockJournalImageCtx &mock_image_ctx,
@@ -360,7 +360,7 @@ public:
     EXPECT_CALL(mock_journal_replay, decode(_, _))
                   .WillOnce(Return(0));
     EXPECT_CALL(mock_journal_replay, process(_, _, _))
-                  .WillOnce(DoAll(WithArg<1>(CompleteContext(0, NULL)),
+                  .WillOnce(DoAll(WithArg<1>(CompleteContext(0, static_cast<ContextWQ*>(NULL))),
                                   WithArg<2>(Invoke(this, &TestMockJournal::save_commit_context))));
   }
 
@@ -370,7 +370,7 @@ public:
 
   void expect_stop_append(::journal::MockJournaler &mock_journaler, int r) {
     EXPECT_CALL(mock_journaler, stop_append(_))
-                  .WillOnce(CompleteContext(r, NULL));
+                  .WillOnce(CompleteContext(r, static_cast<ContextWQ*>(NULL)));
   }
 
   void expect_committed(::journal::MockJournaler &mock_journaler,
@@ -400,7 +400,7 @@ public:
 
   void expect_flush_commit_position(::journal::MockJournaler &mock_journaler) {
     EXPECT_CALL(mock_journaler, flush_commit_position(_))
-                  .WillOnce(CompleteContext(0, NULL));
+                  .WillOnce(CompleteContext(0, static_cast<ContextWQ*>(NULL)));
   }
 
   int when_open(MockJournal &mock_journal) {