New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: fix NULL references to be acceptable by Clang #12880
Conversation
@@ -96,7 +96,7 @@ class TestMockExclusiveLockReleaseRequest : public TestMockFixture { | |||
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)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, maybe we can take this chance to s/NULL/nullptr/ here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov
Perhaps in a second PR?
Or rather in this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's more C++ish, and cosmetic in this case . and i'd suggest do it in this commit.
@wjwithagen might want to use "tests" as the prefix of the title of your commit instead. |
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))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home/jenkins-build/build/workspace/ceph-pull-requests/src/test/librbd/operation/test_mock_ResizeRequest.cc: In member function ‘void librbd::operation::TestMockOperationResizeRequest::expect_invalidate_cache(librbd::MockImageCtx&, int)’:
/home/jenkins-build/build/workspace/ceph-pull-requests/src/test/librbd/operation/test_mock_ResizeRequest.cc:124:90: error: expected ‘)’ before ‘;’ token
.WillOnce(WithArg<1>(CompleteContext(r, static_cast<ContextWQ*>(NULL)));
^
[ 95%] Building CXX object src/test/librbd/CMakeFiles/unittest_librbd.dir/operation/test_mock_SnapshotProtectRequest.cc.o
make[3]: *** [src/test/librbd/CMakeFiles/unittest_librbd.dir/operation/test_mock_ResizeRequest.cc.o] Error 1
missing a )
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov
Yuo, thanx,
Same player shoots again.
2423b98
to
2d0d2d2
Compare
@wjwithagen might want to use "tests" as the prefix of the title of your commit instead. |
2d0d2d2
to
6ef89c7
Compare
@tchaikov |
- 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>
6ef89c7
to
cbb2d65
Compare
@wjwithagen I'm fine w/ keeping NULL, but @tchaikov requested that you switch to nullptr. |
i'm okay either way.
Jason Dillaman <notifications@github.com>于2017年1月12日 周四22:13写道:
… @wjwithagen <https://github.com/wjwithagen> I'm fine w/ keeping NULL, but
@tchaikov <https://github.com/tchaikov> requested that you switch to
nullptr.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12880 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADmv60EkYE6EySTcH18tTA-jG2MtTH7ks5rRjT0gaJpZM4LgafR>
.
|
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