drivers can_native_linux: Avoid using ssize
ssize is a POSIX.1-2001 extension, which may or may not be provided by the C library, or may be defined to a different size in the host and embedded C library. Two internal functions were returning ssize, but one of them was a trampoline into the same host API, which is already provided by the native simulator so let's just use that instead. The other is only carrying data that fits into an int and is anyhow being cast in/to ints, so let's just avoid the trouble by defining it as returning int. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
parent
92af172159
commit
5382f827d6
3 changed files with 5 additions and 11 deletions
|
|
@ -18,6 +18,7 @@
|
|||
#include <zephyr/net/socketcan_utils.h>
|
||||
|
||||
#include "can_native_linux_adapt.h"
|
||||
#include "nsi_host_trampolines.h"
|
||||
|
||||
LOG_MODULE_REGISTER(can_native_linux, CONFIG_CAN_LOG_LEVEL);
|
||||
|
||||
|
|
@ -179,7 +180,7 @@ static int can_native_linux_send(const struct device *dev, const struct can_fram
|
|||
data->tx_callback = callback;
|
||||
data->tx_user_data = user_data;
|
||||
|
||||
ret = linux_socketcan_write_data(data->dev_fd, &sframe, mtu);
|
||||
ret = nsi_host_write(data->dev_fd, &sframe, mtu);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot send CAN data len %d (%d)", sframe.len, -errno);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ int linux_socketcan_poll_data(int fd)
|
|||
return -EAGAIN;
|
||||
}
|
||||
|
||||
ssize_t linux_socketcan_read_data(int fd, void *buf, size_t buf_len, bool *msg_confirm)
|
||||
int linux_socketcan_read_data(int fd, void *buf, size_t buf_len, bool *msg_confirm)
|
||||
{
|
||||
struct canfd_frame *frame = (struct canfd_frame *)buf;
|
||||
struct msghdr msg = {0};
|
||||
|
|
@ -125,7 +125,7 @@ ssize_t linux_socketcan_read_data(int fd, void *buf, size_t buf_len, bool *msg_c
|
|||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
|
||||
int ret = recvmsg(fd, &msg, MSG_WAITALL);
|
||||
int ret = (int)recvmsg(fd, &msg, MSG_WAITALL);
|
||||
|
||||
if (msg_confirm != NULL) {
|
||||
*msg_confirm = (msg.msg_flags & MSG_CONFIRM) != 0;
|
||||
|
|
@ -145,11 +145,6 @@ ssize_t linux_socketcan_read_data(int fd, void *buf, size_t buf_len, bool *msg_c
|
|||
return ret;
|
||||
}
|
||||
|
||||
ssize_t linux_socketcan_write_data(int fd, void *buf, size_t buf_len)
|
||||
{
|
||||
return write(fd, buf, buf_len);
|
||||
}
|
||||
|
||||
int linux_socketcan_set_mode_fd(int fd, bool mode_fd)
|
||||
{
|
||||
int opt = mode_fd ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ int linux_socketcan_iface_close(int fd);
|
|||
|
||||
int linux_socketcan_poll_data(int fd);
|
||||
|
||||
ssize_t linux_socketcan_read_data(int fd, void *buf, size_t buf_len, bool *msg_confirm);
|
||||
|
||||
ssize_t linux_socketcan_write_data(int fd, void *buf, size_t buf_len);
|
||||
int linux_socketcan_read_data(int fd, void *buf, size_t buf_len, bool *msg_confirm);
|
||||
|
||||
int linux_socketcan_set_mode_fd(int fd, bool mode_fd);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue