ianh / owl

A parser generator for visibly pushdown languages.
MIT License
746 stars 21 forks source link

Completion of error handling #16

Closed elfring closed 5 years ago

elfring commented 5 years ago

Would you like to add more error handling for return values from functions like the following?

ianh commented 5 years ago

The return value of malloc is already checked anywhere the src/alloc.h header is included (see src/alloc.h:37). I might as well add a similar check to the call to fwrite.

ianh commented 5 years ago

Added in ce800c8.

ianh commented 5 years ago

There are other calls to fwrite, but they should just be going to stdout/stderr. I'm not sure detecting errors there is worthwhile.

elfring commented 5 years ago

The return value of malloc is already checked

Would it be clearer to use your own function names directly instead of the applied renaming?


I suggest to avoid ignorance of return values a bit more. Would you like to detect every error situation as early as possible?

ianh commented 5 years ago

It may be slightly clearer, but I think it also makes the code harder to read. I only added those checks because of the WebAssembly target, where malloc failure actually happens somewhat frequently—on other platforms it's less of a concern.

elfring commented 5 years ago

A few update candidates were left over.