diff options
author | Egor Chelak <egor.chelak@gmail.com> | 2020-11-07 02:19:56 +0200 |
---|---|---|
committer | Egor Chelak <egor.chelak@gmail.com> | 2020-11-09 07:20:14 +0200 |
commit | cabbf61fab7e69860b076f1d55b26e1fb07b0b4c (patch) | |
tree | 6dfe6a6bce3a3690cdebddf84b6ff818d234b175 /lib/fileutils.c | |
parent | 418eb09482ddef66352e6677211ca3341267223d (diff) | |
download | util-linux-cabbf61fab7e69860b076f1d55b26e1fb07b0b4c.tar.gz |
ul_copy_file: make defines for return values
Suggested-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
Diffstat (limited to 'lib/fileutils.c')
-rw-r--r-- | lib/fileutils.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/fileutils.c b/lib/fileutils.c index a41830457..9da906ae0 100644 --- a/lib/fileutils.c +++ b/lib/fileutils.c @@ -199,9 +199,9 @@ int main(int argc, char *argv[]) close_all_fds(wanted_fds, ARRAY_SIZE(wanted_fds)); } else if (strcmp(argv[1], "--copy-file") == 0) { int ret = ul_copy_file(STDIN_FILENO, STDOUT_FILENO); - if (ret == -1) + if (ret == UL_COPY_READ_ERROR) err(EXIT_FAILURE, "read"); - else if (ret == -2) + else if (ret == UL_COPY_WRITE_ERROR) err(EXIT_FAILURE, "write"); } return EXIT_SUCCESS; @@ -263,9 +263,9 @@ static int copy_file_simple(int from, int to) while ((nr = read_all(from, buf, sizeof(buf))) > 0) if (write_all(to, buf, nr) == -1) - return -2; + return UL_COPY_WRITE_ERROR; if (nr < 0) - return -1; + return UL_COPY_READ_ERROR; #ifdef HAVE_EXPLICIT_BZERO explicit_bzero(buf, sizeof(buf)); #endif @@ -280,7 +280,7 @@ int ul_copy_file(int from, int to) ssize_t nw; if (fstat(from, &st) == -1) - return -1; + return UL_COPY_READ_ERROR; if (!S_ISREG(st.st_mode)) return copy_file_simple(from, to); if (sendfile_all(to, from, NULL, st.st_size) < 0) |