From owner-svn-src-head@freebsd.org Tue Oct 23 13:07:05 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4491DFD767A; Tue, 23 Oct 2018 13:07:05 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E79A17B712; Tue, 23 Oct 2018 13:07:04 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E029510465; Tue, 23 Oct 2018 13:07:04 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9ND743N016776; Tue, 23 Oct 2018 13:07:04 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9ND7408016772; Tue, 23 Oct 2018 13:07:04 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201810231307.w9ND7408016772@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Tue, 23 Oct 2018 13:07:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339648 - head/usr.bin/ar X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/usr.bin/ar X-SVN-Commit-Revision: 339648 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2018 13:07:05 -0000 Author: emaste Date: Tue Oct 23 13:07:03 2018 New Revision: 339648 URL: https://svnweb.freebsd.org/changeset/base/339648 Log: 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. Reviewed by: brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17650 Modified: head/usr.bin/ar/acpyacc.y head/usr.bin/ar/ar.h head/usr.bin/ar/read.c head/usr.bin/ar/write.c Modified: head/usr.bin/ar/acpyacc.y ============================================================================== --- head/usr.bin/ar/acpyacc.y Tue Oct 23 13:03:24 2018 (r339647) +++ head/usr.bin/ar/acpyacc.y Tue Oct 23 13:07:03 2018 (r339648) @@ -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: head/usr.bin/ar/ar.h ============================================================================== --- head/usr.bin/ar/ar.h Tue Oct 23 13:03:24 2018 (r339647) +++ head/usr.bin/ar/ar.h Tue Oct 23 13:07:03 2018 (r339648) @@ -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: head/usr.bin/ar/read.c ============================================================================== --- head/usr.bin/ar/read.c Tue Oct 23 13:03:24 2018 (r339647) +++ head/usr.bin/ar/read.c Tue Oct 23 13:07:03 2018 (r339648) @@ -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: head/usr.bin/ar/write.c ============================================================================== --- head/usr.bin/ar/write.c Tue Oct 23 13:03:24 2018 (r339647) +++ head/usr.bin/ar/write.c Tue Oct 23 13:07:03 2018 (r339648) @@ -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;