input/{async,rewind}, decoder/dsdiff: use std::cmp_*() for safer integer comparisons
This commit is contained in:
parent
cc291e8c98
commit
e4ba736d03
|
@ -387,7 +387,7 @@ dsdiff_decode_chunk(DecoderClient &client, InputStream &is,
|
||||||
/* see how much aligned data from the remaining chunk
|
/* see how much aligned data from the remaining chunk
|
||||||
fits into the local buffer */
|
fits into the local buffer */
|
||||||
size_t now_size = buffer_size;
|
size_t now_size = buffer_size;
|
||||||
if (remaining_bytes < (offset_type)now_size) {
|
if (std::cmp_less(remaining_bytes, now_size)) {
|
||||||
unsigned now_frames = remaining_bytes / frame_size;
|
unsigned now_frames = remaining_bytes / frame_size;
|
||||||
now_size = now_frames * frame_size;
|
now_size = now_frames * frame_size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ AsyncInputStream::Seek(std::unique_lock<Mutex> &lock,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const size_t nbytes =
|
const size_t nbytes =
|
||||||
new_offset - offset < (offset_type)r.size()
|
std::cmp_less(new_offset - offset, r.size())
|
||||||
? new_offset - offset
|
? new_offset - offset
|
||||||
: r.size();
|
: r.size();
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ RewindInputStream::Read(std::unique_lock<Mutex> &lock,
|
||||||
|
|
||||||
size_t nbytes = input->Read(lock, ptr, read_size);
|
size_t nbytes = input->Read(lock, ptr, read_size);
|
||||||
|
|
||||||
if (input->GetOffset() > (offset_type)sizeof(buffer))
|
if (std::cmp_greater(input->GetOffset(), sizeof(buffer)))
|
||||||
/* disable buffering */
|
/* disable buffering */
|
||||||
tail = 0;
|
tail = 0;
|
||||||
else if (tail == (size_t)offset) {
|
else if (tail == (size_t)offset) {
|
||||||
|
|
Loading…
Reference in New Issue