[PATCH] libertas: fix error handling

Holger Schurig hs4233 at mail.mn-solutions.de
Tue Feb 27 03:41:33 EST 2007


> I understand... But I think its cleaner and less bugprone if
> we handle errors right at the callers, not later by a common
> function.

Okay, then I have to code it with some callback function. 
Pseudocode follows:


libertas_add_card(wlan_private *priv,
                  void (*set_hw_functions)(wlan_private *priv) )
{
    if (!set_hw_function)
        error_out;

    add-wlan ...
    if (error)
       goto error_out2;

    set_hw_function();

    activate-card ...
    if (error) goto error_out_3;

    return priv;

error_out3:
    clean-up-mess-of-activate-card
error_out2:
    clean_up_mess-of_add-wlan;
error_out:
    return NULL;
}



BTW: why do we have a wlan_private and an adapter pointer?  As 
far as I can see, there is a 1:1 relationship between 
wlan_private and wlan_adapter, because each 
wlan_private->adapter points to exactly one adapter.



More information about the libertas-dev mailing list