From ba8d2119ba8be9189461d734d5bade32d7821e43 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 24 Aug 2013 11:43:05 +0200 Subject: [PATCH] tools: Fix startup of dumpiso and sendiso on juju Quoting the errno manual: "[errno] is set by system calls and some library functions in the event of an error to indicate what went wrong. Its value is significant only when the return value of the call indicated an error (i.e., -1 from most system calls; -1 or NULL from most library functions); a function that succeeds is allowed to change errno. Valid error numbers are all nonzero; errno is never set to zero by any system call or library function." Dumpiso and sendiso checked for raw1394_set_port() failure by looking at errno rather than by looking at the function's return code. This happened to work on top of raw1394 by lucky incident but no longer works on top of firewire-core. Reported-by: Vladimir Romanov Signed-off-by: Stefan Richter --- tools/dumpiso.c | 8 ++++---- tools/sendiso.c | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/dumpiso.c b/tools/dumpiso.c index d4b2c1b..c9f64a5 100644 --- a/tools/dumpiso.c +++ b/tools/dumpiso.c @@ -212,7 +212,7 @@ iso_handler(raw1394handle_t handle, unsigned char *data, int main(int argc, char **argv) { raw1394handle_t handle; - int i; + int i, ret; parse_args(argc, argv); @@ -236,10 +236,10 @@ int main(int argc, char **argv) exit(1); } - raw1394_set_port(handle, which_port); - } while (errno == ESTALE); + ret = raw1394_set_port(handle, which_port); + } while (ret < 0 && errno == ESTALE); - if (errno) { + if (ret < 0) { perror("raw1394_set_port"); exit(1); } diff --git a/tools/sendiso.c b/tools/sendiso.c index 32ce4ce..6d23ab2 100644 --- a/tools/sendiso.c +++ b/tools/sendiso.c @@ -274,6 +274,7 @@ wrong_version: int main(int argc, char **argv) { raw1394handle_t handle; + int ret; parse_args(argc, argv); @@ -296,10 +297,10 @@ int main(int argc, char **argv) exit(1); } - raw1394_set_port(handle, which_port); - } while (errno == ESTALE); + ret = raw1394_set_port(handle, which_port); + } while (ret < 0 && errno == ESTALE); - if (errno) { + if (ret < 0) { perror("raw1394_set_port"); exit(1); }