[ipxe-devel] [PATCH 1/1] [intel] Add PCI device IDs for Intel I218-LM and I218-V
Michael Brown
mcb30 at ipxe.org
Thu Jan 28 13:13:51 UTC 2016
On 28/01/16 13:06, Thomas Miletich wrote:
> @Michael: somewhat OT, but there seems to be an unreachable call
>> intel_destroy_ring ( intel, &intel->rx );
>
> in intel_open()
Yes, that's the error recovery code to undo the effects of
intel_create_ring(...->rx). My usual pattern for error handling is:
if ( ( rc = try_thing_one() ) != 0 )
goto err_thing_one;
...
if ( ( rc = try_thing_two() ) != 0 )
goto err_thing_two;
...
...
return 0;
...
undo_thing_two();
err_thing_two:
...
undo_thing_one();
err_thing_one:
...
return rc
This means that the error recovery code is always present when the code
is first written. In future, when try_thing_three() is added to the
function, the developer doesn't need to remember to add the logically
unrelated undo_thing_two().
The error recovery code for the latest possible error in the function
will always be unreachable with this design pattern.
Michael
More information about the ipxe-devel
mailing list