buglwIP - A Lightweight TCP/IP stack - Bugs: bug #46594, Useless condition judegement

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #46594: Useless condition judegement

Submitted by:  April M <april_m>
Submitted on:  Thu 03 Dec 2015 05:24:37 AM UTC  
 
Category: Network driversSeverity: 3 - Normal
Item Group: Change RequestStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None
lwIP version: git head

Thu 03 Dec 2015 04:21:05 PM UTC, comment #2:

Here's the entire block of code. Comment above indicates it's checking for loop_cnt_current overflowing and wrapping (which would be a smaller value)

#if LWIP_LOOPBACK_MAX_PBUFS
clen = pbuf_clen(r);
/* check for overflow or too many pbuf on queue */
if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||
((netif->loop_cnt_current + clen) > LWIP_LOOPBACK_MAX_PBUFS)) {
pbuf_free(r);
LINK_STATS_INC(link.memerr);
LINK_STATS_INC(link.drop);
MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
return ERR_MEM;
}

This seems like a valid check to me

Joel Cunningham <jcunningham>
Project Member
Thu 03 Dec 2015 03:11:19 PM UTC, comment #1:

Without looking at the context of this code, it's seems probable that the code was checking if the loop_cnt_current would wrap the 16 bit value?

Patrick Klos <pklos>
Thu 03 Dec 2015 05:24:37 AM UTC, original submission:

In netif.c netif_loop_outpu() Line 725
if (((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||

Since netif->loop_cnt_current is u16_t and clen is u8_t, (netif->loop_cnt_current + clen) will always be larger than or equal to netif->loop_cnt_current, which makes the condition judegement uselsss for it will always return false.

April M <april_m>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dziegel (Updated the item)
  • -unavailable- added by jcunningham (Posted a comment)
  • -unavailable- added by pklos (Posted a comment)
  • -unavailable- added by april_m (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 05 Dec 2015 08:12:21 PM UTCdziegelStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1