-
Notifications
You must be signed in to change notification settings - Fork 674
Avoid tyecast warnings in inflate_with_eb
#3066
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
base: develop
Are you sure you want to change the base?
Conversation
pps83
left a comment
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.
fixes warnigs like this:
1>C:\boost_1_90_0\boost\beast\websocket\detail\impl_base.hpp(186,35): warning C4267: '+=': conversion from 'size_t' to 'uint8_t', possible loss of data
1> (compiling source file '../src/test/WebSocketTest.cpp')
|
The logic is correct, const std::uint8_t eb[4] = { 0x00, 0x00, 0xff, 0xff };
zs.next_in = eb + pmd_->rd_eb_consumed;
zs.avail_in = sizeof(eb) - pmd_->rd_eb_consumed;
inflate(zs, ec);
pmd_->rd_eb_consumed += zs.total_in;
BOOST_ASSERT(pmd_->rd_eb_consumed <= sizeof(eb));
if(ec == zlib::error::need_buffers)
ec.clear();Changing pmd_->rd_eb_consumed += zs.total_in; |
this part is very not obvious. What makes it correct? The assert? That There is no benefit to use
That's not about safety. There is a warning because consumed size is accumulated to a byte instead of a type meant to store sizes. Simple as that. |
|
|
this part is not obvious. Even if it cannot be more than 4, there is no benefit of using uint8_t: If you think it's better to cast, let me know and I'll update the patch to a cast instead. In any case, I think it should be |
No description provided.