mirror of
https://github.com/transmission/transmission
synced 2025-01-30 19:03:04 +00:00
Attempt to explain something to Coverity
I'm seeing 7 potentially false reported issues re. use of uninitialized buffer data here. It seems that `read` function should be properly supported by Coverity, but maybe it can't figure out the postconditions of it properly... Walking in the dark here.
This commit is contained in:
parent
10b0a280b1
commit
698bb2c418
1 changed files with 6 additions and 1 deletions
|
@ -26,7 +26,9 @@ bool tr_sys_file_read_line(tr_sys_file_t handle, char* buffer, size_t buffer_siz
|
|||
|
||||
while (buffer_size > 0)
|
||||
{
|
||||
ret = tr_sys_file_read(handle, buffer + offset, MIN(buffer_size, 1024u), &bytes_read, error);
|
||||
size_t const bytes_needed = MIN(buffer_size, 1024u);
|
||||
|
||||
ret = tr_sys_file_read(handle, buffer + offset, bytes_needed, &bytes_read, error);
|
||||
|
||||
if (!ret || (offset == 0 && bytes_read == 0))
|
||||
{
|
||||
|
@ -34,6 +36,9 @@ bool tr_sys_file_read_line(tr_sys_file_t handle, char* buffer, size_t buffer_siz
|
|||
break;
|
||||
}
|
||||
|
||||
TR_ASSERT(bytes_read <= bytes_needed);
|
||||
TR_ASSERT(bytes_read <= buffer_size);
|
||||
|
||||
int64_t delta = 0;
|
||||
|
||||
for (size_t i = 0; i < bytes_read; ++i, ++offset, --buffer_size)
|
||||
|
|
Loading…
Reference in a new issue