tests/websocket: improve portability
This commit improves portability somewhat on machines where sizeof (int) is less than sizeof (void *). Note that the implementation is still not portable and will fail when you start using addresses which can not be represented by "int cast to unsigned int". On RISC-V 64-bit with RAM on 0x80000000 we previously got hit by E: Exception cause Load access fault (5) ld s0,16(a0) a0: 0xffffffff80025610 (The int should probably be changed to intptr_t if possible.) Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
This commit is contained in:
parent
9e463d023f
commit
9156c2d32e
|
@ -502,7 +502,7 @@ int websocket_send_msg(int ws_sock, const uint8_t *payload, size_t payload_len,
|
|||
/* Websocket unit test does not use socket layer but feeds
|
||||
* the data directly here when testing this function.
|
||||
*/
|
||||
ctx = INT_TO_POINTER(ws_sock);
|
||||
ctx = UINT_TO_POINTER((unsigned int) ws_sock);
|
||||
#else
|
||||
ctx = z_get_fd_obj(ws_sock, NULL, 0);
|
||||
if (ctx == NULL) {
|
||||
|
@ -675,7 +675,8 @@ int websocket_recv_msg(int ws_sock, uint8_t *buf, size_t buf_len,
|
|||
struct websocket_context *ctx;
|
||||
};
|
||||
|
||||
struct test_data *test_data = INT_TO_POINTER(ws_sock);
|
||||
struct test_data *test_data =
|
||||
UINT_TO_POINTER((unsigned int) ws_sock);
|
||||
|
||||
ctx = test_data->ctx;
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue