lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] Proposing change to netif state member


From: Sprow
Subject: Re: [lwip-devel] Proposing change to netif state member
Date: Mon, 19 Mar 2012 18:37:05 +0000 (GMT)
User-agent: Pluto/2.04e (RISC-OS/4.02) POPstar/2.05

In article <address@hidden>,
   Bill Auerbach <address@hidden> wrote:
> It would be nice to override the void type in void *state in struct 
> netif.h.
> This is the pointer to be used by the Ethernet hardware port or other
> user-code and it would be nice to use it with the correct type instead of
> casting whenever it's used.

I just use

  err_t some_netif_function(struct netif *netif)
  {
    ethernetif_t *netstate = netif->state;
    :
    netstate->mything = 1;
    netstate->stuff++;
    :
    return ERR_OK;
  }

the first line reduces to no code output since it's just a pointer
assignment but gives it the correct type for later use. You might also find
you get smaller code since you don't have to keep dereferencing netif.

> #ifdef NETIF_STATE_TYPE
>   NETIF_STATE_TYPE state;
> #else
>   void *state;
> #endif
>
> And in cc.h I can use:
>
> #define NETIF_STATE_TYPE struct myPortDescriptor *

Please at least leave the '*' with the state!
Robert.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]