mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-29 19:46:19 +08:00
Fix bug #49827: wrong cast to size_t on 16-bit x86 architecture
I hope I caught all of them. TODO: Same for casts to get rid of alignment warnings, these are also casts via size_t
This commit is contained in:
@@ -103,11 +103,11 @@ lwip_strnstr(const char* buffer, const char* token, size_t n)
|
||||
const char* p;
|
||||
int tokenlen = (int)strlen(token);
|
||||
if (tokenlen == 0) {
|
||||
return (char *)(size_t)buffer;
|
||||
return LWIP_CONST_CAST(char *, buffer);
|
||||
}
|
||||
for (p = buffer; *p && (p + tokenlen <= buffer + n); p++) {
|
||||
if ((*p == *token) && (strncmp(p, token, tokenlen) == 0)) {
|
||||
return (char *)(size_t)p;
|
||||
return LWIP_CONST_CAST(char *, p);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -1119,7 +1119,7 @@ pbuf_skip_const(const struct pbuf* in, u16_t in_offset, u16_t* out_offset)
|
||||
struct pbuf*
|
||||
pbuf_skip(struct pbuf* in, u16_t in_offset, u16_t* out_offset)
|
||||
{
|
||||
return (struct pbuf*)(size_t)pbuf_skip_const(in, in_offset, out_offset);
|
||||
return LWIP_CONST_CAST(struct pbuf*, pbuf_skip_const(in, in_offset, out_offset));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -179,7 +179,7 @@ void sys_timeouts_init(void)
|
||||
for (i = 1; i < LWIP_ARRAYSIZE(lwip_cyclic_timers); i++) {
|
||||
/* we have to cast via size_t to get rid of const warning
|
||||
(this is OK as cyclic_timer() casts back to const* */
|
||||
sys_timeout(lwip_cyclic_timers[i].interval_ms, cyclic_timer, (void*)(size_t)&lwip_cyclic_timers[i]);
|
||||
sys_timeout(lwip_cyclic_timers[i].interval_ms, cyclic_timer, LWIP_CONST_CAST(void*, &lwip_cyclic_timers[i]));
|
||||
}
|
||||
|
||||
/* Initialise timestamp for sys_check_timeouts */
|
||||
|
||||
Reference in New Issue
Block a user