Avoid tyecast warnings in inflate_with_eb#3066
Conversation
pps83
left a comment
There was a problem hiding this comment.
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 |
If
I would have fully agreed with you if this were a user-facing interface. Even so, I still agree with your point, given that Thank you. |
No description provided.