|Re: [hatari-devel] (raw) MIDI connection reliability?|
[ Thread Index |
| More lists.tuxfamily.org/hatari-devel Archives
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] (raw) MIDI connection reliability?
- From: Thomas Huth <th.huth@xxxxxxxxx>
- Date: Sat, 18 Jun 2022 12:46:14 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1655556379; bh=z6zIxPJ2w20DcpwrW0zlFieIY8tul44MpBTWafJQxcA=; h=Date:From:To:Subject:From; b=OY6vz/3y9jdM+a8RC0PyXTuG6FhkwBzfhTFEgQhoZzweCZU3rm+HlwX9yMTckLso/ hUat4LtLzJy0QTiObad/PG5FPm+3f9zFlnyFkSPuHONru0q34kvyKAEwJQx9Lq6CJY OL9CID0+Qih/78pSh53m+da1wmDpmiuwBbZaBmjEnw6pmtIacJAfS3sEYTU8N9MANR vvRfNoLRiAVWt+auXqgoV4lwiYxoxfOrewGM/72DvIxdHWqi0aUaxXmbgzs8xjAasn BzHMBJ5NjmjaY0O8vFJ8vT3U7LlHvxEqraj9pw1ErUfyYqfePmO5AoM1MMwDDMnFOQ fuT2HmeoBw71w==
Am Sat, 18 Jun 2022 14:59:24 +0300
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
> On 18.6.2022 7.18, Thomas Huth wrote:
> > Am Fri, 17 Jun 2022 21:51:28 +0300
> > schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
> > ...
> >> I added output to MIDI trace on whether buffering disabling actually
> >> succeeded, and fixed issue in
> >> read error handling (it handled other errors than
> >> EOF as valid input).
> > I don't think that change wrt EOF was really necessary.
> > Midi_Host_ReadByte() only returns EOF on errors, and that's
> > also what the comment in front of the function says.
> No, it returns what fgetc() returns, or EOF if nothing is available.
> Manual page says:
> RETURN VALUE
> 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.
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.