From a654d8a02853d3d2bd63d2e5295d4a39a1181bf6 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Fri, 20 Jun 2014 21:39:50 -0700 Subject: [PATCH] Document the buggy return codes of archive_write_data when writing to an archive_write_disk handle; comment that this should change in libarchive 4 --- libarchive/archive_write_data.3 | 12 ++++++++++-- libarchive/archive_write_disk_posix.c | 4 ++++ libarchive/archive_write_disk_windows.c | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libarchive/archive_write_data.3 b/libarchive/archive_write_data.3 index cfd5cd552..a85f61d3a 100644 --- a/libarchive/archive_write_data.3 +++ b/libarchive/archive_write_data.3 @@ -42,8 +42,7 @@ Write data corresponding to the header just written. .\" .Sh RETURN VALUES This function returns the number of bytes actually written, or -.Li -1 -on error. +a negative error code on error. .\" .Sh ERRORS Detailed error codes and textual descriptions are available from the @@ -52,6 +51,15 @@ and .Fn archive_error_string functions. .\" +.Sh BUGS +In libarchive 3.x, this function sometimes returns +zero on success instead of returning the number of bytes written. +Specifically, this occurs when writing to an +.Vt archive_write_disk +handle. +Clients should treat any value less than zero as an error +and consider any non-negative value as success. +.\" .Sh SEE ALSO .Xr tar 1 , .Xr libarchive 3 , diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index 1fac4cecf..ee16d9d76 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -1470,7 +1470,11 @@ _archive_write_disk_data_block(struct archive *_a, "Write request too large"); return (ARCHIVE_WARN); } +#if ARCHIVE_VERSION_NUMBER < 3999000 return (ARCHIVE_OK); +#else + return (size); +#endif } static ssize_t diff --git a/libarchive/archive_write_disk_windows.c b/libarchive/archive_write_disk_windows.c index 512caf439..800aa893f 100644 --- a/libarchive/archive_write_disk_windows.c +++ b/libarchive/archive_write_disk_windows.c @@ -1009,7 +1009,11 @@ _archive_write_disk_data_block(struct archive *_a, "Write request too large"); return (ARCHIVE_WARN); } +#if ARCHIVE_VERSION_NUMBER < 3999000 return (ARCHIVE_OK); +#else + return (size); +#endif } static ssize_t -- 2.47.2