[Xenomai-git] Philippe Gerum : drivers/rtipc: fixup for 32bit emulation
Module: xenomai-3 Branch: master Commit: 92b6dab81dcf6d5be10642010830c359410055a7 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=92b6dab81dcf6d5be10642010830c359410055a7 Author: Philippe Gerum Date: Wed Oct 22 15:20:21 2014 +0200 drivers/rtipc: fixup for 32bit emulation --- kernel/drivers/ipc/bufp.c | 115 ++--- kernel/drivers/ipc/iddp.c | 123 +++--- kernel/drivers/ipc/internal.h | 41 - kernel/drivers/ipc/rtipc.c| 365 - kernel/drivers/ipc/xddp.c | 113 ++--- 5 files changed, 520 insertions(+), 237 deletions(-) diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c index 1e5ecf3..5ae166a 100644 --- a/kernel/drivers/ipc/bufp.c +++ b/kernel/drivers/ipc/bufp.c @@ -375,17 +375,16 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd, return -EINVAL; /* Copy I/O vector in */ - if (rtipc_get_arg(fd, iov, msg->msg_iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; + ret = rtipc_get_iovec(fd, iov, msg); + if (ret) + return ret; ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, &saddr); if (ret <= 0) return ret; /* Copy the updated I/O vector back */ - if (rtipc_put_arg(fd, msg->msg_iov, iov, - sizeof(iov[0]) * msg->msg_iovlen)) + if (rtipc_put_iovec(fd, iov, msg)) return -EFAULT; /* Copy the source address if required. */ @@ -620,8 +619,7 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd, return -EINVAL; /* Fetch the destination address to send to. */ - if (rtipc_get_arg(fd, &daddr, - msg->msg_name, sizeof(daddr))) + if (rtipc_get_arg(fd, &daddr, msg->msg_name, sizeof(daddr))) return -EFAULT; if (daddr.sipc_port < 0 || @@ -639,20 +637,16 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd, return -EINVAL; /* Copy I/O vector in */ - if (rtipc_get_arg(fd, iov, msg->msg_iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; + ret = rtipc_get_iovec(fd, iov, msg); + if (ret) + return ret; ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, &daddr); if (ret <= 0) return ret; /* Copy updated I/O vector back */ - if (rtipc_put_arg(fd, msg->msg_iov, iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; - - return ret; + return rtipc_put_iovec(fd, iov, msg) ?: ret; } static ssize_t bufp_write(struct rtdm_fd *fd, @@ -829,30 +823,27 @@ static int __bufp_setsockopt(struct bufp_socket *sk, struct rtipc_port_label plabel; struct timeval tv; rtdm_lockctx_t s; - int ret = 0; size_t len; + int ret; - if (rtipc_get_arg(fd, &sopt, arg, sizeof(sopt))) - return -EFAULT; + ret = rtipc_get_sockoptin(fd, &sopt, arg); + if (ret) + return ret; if (sopt.level == SOL_SOCKET) { switch (sopt.optname) { case SO_RCVTIMEO: - if (sopt.optlen != sizeof(tv)) - return -EINVAL; - if (rtipc_get_arg(fd, &tv, - sopt.optval, sizeof(tv))) - return -EFAULT; + ret = rtipc_get_timeval(fd, &tv, sopt.optval, sopt.optlen); + if (ret) + return ret; sk->rx_timeout = rtipc_timeval_to_ns(&tv); break; case SO_SNDTIMEO: - if (sopt.optlen != sizeof(tv)) - return -EINVAL; - if (rtipc_get_arg(fd, &tv, - sopt.optval, sizeof(tv))) - return -EFAULT; + ret = rtipc_get_timeval(fd, &tv, sopt.optval, sopt.optlen); + if (ret) + return ret; sk->tx_timeout = rtipc_timeval_to_ns(&tv); break; @@ -869,11 +860,9 @@ static int __bufp_setsockopt(struct bufp_socket *sk, switch (sopt.optname) { case BUFP_BUFSZ: - if (sopt.optlen != sizeof(len)) - return -EINVAL; - if (rtipc_get_arg(fd, &len, - sopt.optval, sizeof(len))) - return -EFAULT; + ret = rtipc_get_length(fd, &len, sopt.optval, sopt.optlen); + if (ret) + return ret; if (len == 0)
[Xenomai-git] Philippe Gerum : drivers/rtipc: fixup for 32bit emulation
Module: xenomai-3 Branch: next Commit: 92b6dab81dcf6d5be10642010830c359410055a7 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=92b6dab81dcf6d5be10642010830c359410055a7 Author: Philippe Gerum Date: Wed Oct 22 15:20:21 2014 +0200 drivers/rtipc: fixup for 32bit emulation --- kernel/drivers/ipc/bufp.c | 115 ++--- kernel/drivers/ipc/iddp.c | 123 +++--- kernel/drivers/ipc/internal.h | 41 - kernel/drivers/ipc/rtipc.c| 365 - kernel/drivers/ipc/xddp.c | 113 ++--- 5 files changed, 520 insertions(+), 237 deletions(-) diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c index 1e5ecf3..5ae166a 100644 --- a/kernel/drivers/ipc/bufp.c +++ b/kernel/drivers/ipc/bufp.c @@ -375,17 +375,16 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd, return -EINVAL; /* Copy I/O vector in */ - if (rtipc_get_arg(fd, iov, msg->msg_iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; + ret = rtipc_get_iovec(fd, iov, msg); + if (ret) + return ret; ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, &saddr); if (ret <= 0) return ret; /* Copy the updated I/O vector back */ - if (rtipc_put_arg(fd, msg->msg_iov, iov, - sizeof(iov[0]) * msg->msg_iovlen)) + if (rtipc_put_iovec(fd, iov, msg)) return -EFAULT; /* Copy the source address if required. */ @@ -620,8 +619,7 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd, return -EINVAL; /* Fetch the destination address to send to. */ - if (rtipc_get_arg(fd, &daddr, - msg->msg_name, sizeof(daddr))) + if (rtipc_get_arg(fd, &daddr, msg->msg_name, sizeof(daddr))) return -EFAULT; if (daddr.sipc_port < 0 || @@ -639,20 +637,16 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd, return -EINVAL; /* Copy I/O vector in */ - if (rtipc_get_arg(fd, iov, msg->msg_iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; + ret = rtipc_get_iovec(fd, iov, msg); + if (ret) + return ret; ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, &daddr); if (ret <= 0) return ret; /* Copy updated I/O vector back */ - if (rtipc_put_arg(fd, msg->msg_iov, iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; - - return ret; + return rtipc_put_iovec(fd, iov, msg) ?: ret; } static ssize_t bufp_write(struct rtdm_fd *fd, @@ -829,30 +823,27 @@ static int __bufp_setsockopt(struct bufp_socket *sk, struct rtipc_port_label plabel; struct timeval tv; rtdm_lockctx_t s; - int ret = 0; size_t len; + int ret; - if (rtipc_get_arg(fd, &sopt, arg, sizeof(sopt))) - return -EFAULT; + ret = rtipc_get_sockoptin(fd, &sopt, arg); + if (ret) + return ret; if (sopt.level == SOL_SOCKET) { switch (sopt.optname) { case SO_RCVTIMEO: - if (sopt.optlen != sizeof(tv)) - return -EINVAL; - if (rtipc_get_arg(fd, &tv, - sopt.optval, sizeof(tv))) - return -EFAULT; + ret = rtipc_get_timeval(fd, &tv, sopt.optval, sopt.optlen); + if (ret) + return ret; sk->rx_timeout = rtipc_timeval_to_ns(&tv); break; case SO_SNDTIMEO: - if (sopt.optlen != sizeof(tv)) - return -EINVAL; - if (rtipc_get_arg(fd, &tv, - sopt.optval, sizeof(tv))) - return -EFAULT; + ret = rtipc_get_timeval(fd, &tv, sopt.optval, sopt.optlen); + if (ret) + return ret; sk->tx_timeout = rtipc_timeval_to_ns(&tv); break; @@ -869,11 +860,9 @@ static int __bufp_setsockopt(struct bufp_socket *sk, switch (sopt.optname) { case BUFP_BUFSZ: - if (sopt.optlen != sizeof(len)) - return -EINVAL; - if (rtipc_get_arg(fd, &len, - sopt.optval, sizeof(len))) - return -EFAULT; + ret = rtipc_get_length(fd, &len, sopt.optval, sopt.optlen); + if (ret) + return ret; if (len == 0)
[Xenomai-git] Philippe Gerum : drivers/rtipc: fixup for 32bit emulation
Module: xenomai-3 Branch: next Commit: 3e65688b956fad5a9236b7e9d1fd837685994154 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3e65688b956fad5a9236b7e9d1fd837685994154 Author: Philippe Gerum Date: Wed Oct 22 15:20:21 2014 +0200 drivers/rtipc: fixup for 32bit emulation --- kernel/drivers/ipc/bufp.c | 115 ++--- kernel/drivers/ipc/iddp.c | 123 +++--- kernel/drivers/ipc/internal.h | 41 - kernel/drivers/ipc/rtipc.c| 365 - kernel/drivers/ipc/xddp.c | 113 ++--- 5 files changed, 520 insertions(+), 237 deletions(-) diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c index 1e5ecf3..5ae166a 100644 --- a/kernel/drivers/ipc/bufp.c +++ b/kernel/drivers/ipc/bufp.c @@ -375,17 +375,16 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd, return -EINVAL; /* Copy I/O vector in */ - if (rtipc_get_arg(fd, iov, msg->msg_iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; + ret = rtipc_get_iovec(fd, iov, msg); + if (ret) + return ret; ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, &saddr); if (ret <= 0) return ret; /* Copy the updated I/O vector back */ - if (rtipc_put_arg(fd, msg->msg_iov, iov, - sizeof(iov[0]) * msg->msg_iovlen)) + if (rtipc_put_iovec(fd, iov, msg)) return -EFAULT; /* Copy the source address if required. */ @@ -620,8 +619,7 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd, return -EINVAL; /* Fetch the destination address to send to. */ - if (rtipc_get_arg(fd, &daddr, - msg->msg_name, sizeof(daddr))) + if (rtipc_get_arg(fd, &daddr, msg->msg_name, sizeof(daddr))) return -EFAULT; if (daddr.sipc_port < 0 || @@ -639,20 +637,16 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd, return -EINVAL; /* Copy I/O vector in */ - if (rtipc_get_arg(fd, iov, msg->msg_iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; + ret = rtipc_get_iovec(fd, iov, msg); + if (ret) + return ret; ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, &daddr); if (ret <= 0) return ret; /* Copy updated I/O vector back */ - if (rtipc_put_arg(fd, msg->msg_iov, iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; - - return ret; + return rtipc_put_iovec(fd, iov, msg) ?: ret; } static ssize_t bufp_write(struct rtdm_fd *fd, @@ -829,30 +823,27 @@ static int __bufp_setsockopt(struct bufp_socket *sk, struct rtipc_port_label plabel; struct timeval tv; rtdm_lockctx_t s; - int ret = 0; size_t len; + int ret; - if (rtipc_get_arg(fd, &sopt, arg, sizeof(sopt))) - return -EFAULT; + ret = rtipc_get_sockoptin(fd, &sopt, arg); + if (ret) + return ret; if (sopt.level == SOL_SOCKET) { switch (sopt.optname) { case SO_RCVTIMEO: - if (sopt.optlen != sizeof(tv)) - return -EINVAL; - if (rtipc_get_arg(fd, &tv, - sopt.optval, sizeof(tv))) - return -EFAULT; + ret = rtipc_get_timeval(fd, &tv, sopt.optval, sopt.optlen); + if (ret) + return ret; sk->rx_timeout = rtipc_timeval_to_ns(&tv); break; case SO_SNDTIMEO: - if (sopt.optlen != sizeof(tv)) - return -EINVAL; - if (rtipc_get_arg(fd, &tv, - sopt.optval, sizeof(tv))) - return -EFAULT; + ret = rtipc_get_timeval(fd, &tv, sopt.optval, sopt.optlen); + if (ret) + return ret; sk->tx_timeout = rtipc_timeval_to_ns(&tv); break; @@ -869,11 +860,9 @@ static int __bufp_setsockopt(struct bufp_socket *sk, switch (sopt.optname) { case BUFP_BUFSZ: - if (sopt.optlen != sizeof(len)) - return -EINVAL; - if (rtipc_get_arg(fd, &len, - sopt.optval, sizeof(len))) - return -EFAULT; + ret = rtipc_get_length(fd, &len, sopt.optval, sopt.optlen); + if (ret) + return ret; if (len == 0)
[Xenomai-git] Philippe Gerum : drivers/rtipc: fixup for 32bit emulation
Module: xenomai-3 Branch: next Commit: 053df824650bb072381ce83e3928165eea2ce03e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=053df824650bb072381ce83e3928165eea2ce03e Author: Philippe Gerum Date: Wed Oct 22 15:20:21 2014 +0200 drivers/rtipc: fixup for 32bit emulation --- kernel/drivers/ipc/bufp.c | 115 ++--- kernel/drivers/ipc/iddp.c | 123 +++--- kernel/drivers/ipc/internal.h | 41 - kernel/drivers/ipc/rtipc.c| 365 - kernel/drivers/ipc/xddp.c | 113 ++--- 5 files changed, 520 insertions(+), 237 deletions(-) diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c index 1e5ecf3..5ae166a 100644 --- a/kernel/drivers/ipc/bufp.c +++ b/kernel/drivers/ipc/bufp.c @@ -375,17 +375,16 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd, return -EINVAL; /* Copy I/O vector in */ - if (rtipc_get_arg(fd, iov, msg->msg_iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; + ret = rtipc_get_iovec(fd, iov, msg); + if (ret) + return ret; ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, &saddr); if (ret <= 0) return ret; /* Copy the updated I/O vector back */ - if (rtipc_put_arg(fd, msg->msg_iov, iov, - sizeof(iov[0]) * msg->msg_iovlen)) + if (rtipc_put_iovec(fd, iov, msg)) return -EFAULT; /* Copy the source address if required. */ @@ -620,8 +619,7 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd, return -EINVAL; /* Fetch the destination address to send to. */ - if (rtipc_get_arg(fd, &daddr, - msg->msg_name, sizeof(daddr))) + if (rtipc_get_arg(fd, &daddr, msg->msg_name, sizeof(daddr))) return -EFAULT; if (daddr.sipc_port < 0 || @@ -639,20 +637,16 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd, return -EINVAL; /* Copy I/O vector in */ - if (rtipc_get_arg(fd, iov, msg->msg_iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; + ret = rtipc_get_iovec(fd, iov, msg); + if (ret) + return ret; ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, &daddr); if (ret <= 0) return ret; /* Copy updated I/O vector back */ - if (rtipc_put_arg(fd, msg->msg_iov, iov, - sizeof(iov[0]) * msg->msg_iovlen)) - return -EFAULT; - - return ret; + return rtipc_put_iovec(fd, iov, msg) ?: ret; } static ssize_t bufp_write(struct rtdm_fd *fd, @@ -829,30 +823,27 @@ static int __bufp_setsockopt(struct bufp_socket *sk, struct rtipc_port_label plabel; struct timeval tv; rtdm_lockctx_t s; - int ret = 0; size_t len; + int ret; - if (rtipc_get_arg(fd, &sopt, arg, sizeof(sopt))) - return -EFAULT; + ret = rtipc_get_sockoptin(fd, &sopt, arg); + if (ret) + return ret; if (sopt.level == SOL_SOCKET) { switch (sopt.optname) { case SO_RCVTIMEO: - if (sopt.optlen != sizeof(tv)) - return -EINVAL; - if (rtipc_get_arg(fd, &tv, - sopt.optval, sizeof(tv))) - return -EFAULT; + ret = rtipc_get_timeval(fd, &tv, sopt.optval, sopt.optlen); + if (ret) + return ret; sk->rx_timeout = rtipc_timeval_to_ns(&tv); break; case SO_SNDTIMEO: - if (sopt.optlen != sizeof(tv)) - return -EINVAL; - if (rtipc_get_arg(fd, &tv, - sopt.optval, sizeof(tv))) - return -EFAULT; + ret = rtipc_get_timeval(fd, &tv, sopt.optval, sopt.optlen); + if (ret) + return ret; sk->tx_timeout = rtipc_timeval_to_ns(&tv); break; @@ -869,11 +860,9 @@ static int __bufp_setsockopt(struct bufp_socket *sk, switch (sopt.optname) { case BUFP_BUFSZ: - if (sopt.optlen != sizeof(len)) - return -EINVAL; - if (rtipc_get_arg(fd, &len, - sopt.optval, sizeof(len))) - return -EFAULT; + ret = rtipc_get_length(fd, &len, sopt.optval, sopt.optlen); + if (ret) + return ret; if (len == 0)