[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/
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, (continued)
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Alexander, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Dirk Ziegelmeier, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Alexander, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Dirk Ziegelmeier, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Alexander, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Simon Goldschmidt, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Ambroz Bizjak, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Simon Goldschmidt, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Ambroz Bizjak, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Joel Cunningham, 2016/12/12
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture,
Dirk Ziegelmeier <=
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Simon Goldschmidt, 2016/12/13
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Alexander, 2016/12/13
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Simon Goldschmidt, 2016/12/13
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Joel Cunningham, 2016/12/13
- [lwip-devel] [bug #49827] wrong cast to size_t on 16-bit x86 architecture, Ambroz Bizjak, 2016/12/13