[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a warning in ios-dev-stream.c

From: Jose E. Marchesi
Subject: Re: a warning in ios-dev-stream.c
Date: Sat, 20 Feb 2021 13:28:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Gcc gives me a warning:
> ios-dev-stream.c: In function 'ios_dev_stream_pread':
> ios-dev-stream.c:184:7: warning: ignoring return value of 'fread',
> declared with attribute warn_unused_result [-Wunused-result]
>        fread (temp, to_be_read, 1, sio->file);
>        ^
> I think the warning is justified: If someone truncates the file just before
> the fread() call happens, fread() will read nothing, and the following
> ios_buffer_pwrite() call will write an uninitialized value?

Egeyar, can you comment on this?

In ios_dev_stream_pread, we may need to also loop on fread in the `else'
part of the `ios_buffer_get_end_offset (buffer) == offset' conditional
to assure to_be_read bytes are read?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]