buglwIP - A Lightweight TCP/IP stack - Bugs: bug #54850, lwip definition of htonX and ntohX...

 
 

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

bug #54850: lwip definition of htonX and ntohX do not properly cast to unsigned when byte order is Big Endian

Submitter:  Ivan Warren <ivanw>
Submitted:  Wed 17 Oct 2018 07:57:18 AM UTC
   
 
Category:  Platform ports Severity:  3 - Normal
Item Group:  Compiler Warning Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  2.1.0

Wed 17 Oct 2018 07:44:49 PM UTC, comment #3: 

Thanks Simon & Dirk.

Note that my current project is just a hobby retro computing project (Having an IP stack on VM/370 under hercules). So any bug I file will always be low priority (and I will always attempt to submit a solution)

--Ivan

Ivan Warren <ivanw>
Wed 17 Oct 2018 06:29:38 PM UTC, comment #2: 

In the days of even ARM processors being little endian, big endian systems are not used that often any more (which is odd at least for networking systems).

Being like that, please don't hesitate to inform us of any other glitches you observe on your big endian platform :-)

Simon Goldschmidt <goldsimon>
Group administrator
Wed 17 Oct 2018 06:24:17 PM UTC, comment #1: 

Fixed, thanks for reporting!

Dirk Ziegelmeier <dziegel>
Group administrator
Wed 17 Oct 2018 07:57:18 AM UTC, original submission:  

in src/include/lwip/def.h the definitions for
- lwip_ntohl
- lwip_htonl
- lwip_ntohs
- lwip_htons

on big endian systems are defined as : #define lwip_xxx(x) (x)

However, this leads to compiler warning/errors sign compares if 'x' is signed since the result is expected to be an unsigned value (even if x is a signed scalar).

Fixed with the following patch :

diff --git a/src/include/lwip/def.h b/src/include/lwip/def.h
index 3d6e107e..200af1c3 100644
--- a/src/include/lwip/def.h
+++ b/src/include/lwip/def.h
@@ -83,14 +83,14 @@ extern "C" {
 #endif

 #if BYTE_ORDER == BIG_ENDIAN
-#define lwip_htons(x) (x)
-#define lwip_ntohs(x) (x)
-#define lwip_htonl(x) (x)
-#define lwip_ntohl(x) (x)
-#define PP_HTONS(x) (x)
-#define PP_NTOHS(x) (x)
-#define PP_HTONL(x) (x)
-#define PP_NTOHL(x) (x)
+#define lwip_htons(x) (u16_t)(x)
+#define lwip_ntohs(x) (u16_t)(x)
+#define lwip_htonl(x) (u32_t)(x)
+#define lwip_ntohl(x) (u32_t)(x)
+#define PP_HTONS(x) (u16_t)(x)
+#define PP_NTOHS(x) (u16_t)(x)
+#define PP_HTONL(x) (u32_t)(x)
+#define PP_NTOHL(x) (u32_t)(x)
 #else /* BYTE_ORDER != BIG_ENDIAN */
 #ifndef lwip_htons
 u16_t lwip_htons(u16_t x);

Ivan Warren <ivanw>

 

(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 goldsimon (Posted a comment)
  • -email is unavailable- added by dziegel (Posted a comment)
  • -email is unavailable- added by ivanw (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
    2018-10-17 dziegel StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code