Exceptions: Difference between revisions

no edit summary
(coding tasks)
No edit summary
Line 6: Line 6:


* Remove all current OOM handling code
* Remove all current OOM handling code
* Rewrite call sites that ignore nsresults


* Rewrite call sites that use NS_SUCCEEDED
* Rewrite call sites that use NS_SUCCEEDED
* Rewrite call sites that ignore nsresults


These steps are explained in more detail below. And by the way, we'd love to have community help with any of these.  
These steps are explained in more detail below. And by the way, we'd love to have community help with any of these.  
Line 66: Line 66:


Coding Task 2: Dehydra GCC script to detect explicit tests for NS_OUT_OF_MEMORY return value.
Coding Task 2: Dehydra GCC script to detect explicit tests for NS_OUT_OF_MEMORY return value.
= Fixing Ignored nsresults =
== Background ==
There are a fair number of call sites that ignore nsresult return values. This can be for several reasons, including:
* The caller checks failure using some other condition (e.g., a null return value)
* The function being called always returns NS_OK.
* At this call site, the caller has ensured that the function will succeed.
* The caller doesn't need to respond to errors.
These calls need checking before we can enable exceptions. In general, it won't be possible to ensure that a function doesn't throw an exception, especially if we use exceptions for OOM. Thus, call sites that now ignore nsresults need to be looked at and made exception safe.
== Finding Ignored nsresults ==
The key need here is a tool to automatically find call sites that ignore return values. There is a script under development (by dmandelin) that does this, but it needs to be improved to handle all the special cases, such as checking for a null return value.
Once the list is in place, the calls will need manual attention.


= Removing NS_SUCCEEDED =
= Removing NS_SUCCEEDED =
Line 97: Line 120:
This would be fairly easy to rewrite to the exceptions version, because the NS_FAILED check is easily identified as equivalent to letting the exception propagate to the caller.
This would be fairly easy to rewrite to the exceptions version, because the NS_FAILED check is easily identified as equivalent to letting the exception propagate to the caller.


= Fixing Ignored nsresults =
== Background ==
There are a fair number of call sites that ignore nsresult return values. This can be for several reasons, including:
* The caller checks failure using some other condition (e.g., a null return value)
* The function being called always returns NS_OK.
* At this call site, the caller has ensured that the function will succeed.
* The caller doesn't need to respond to errors.
These calls need checking before we can enable exceptions. In general, it won't be possible to ensure that a function doesn't throw an exception, especially if we use exceptions for OOM. Thus, call sites that now ignore nsresults need to be looked at and made exception safe.
== Finding Ignored nsresults ==
The key need here is a tool to automatically find call sites that ignore return values. There is a script under development (by dmandelin) that does this, but it needs to be improved to handle all the special cases, such as checking for a null return value.
Once the list is in place, the calls will need manual attention.


= Old Material =
= Old Material =
313

edits