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

Submitter:  April M <april_m>
Submitted:  Thu 03 Dec 2015 05:24:37 AM UTC
   
 
Category:  Network drivers Severity:  3 - Normal
Item Group:  Change Request Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned 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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-05 dziegel StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code