Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2019 18:28:34 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r346901 - stable/11/usr.bin/ar
Message-ID:  <201904291828.x3TISYpK040411@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Mon Apr 29 18:28:34 2019
New Revision: 346901
URL: https://svnweb.freebsd.org/changeset/base/346901

Log:
  MFC r339648:     ar: report errno on warning/error
  
  Previously ar would report an error like "ar: fatal: Write error"
  without including additional errno information.  Change warnings and
  errors to include archive_errno() so that the user may have some idea
  of the reason for the failure.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/11/usr.bin/ar/acpyacc.y
  stable/11/usr.bin/ar/ar.h
  stable/11/usr.bin/ar/read.c
  stable/11/usr.bin/ar/write.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/ar/acpyacc.y
==============================================================================
--- stable/11/usr.bin/ar/acpyacc.y	Mon Apr 29 18:25:39 2019	(r346900)
+++ stable/11/usr.bin/ar/acpyacc.y	Mon Apr 29 18:28:34 2019	(r346901)
@@ -254,7 +254,8 @@ arscp_open(char *fname)
 	archive_read_support_format_ar(a);
 	AC(archive_read_open_filename(a, fname, DEF_BLKSZ));
 	if ((r = archive_read_next_header(a, &entry)))
-		bsdar_warnc(bsdar, 0, "%s", archive_error_string(a));
+		bsdar_warnc(bsdar, archive_errno(a), "%s",
+		    archive_error_string(a));
 	AC(archive_read_close(a));
 	AC(archive_read_free(a));
 	if (r != ARCHIVE_OK)

Modified: stable/11/usr.bin/ar/ar.h
==============================================================================
--- stable/11/usr.bin/ar/ar.h	Mon Apr 29 18:25:39 2019	(r346900)
+++ stable/11/usr.bin/ar/ar.h	Mon Apr 29 18:28:34 2019	(r346901)
@@ -52,10 +52,10 @@
 /*
  * Convenient wrapper for general libarchive error handling.
  */
-#define	AC(CALL) do {					\
-	if ((CALL))					\
-		bsdar_errc(bsdar, EX_SOFTWARE, 0, "%s",	\
-		    archive_error_string(a));		\
+#define	AC(CALL) do {							\
+	if ((CALL))							\
+		bsdar_errc(bsdar, EX_SOFTWARE, archive_errno(a), "%s",	\
+		    archive_error_string(a));				\
 } while (0)
 
 /*

Modified: stable/11/usr.bin/ar/read.c
==============================================================================
--- stable/11/usr.bin/ar/read.c	Mon Apr 29 18:25:39 2019	(r346900)
+++ stable/11/usr.bin/ar/read.c	Mon Apr 29 18:28:34 2019	(r346901)
@@ -96,7 +96,8 @@ read_archive(struct bsdar *bsdar, char mode)
 		r = archive_read_next_header(a, &entry);
 		if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY ||
 		    r == ARCHIVE_FATAL)
-			bsdar_warnc(bsdar, 0, "%s", archive_error_string(a));
+			bsdar_warnc(bsdar, archive_errno(a), "%s",
+			    archive_error_string(a));
 		if (r == ARCHIVE_EOF || r == ARCHIVE_FATAL)
 			break;
 		if (r == ARCHIVE_RETRY) {
@@ -151,7 +152,7 @@ read_archive(struct bsdar *bsdar, char mode)
 			if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY ||
 			    r == ARCHIVE_FATAL) {
 				(void)fprintf(stdout, "\n");
-				bsdar_warnc(bsdar, 0, "%s",
+				bsdar_warnc(bsdar, archive_errno(a), "%s",
 				    archive_error_string(a));
 			}
 
@@ -205,7 +206,7 @@ read_archive(struct bsdar *bsdar, char mode)
 			}
 
 			if (r)
-				bsdar_warnc(bsdar, 0, "%s",
+				bsdar_warnc(bsdar, archive_errno(a), "%s",
 				    archive_error_string(a));
 		}
 	}

Modified: stable/11/usr.bin/ar/write.c
==============================================================================
--- stable/11/usr.bin/ar/write.c	Mon Apr 29 18:25:39 2019	(r346900)
+++ stable/11/usr.bin/ar/write.c	Mon Apr 29 18:28:34 2019	(r346901)
@@ -291,12 +291,13 @@ read_objs(struct bsdar *bsdar, const char *archive, in
 	for (;;) {
 		r = archive_read_next_header(a, &entry);
 		if (r == ARCHIVE_FATAL)
-			bsdar_errc(bsdar, EX_DATAERR, 0, "%s",
+			bsdar_errc(bsdar, EX_DATAERR, archive_errno(a), "%s",
 			    archive_error_string(a));
 		if (r == ARCHIVE_EOF)
 			break;
 		if (r == ARCHIVE_WARN || r == ARCHIVE_RETRY)
-			bsdar_warnc(bsdar, 0, "%s", archive_error_string(a));
+			bsdar_warnc(bsdar, archive_errno(a), "%s",
+			    archive_error_string(a));
 		if (r == ARCHIVE_RETRY) {
 			bsdar_warnc(bsdar, 0, "Retrying...");
 			continue;
@@ -341,7 +342,7 @@ read_objs(struct bsdar *bsdar, const char *archive, in
 				bsdar_errc(bsdar, EX_SOFTWARE, errno,
 				    "malloc failed");
 			if (archive_read_data(a, buff, size) != (ssize_t)size) {
-				bsdar_warnc(bsdar, 0, "%s",
+				bsdar_warnc(bsdar, archive_errno(a), "%s",
 				    archive_error_string(a));
 				free(buff);
 				continue;
@@ -594,7 +595,7 @@ write_data(struct bsdar *bsdar, struct archive *a, con
 	while (s > 0) {
 		written = archive_write_data(a, buf, s);
 		if (written < 0)
-			bsdar_errc(bsdar, EX_SOFTWARE, 0, "%s",
+			bsdar_errc(bsdar, EX_SOFTWARE, archive_errno(a), "%s",
 			    archive_error_string(a));
 		buf = (const char *)buf + written;
 		s -= written;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904291828.x3TISYpK040411>