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 <blueboar2@gmail.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
Stefan Richter 2013-08-24 11:43:05 +02:00
parent 77dd78e3b4
commit ba8d2119ba
2 changed files with 8 additions and 7 deletions

View File

@ -212,7 +212,7 @@ iso_handler(raw1394handle_t handle, unsigned char *data,
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
raw1394handle_t handle; raw1394handle_t handle;
int i; int i, ret;
parse_args(argc, argv); parse_args(argc, argv);
@ -236,10 +236,10 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
raw1394_set_port(handle, which_port); ret = raw1394_set_port(handle, which_port);
} while (errno == ESTALE); } while (ret < 0 && errno == ESTALE);
if (errno) { if (ret < 0) {
perror("raw1394_set_port"); perror("raw1394_set_port");
exit(1); exit(1);
} }

View File

@ -274,6 +274,7 @@ wrong_version:
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
raw1394handle_t handle; raw1394handle_t handle;
int ret;
parse_args(argc, argv); parse_args(argc, argv);
@ -296,10 +297,10 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
raw1394_set_port(handle, which_port); ret = raw1394_set_port(handle, which_port);
} while (errno == ESTALE); } while (ret < 0 && errno == ESTALE);
if (errno) { if (ret < 0) {
perror("raw1394_set_port"); perror("raw1394_set_port");
exit(1); exit(1);
} }