buglwIP - A Lightweight TCP/IP stack - Bugs: bug #34541, LWIP_U32_DIFF is unnecessarily...

 
 

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

bug #34541: LWIP_U32_DIFF is unnecessarily complex

Submitted by:  Simon Goldschmidt <goldsimon>
Submitted on:  Thu 13 Oct 2011 05:34:48 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Change RequestStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: CVS Head

Thu 13 Oct 2011 05:37:37 PM UTC, comment #1:

fixed

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Thu 13 Oct 2011 05:34:48 PM UTC, original submission:

mason wrote on lwip-devel:
[..]
/** Get the absolute difference between 2 u32_t values (correcting overflows)

  • 'a' is expected to be 'higher' (without overflow) than 'b'. */

#define LWIP_U32_DIFF(a, b) (((a) >= (b)) ? ((a) - (b)) : (((a) + ((b) ^ 0xFFFFFFFF) + 1)))

Given a 32-bit unsigned value, C guarantees that the
expression ((b) ^ 0xFFFFFFFF) + 1 is always equal to
the expression -b.

[..]

Therefore LWIP_U32_DIFF reduces to

#define LWIP_U32_DIFF(a, b) ((a)-(b))

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.

 

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 goldsimon (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
    Thu 13 Oct 2011 05:37:37 PM UTCgoldsimonStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1