marian-dev icon indicating copy to clipboard operation
marian-dev copied to clipboard

fclose can fail, but Marian doesn't check for that

Open kpu opened this issue 4 years ago • 2 comments

https://github.com/marian-nmt/marian-dev/blob/e9aa7ad340bc3e407add08ef5015f3cbf7e00485/src/common/binary.cpp#L81

kpu avatar May 23 '20 20:05 kpu

This entire piece of code inside the #if irks me. Tempted to remove it just to see what breaks and where and for whom.

emjotde avatar May 23 '20 20:05 emjotde

No, this is a close on read. It cannot fail. Don't add a check.

Close is a destructor, there should be no error condition (other than you are trying to close something you didn't open, which is not something we are concerned with here).

For writing, the correct way is to flush before close and check on that, then don't check on close.

frankseide avatar May 23 '20 23:05 frankseide