Exceptions: Difference between revisions

1,482 bytes added ,  31 January 2008
ignored nsresults
(ns_succeeded)
(ignored nsresults)
Line 60: Line 60:


the if statement would be deleted.
the if statement would be deleted.
For these tasks, we need a full automatic rewriting system, with a pattern detection component and a patch generation component. The example patterns given here can be detected by looking at ASTs, so [[Dehydra GCC]] would be a great tool to use for detecting them. Once we have the list of patterns (say, as line numbers where the if statements start), we can work on an Elsa-based patch generator.


= Removing NS_SUCCEEDED =
= Removing NS_SUCCEEDED =
Line 90: Line 92:


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 =


== Benefits of Exceptions ==
== Benefits of Exceptions ==
313

edits