lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [patch #10088] allow "typedef u32_t mem_size_t" when MEM_SI


From: ODH
Subject: [lwip-devel] [patch #10088] allow "typedef u32_t mem_size_t" when MEM_SIZE > 640000L and MEM_USE_POOLS
Date: Wed, 21 Jul 2021 16:51:35 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0

URL:
  <https://savannah.nongnu.org/patch/?10088>

                 Summary: allow "typedef u32_t mem_size_t" when MEM_SIZE >
640000L and MEM_USE_POOLS
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: odh
            Submitted on: Wed 21 Jul 2021 08:51:33 PM UTC
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

Currently, while MEM_USE_POOLS is true,
u16_t is forced for mem_size_t, even when MEM_SIZE cannot fit into a type as
small as u16_t.
The following patch duplicates the test used if MEM_USE_POOLS is false, and
which, if MEM_SIZE > 64000, uses u32_t for mem_size_t.

This allows MEM_USE_POOLS while MEM_SIZE > 0xFFFFU without an overflow error.

Patch below:

diff --git a/src/include/lwip/mem.h b/src/include/lwip/mem.h
index ff208d25..76aeda56 100644
--- a/src/include/lwip/mem.h
+++ b/src/include/lwip/mem.h
@@ -52,8 +52,17 @@ typedef size_t mem_size_t;

 #elif MEM_USE_POOLS

+/* MEM_SIZE would have to be aligned, but using 64000 here instead of
+ * 65535 leaves some room for alignment...
+ */
+#if MEM_SIZE > 64000L
+typedef u32_t mem_size_t;
+#define MEM_SIZE_F U32_F
+#else
 typedef u16_t mem_size_t;
 #define MEM_SIZE_F U16_F
+#endif /* MEM_SIZE > 64000 */
+#endif

 #else






    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?10088>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

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