lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] Re: [patch #6414] Avoid compiler errors/warnings with mem_s


From: Iordan Neshev
Subject: [lwip-devel] Re: [patch #6414] Avoid compiler errors/warnings with mem_size_t if MEM_LIBC_MALLOC
Date: Wed, 20 Feb 2008 13:43:38 +0100
User-agent: Thunderbird 1.5.0.12 (Windows/20070509)

Jonathan Larmour wrote:
URL:
  <http://savannah.nongnu.org/patch/?6414>

                 Summary: Avoid compiler errors/warnings with mem_size_t if
MEM_LIBC_MALLOC
  ...

    _______________________________________________________

Details:

As per the discussion "Possible mistake in mem.h" here:
http://lists.gnu.org/archive/html/lwip-devel/2008-01/threads.html

here is an untested patch.

Can someone (Iordan?) please verify it resolves the issue.

Note that I had to remove the MEM_SIZE_F format string, since I could not do
anything sane with it if mem_size_t is size_t. The size of size_t is unknown
for the purposes of determining the format specifier, and getting the wrong
size could screw up the stack on some architectures. I doubt the %z specifier
(the offical ISO C 99 way) is portable enough to rely on. We could a SIZE_T_F
requirement on ports, but that seems arduous given the only use is from a
debug statistics display function, so I've just cast to 32.

Kieran, please let me know if this is ok for check-in prior to 1.3.0 or not
(once tested).

Jifl




Hello
The patch solves the problem :)
but rises other 3 warnings that are trivial, and IMHO can be fixed right now without discussion.

There are 3 lines where the return value of mem_malloc() (which is void*) is not casted
to the target types. Someone just forgot this. There is the list:


pbuf.c, line 210:
p = (struct pbuf*) mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length));// casted!!!

ppp.c, line 401:
outpacket_buf[i] = (u_char *) mem_malloc(PPP_MRU+PPP_HDRLEN); // casted!!!

httpd.c, line 215 (httpserver_raw example)
hs = (struct http_state *) mem_malloc(sizeof(struct http_state)); // casted!!!

Searching for mem_malloc I noticed some other places where the return value
should also be casted, but they are ignored because of the #ifdef-s.

Greetings
Iordan Neshev





reply via email to

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