Re: [PATCH 03/29] modpost: add read_text_file() and get_line() helpers

Masahiro Yamada
2020-05-23T04:19:43Z

On Wed, May 20, 2020 at 9:29 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Wed, May 20, 2020 at 09:17:45PM +0900, Masahiro Yamada wrote:
>
> > The specification [1] says this:
> >
> > "The value returned may be less than nbyte if the number of bytes
> > left in the file is less than nbyte, if the read() request was
> > interrupted by a signal, or if the file is a pipe or FIFO or
> > special file and has fewer than nbyte bytes immediately available
> > for reading."
> >
> >
> > This case does not meet any of 'if ...' parts.
>
> So nobody ever ^Z's their build? I really don't think you can assume
> that you'll never get a signal. That's just asking for trouble.
>
> Doing the right thing here is 'trivial', there is absolutely no reason
> to not do it.

In my testing, read() seems robust against ^Z,
but perhaps it might be implementation-defined ?

I think you are right.
We can gain extra safety with a trivial change.

--
Best Regards
Masahiro Yamada