mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-30 10:17:08 +03:00
coap-server.c: Fix warnings on 32-bit architectures
Casting an unsigned long to void * caused a compiler warning on 32-bit architectures. This change uses unsigned int as this has a sufficient range for the respective calculation and introduces a union to avoid the explicit type cast.
This commit is contained in:
1 parent
39592e8519
commit
d6c25a9a07
1 file changed
+12
-3
+12
-3
@@ -68,6 +68,12 @@ static int support_dynamic = 0;
|
||||
/* This variable is used to mimic long-running tasks that require
|
||||
* asynchronous responses. */
|
||||
static coap_async_state_t *async = NULL;
|
||||
|
||||
/* A typedef for transfering a value in a void pointer */
|
||||
typedef union {
|
||||
unsigned int val;
|
||||
void *ptr;
|
||||
} async_data_t;
|
||||
#endif /* WITHOUT_ASYNC */
|
||||
|
||||
#ifdef __GNUC__
|
||||
@@ -244,11 +250,13 @@ hnd_get_async(coap_context_t *ctx,
|
||||
delay = delay * 10 + (*p - '0');
|
||||
}
|
||||
|
||||
async_data_t data;
|
||||
data.val = COAP_TICKS_PER_SECOND * delay;
|
||||
async = coap_register_async(ctx,
|
||||
session,
|
||||
request,
|
||||
COAP_ASYNC_SEPARATE | COAP_ASYNC_CONFIRM,
|
||||
(void *)(COAP_TICKS_PER_SECOND * delay));
|
||||
data.ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -268,8 +276,9 @@ check_async(coap_context_t *ctx,
|
||||
COAP_RESPONSE_CODE(205), 0, size);
|
||||
if (!response) {
|
||||
coap_log(LOG_DEBUG, "check_async: insufficient memory, we'll try later\n");
|
||||
async->appdata =
|
||||
(void *)((unsigned long)async->appdata + 15 * COAP_TICKS_PER_SECOND);
|
||||
async_data_t data = { .ptr = async->appdata };
|
||||
data.val = data.val + 15 * COAP_TICKS_PER_SECOND;
|
||||
async->appdata = data.ptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user