Re: [hatari-devel] (raw) MIDI connection reliability?

[ Thread Index | Date Index | More Archives ]


On 18.6.2022 15.46, Thomas Huth wrote:
Am Sat, 18 Jun 2022 14:59:24 +0300
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
Manual page says:
         fgetc(), getc(), and getchar() return the character read as an
         char cast to an int or EOF on end of file *or error*.

Hmm, interesting, I think you read the man page differently than I did.

I interpreted it that way:

	(unsigned character) OR (EOF if (end of of file or error))

while you read it that way:

	(unsigned character) OR (EOF if end of file) OR (error)

It's ambiguous in the man-page, indeed.

The Posix version (man 3p fgetc) of the man page is more precise:

        Upon successful completion, fgetc() shall return the next byte from the  in‐
        put  stream  pointed  to  by  stream.   If the end-of-file indicator for the
        stream is set, or if the stream is at end-of-file, the end-of-file indicator
        for  the  stream  shall be set and fgetc() shall return EOF. If a read error
        occurs, the error indicator for the stream shall be set, fgetc()  shall  re‐
        turn EOF, and shall set errno to indicate the error.

Thanks for clarifying that!

Anyway, since EOF is guaranteed to be negative, it shouldn't
really matter much in this case, so never mind, let's just
leave the code as it is.

I think I need to update logging to check errno instead of return value. Now it ignores all errors as they all get mapped to EOF return value.

	- Eero

Mail converted by MHonArc 2.6.19+