[PATCH] libertas: fix error handling

Marcelo Tosatti marcelo at kvack.org
Wed Jul 18 03:07:09 EDT 2007


Hi Holger,

On Tue, Feb 27, 2007 at 09:41:33AM +0100, Holger Schurig wrote:
> > 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;
> }

Looks good.

> 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.

Yes, thats right. It might be worth merging them together, but maybe not
(both are pretty large already).



More information about the libertas-dev mailing list