lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Is LWIP_SUPPORT_CUSTOM_PBUF functionality proper ?


From: Arpit Agarwal
Subject: [lwip-users] Is LWIP_SUPPORT_CUSTOM_PBUF functionality proper ?
Date: Mon, 07 Nov 2016 06:20:46 +0000

 

Hello All,

I am facing assertion fail issue in pbuf_free API. The code where assert fails is mentioned below.

if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0)
      {
        struct pbuf_custom *pc = (struct pbuf_custom *)p;
        LWIP_ASSERT("pc->custom_free_function != NULL",
                    pc->custom_free_function != NULL);
        pc->custom_free_function(p);
      }

 

I have two queries :

1. Is it proper to typecast struct pbuf to struct pbuf_custom as in above code "struct pbuf_custom *pc = (struct pbuf_custom *)p;", as if the condition in if statement is true, then pbuf "p" should be a member of some struct of type pbuf_custom and hence typecasting like this is improper.

2. If the typecasting is proper:

Although its good to have assertion check, but may I know in which scenario this assertion can fail ? Because whenever the flag PBUF_FLAG_IS_CUSTOM is set only at one place i.e. in "pbuf_alloced_custom" API, and if that API returns properly, then custom_free_function member of strct pbuf_custom is always set to "ipfrag_free_pbuf_custom" and hence assertion fail should not happen.

Please help me out where I am going wrong in my understanding.

 

Thanks,

Arpit

 



reply via email to

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