jakt icon indicating copy to clipboard operation
jakt copied to clipboard

runtime: Do not error when writing zero bytes to a File

Open cg-jl opened this issue 2 years ago • 3 comments

File::write might get an empty array, so fwrite() returning zero does not always mean that an error occurred. Better check that an error actually occurred before returning an Error(errno=0).

cg-jl avatar Aug 03 '22 20:08 cg-jl

Hello!

One or more of the commit messages in this PR do not match the Jakt code submission policy, please check the lint_commits CI job for more details on which commits were flagged and why. Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR.

BuggieBot avatar Aug 03 '22 20:08 BuggieBot

How about we check for 0 before even calling fwrite, and early return if so?

awesomekling avatar Aug 04 '22 08:08 awesomekling

Seems like a better option, since that's the only other case where fwrite() can return zero without having an error.

cg-jl avatar Aug 04 '22 09:08 cg-jl