Be more POSIX compliant w.r.t. errno; fixes erroneousl reporting of errors on FreeBSD

master
Rob Sykes 2013-05-27 21:07:14 +01:00
parent e55c47697b
commit 988f8303c7
4 changed files with 14 additions and 12 deletions

View File

@ -72,7 +72,7 @@ int main(int argc, char const * arg[])
soxr_delete(soxr);
free(obuf), free(ibuf);
/* Diagnostics: */
fprintf(stderr, "%-26s %s; I/O: %s\n", arg[0],
soxr_strerror(error), errno? strerror(errno) : "no error");
return error || errno;
fprintf(stderr, "%-26s %s; I/O: %s\n", arg[0], soxr_strerror(error),
ferror(stdin) || ferror(stdout)? strerror(errno) : "no error");
return !!error;
}

View File

@ -104,7 +104,8 @@ int main(int n, char const * arg[])
soxr_delete(soxr);
free(obuf), free(ibuf);
/* Diagnostics: */
fprintf(stderr, "%-26s %s; %lu clips; I/O: %s\n", arg0, soxr_strerror(error),
(long unsigned)clips, errno? strerror(errno) : "no error");
return error || errno;
fprintf(stderr, "%-26s %s; %lu clips; I/O: %s\n",
arg0, soxr_strerror(error), (long unsigned)clips,
ferror(stdin) || ferror(stdout)? strerror(errno) : "no error");
return !!error;
}

View File

@ -141,7 +141,8 @@ int main(int n, char const * arg[])
free(obuf), free(ibuf), free(obufs), free(ibufs);
free(obuf_ptrs), free(ibuf_ptrs);
/* Diagnostics: */
fprintf(stderr, "%-26s %s; %lu clips; I/O: %s\n", arg0, soxr_strerror(error),
(long unsigned)clips, errno? strerror(errno) : "no error");
return error || errno;
fprintf(stderr, "%-26s %s; %lu clips; I/O: %s\n",
arg0, soxr_strerror(error), (long unsigned)clips,
ferror(stdin) || ferror(stdout)? strerror(errno) : "no error");
return !!error;
}

View File

@ -88,7 +88,7 @@ int main(int argc, char *arg[])
soxr_delete(soxr);
}
/* Diagnostics: */
fprintf(stderr, "%-26s %s; I/O: %s\n", arg[0],
soxr_strerror(error), errno? strerror(errno) : "no error");
return error || errno;
fprintf(stderr, "%-26s %s; I/O: %s\n", arg[0], soxr_strerror(error),
ferror(stdin) || ferror(stdout)? strerror(errno) : "no error");
return !!error;
}