* [Xenomai] [PATCH v2] demo: cross-link: Properly handle ioctl error
@ 2016-02-22 21:41 Michael Welling
2016-02-22 23:30 ` Michael Welling
0 siblings, 1 reply; 2+ messages in thread
From: Michael Welling @ 2016-02-22 21:41 UTC (permalink / raw)
To: xenomai, Gilles Chanteperdrix, Jan Kiszka
Update cross-link demo to properly report ioctl errors.
Signed-off-by: Michael Welling <mwelling@ieee.org>
---
v2: Update all instances that incorrectly handle ioctl errors.
demo/alchemy/cobalt/cross-link.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/demo/alchemy/cobalt/cross-link.c b/demo/alchemy/cobalt/cross-link.c
index 8c0f53f..fa3cc91 100644
--- a/demo/alchemy/cobalt/cross-link.c
+++ b/demo/alchemy/cobalt/cross-link.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/mman.h>
#include <alchemy/task.h>
#include <alchemy/timer.h>
@@ -199,6 +200,7 @@ static void read_task_proc(void *arg)
/* waiting for event */
err = ioctl(read_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event);
if (err) {
+ err = -errno;
printf(RTASK_PREFIX
"error on RTSER_RTIOC_WAIT_EVENT, %s\n",
strerror(-err));
@@ -254,6 +256,7 @@ int main(int argc, char* argv[])
/* writing write-config */
err = ioctl(write_fd, RTSER_RTIOC_SET_CONFIG, &write_config);
if (err) {
+ err = -errno;
printf(MAIN_PREFIX "error while RTSER_RTIOC_SET_CONFIG, %s\n",
strerror(-err));
goto error;
@@ -273,6 +276,7 @@ int main(int argc, char* argv[])
/* writing read-config */
err = ioctl(read_fd, RTSER_RTIOC_SET_CONFIG, &read_config);
if (err) {
+ err = -errno;
printf(MAIN_PREFIX "error while ioctl, %s\n",
strerror(-err));
goto error;
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [Xenomai] [PATCH v2] demo: cross-link: Properly handle ioctl error
2016-02-22 21:41 [Xenomai] [PATCH v2] demo: cross-link: Properly handle ioctl error Michael Welling
@ 2016-02-22 23:30 ` Michael Welling
0 siblings, 0 replies; 2+ messages in thread
From: Michael Welling @ 2016-02-22 23:30 UTC (permalink / raw)
To: xenomai, Gilles Chanteperdrix, Jan Kiszka
On Mon, Feb 22, 2016 at 03:41:27PM -0600, Michael Welling wrote:
> Update cross-link demo to properly report ioctl errors.
>
> Signed-off-by: Michael Welling <mwelling@ieee.org>
> ---
> v2: Update all instances that incorrectly handle ioctl errors.
>
> demo/alchemy/cobalt/cross-link.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/demo/alchemy/cobalt/cross-link.c b/demo/alchemy/cobalt/cross-link.c
> index 8c0f53f..fa3cc91 100644
> --- a/demo/alchemy/cobalt/cross-link.c
> +++ b/demo/alchemy/cobalt/cross-link.c
> @@ -23,6 +23,7 @@
> #include <stdio.h>
> #include <signal.h>
> #include <unistd.h>
> +#include <errno.h>
> #include <sys/mman.h>
> #include <alchemy/task.h>
> #include <alchemy/timer.h>
> @@ -199,6 +200,7 @@ static void read_task_proc(void *arg)
> /* waiting for event */
> err = ioctl(read_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event);
> if (err) {
> + err = -errno;
> printf(RTASK_PREFIX
> "error on RTSER_RTIOC_WAIT_EVENT, %s\n",
> strerror(-err));
> @@ -254,6 +256,7 @@ int main(int argc, char* argv[])
> /* writing write-config */
> err = ioctl(write_fd, RTSER_RTIOC_SET_CONFIG, &write_config);
> if (err) {
> + err = -errno;
> printf(MAIN_PREFIX "error while RTSER_RTIOC_SET_CONFIG, %s\n",
> strerror(-err));
> goto error;
> @@ -273,6 +276,7 @@ int main(int argc, char* argv[])
> /* writing read-config */
> err = ioctl(read_fd, RTSER_RTIOC_SET_CONFIG, &read_config);
> if (err) {
> + err = -errno;
> printf(MAIN_PREFIX "error while ioctl, %s\n",
> strerror(-err));
> goto error;
After I got an email about this patch offlist, I found even more issues with
error number handling.
Not only are the ioctl calls wrong but the read, open, and write calls are too.
Here comes v3.
> --
> 2.1.4
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-22 23:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-22 21:41 [Xenomai] [PATCH v2] demo: cross-link: Properly handle ioctl error Michael Welling
2016-02-22 23:30 ` Michael Welling
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.