lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architectur


From: Dirk Ziegelmeier
Subject: [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture
Date: Tue, 13 Dec 2016 06:02:25 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0

Follow-up Comment #13, bug #49827 (project lwip):

You correctly described the problems that could happen when you "cast away
constness": you may accidentally modify data in read-only memory.
A _good_ interface declares all parameters const that are not modified during
the function call.
Then, how do you verify that you do not accidentally pass const data to
function that tries to modify it? Turn on gcc -Wconst-cast warning. The
LWIP_CONST_CAST macro makes this warning go away by casting via a number. By
using this macro, you declare "I know this is dangerous, and I know what I'm
doing.
Last, const parameters help the compiler to optimize, which is desirable in a
lightweight stack.


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?49827>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

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