From mboxrd@z Thu Jan 1 00:00:00 1970 Sender: Michael Welling Date: Mon, 22 Feb 2016 17:30:25 -0600 From: Michael Welling Message-ID: <20160222233025.GA28057@deathstar> References: <1456177287-15501-1-git-send-email-mwelling@ieee.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1456177287-15501-1-git-send-email-mwelling@ieee.org> Subject: Re: [Xenomai] [PATCH v2] demo: cross-link: Properly handle ioctl error List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xenomai@xenomai.org, 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 > --- > 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 > #include > #include > +#include > #include > #include > #include > @@ -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 >