summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorRuslan Baratov <ruslan_baratov@yahoo.com>2018-05-16 20:44:56 (GMT)
committerBrad King <brad.king@kitware.com>2018-05-18 14:04:18 (GMT)
commita203fcc63d3e11a44c51f818710bb304c1b6f780 (patch)
tree5b6acb80828ba4900526ef4311f729af0de64e61 /Source/cmSystemTools.cxx
parent743f24bac68010c0157dc0349958e09ed1784f5f (diff)
downloadCMake-a203fcc63d3e11a44c51f818710bb304c1b6f780.zip
CMake-a203fcc63d3e11a44c51f818710bb304c1b6f780.tar.gz
CMake-a203fcc63d3e11a44c51f818710bb304c1b6f780.tar.bz2
cmake: Teach '-E tar' to report errors copying data
The `copy_data` function checks for errors but the caller ignored them. Simplify its return type and add a check to the caller.
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx26
1 files changed, 18 insertions, 8 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 94c5ee8..169b525 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1696,7 +1696,8 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
fflush(out);
}
-long copy_data(struct archive* ar, struct archive* aw)
+// Return 'true' on success
+bool copy_data(struct archive* ar, struct archive* aw)
{
long r;
const void* buff;
@@ -1708,22 +1709,28 @@ long copy_data(struct archive* ar, struct archive* aw)
#endif
for (;;) {
+ // Return value:
+ // * ARCHIVE_OK - read succeed
+ // * ARCHIVE_EOF - no more data to read left
r = archive_read_data_block(ar, &buff, &size, &offset);
if (r == ARCHIVE_EOF) {
- return (ARCHIVE_OK);
+ return true;
}
if (r != ARCHIVE_OK) {
- return (r);
+ return false;
}
- r = archive_write_data_block(aw, buff, size, offset);
- if (r != ARCHIVE_OK) {
+ // Return value:
+ // * >= ARCHIVE_OK - write succeed
+ // * < ARCHIVE_OK - write failed
+ const la_ssize_t w_size = archive_write_data_block(aw, buff, size, offset);
+ if (w_size < ARCHIVE_OK) {
cmSystemTools::Message("archive_write_data_block()",
archive_error_string(aw));
- return (r);
+ return false;
}
}
#if !defined(__clang__) && !defined(__HP_aCC)
- return r; /* this should not happen but it quiets some compilers */
+ return false; /* this should not happen but it quiets some compilers */
#endif
}
@@ -1776,7 +1783,10 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract)
r = archive_write_header(ext, entry);
if (r == ARCHIVE_OK) {
- copy_data(a, ext);
+ if (!copy_data(a, ext)) {
+ cmSystemTools::Error("Problem with copy_data");
+ break;
+ }
r = archive_write_finish_entry(ext);
if (r != ARCHIVE_OK) {
cmSystemTools::Error("Problem with archive_write_finish_entry(): ",