Date: Thu, 12 Aug 2021 11:29:07 -0700 From: Cy Schubert <Cy.Schubert@cschubert.com> To: Ed Maste <emaste@FreeBSD.org> Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: d20e9e02db3d - main - ar: diff reduction against ELF Tool Chain Message-ID: <202108121829.17CIT71Q034598@slippy.cwsent.com> In-Reply-To: <202108121729.17CHTWfb033244@slippy.cwsent.com> References: <202108112313.17BNDL1g093210@gitrepo.freebsd.org> <202108121729.17CHTWfb033244@slippy.cwsent.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <202108121729.17CHTWfb033244@slippy.cwsent.com>, Cy Schubert writes: > In message <202108112313.17BNDL1g093210@gitrepo.freebsd.org>, Ed Maste > writes: > > The branch main has been updated by emaste: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=d20e9e02db3dde383c3de1ce8cec3a > 8c > > 35b3eee6 > > > > commit d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6 > > Author: Ed Maste <emaste@FreeBSD.org> > > AuthorDate: 2021-08-04 13:54:17 +0000 > > Commit: Ed Maste <emaste@FreeBSD.org> > > CommitDate: 2021-08-11 23:12:46 +0000 > > > > ar: diff reduction against ELF Tool Chain > > > > - Drop exit status from bsdar_errc. ELF Tool Chain always returns > > EXIT_FAILURE in bsdar_errc. > > > > - Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive > > directly. > > > > Obtained from: ELF Tool Chain > > Reviewed by: markj > > Sponsored by: The FreeBSD Foundation > > Differential Revision: https://reviews.freebsd.org/D31496 > > --- > > usr.bin/ar/acpyacc.y | 48 ++++++++++------------ > > usr.bin/ar/ar.c | 52 ++++++++---------------- > > usr.bin/ar/ar.h | 18 +++------ > > usr.bin/ar/read.c | 34 ++++------------ > > usr.bin/ar/util.c | 4 +- > > usr.bin/ar/write.c | 111 +++++++++++++++-------------------------------- > -- > > -- > > 6 files changed, 85 insertions(+), 182 deletions(-) > > > [...] > > diff --git a/usr.bin/ar/ar.h b/usr.bin/ar/ar.h > > index 21b3a669a943..bcccf93a6016 100644 > > --- a/usr.bin/ar/ar.h > > +++ b/usr.bin/ar/ar.h > > @@ -54,7 +54,7 @@ > > */ > > #define AC(CALL) do { > > \ > > if ((CALL)) \ > > - bsdar_errc(bsdar, EXIT_FAILURE, archive_errno(a), "%s", \ > > + bsdar_errc(bsdar, archive_errno(a), "%s", \ > > archive_error_string(a)); \ > > } while (0) > > > > @@ -114,16 +114,8 @@ struct bsdar { > > TAILQ_HEAD(, ar_obj) v_obj; /* object(member) list */ > > }; > > > > -void bsdar_errc(struct bsdar *, int _eval, int _code, > > - const char *fmt, ...) __dead2; > > -void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); > > -int ar_mode_d(struct bsdar *bsdar); > > -int ar_mode_m(struct bsdar *bsdar); > > -int ar_mode_p(struct bsdar *bsdar); > > -int ar_mode_q(struct bsdar *bsdar); > > -int ar_mode_r(struct bsdar *bsdar); > > -int ar_mode_s(struct bsdar *bsdar); > > -int ar_mode_t(struct bsdar *bsdar); > > -int ar_mode_x(struct bsdar *bsdar); > > -int ar_mode_A(struct bsdar *bsdar); > > void ar_mode_script(struct bsdar *ar); > > +int ar_read_archive(struct bsdar *ar, int mode); > > +int ar_write_archive(struct bsdar *ar, int mode); > > +void bsdar_errc(struct bsdar *, int _code, const char *fmt, ...) __d > ead2; > > +void bsdar_warnc(struct bsdar *, int _code, const char *fmt, ...); > > diff --git a/usr.bin/ar/read.c b/usr.bin/ar/read.c > > index 04130b859c32..81e0bfce1b7e 100644 > > --- a/usr.bin/ar/read.c > > +++ b/usr.bin/ar/read.c > > @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); > > #include <sys/stat.h> > > #include <archive.h> > > #include <archive_entry.h> > > +#include <assert.h> > > #include <errno.h> > > #include <libgen.h> > > #include <stdio.h> > > @@ -42,34 +43,11 @@ __FBSDID("$FreeBSD$"); > > > > #include "ar.h" > > > > -static int read_archive(struct bsdar *bsdar, char mode); > > - > > -int > > -ar_mode_p(struct bsdar *bsdar) > > -{ > > - > > - return (read_archive(bsdar, 'p')); > > -} > > - > > -int > > -ar_mode_t(struct bsdar *bsdar) > > -{ > > - > > - return (read_archive(bsdar, 't')); > > -} > > - > > -int > > -ar_mode_x(struct bsdar *bsdar) > > -{ > > - > > - return (read_archive(bsdar, 'x')); > > -} > > - > > /* > > * Handle read modes: 'x', 't' and 'p'. > > */ > > -static int > > -read_archive(struct bsdar *bsdar, char mode) > > +int > > +ar_read_archive(struct bsdar *bsdar, int mode) > > { > > struct archive *a; > > struct archive_entry *entry; > > @@ -87,8 +65,10 @@ read_archive(struct bsdar *bsdar, char mode) > > char find; > > int exitcode, flags, r, i; > > > > + assert(mode == 'p' || mode == 't' || mode == 'x'); > > This is causing port build failures: > > ar -cq libutil.a allwhite.o inctest.o letter.o triedump.o triepdmp.o > trieplk.o trierset.o upcmp8.o upstrcmp.o wchar.o conutil.o error.o exit.o > itoa.o lower.o malloc.o openchk.o trie.o triecnt.o upper.o whitesp.o > ranlib libutil.a > Assertion failed: (mode == 'p' || mode == 't' || mode == 'x'), function > ar_read_archive, file /usr/local/poudriere/jails/main-amd64/usr/src/usr.bin/ > ar/read.c, line 68. > *** Signal 6 > > Notice at line 154 of ar.c that ar_read_archive() is called with mode='s'. > This certainly triggers the assertion. The assertion may also trigger by > the call to ar_read_archive() at line 330 of ar.c where mode is set to > bsdar->mode. It appears that upstream doesn't call ar_read_archive() at line 154 of ar.c. This would explain why they have the assertion they do in ar_read_archive(). There is only one call to ar_read_archive() at line 350 which corresponds to our line 330 of ar.c. > > > + > > if ((a = archive_read_new()) == NULL) > > - bsdar_errc(bsdar, EXIT_FAILURE, 0, "archive_read_new failed"); > > + bsdar_errc(bsdar, 0, "archive_read_new failed"); > > archive_read_support_format_ar(a); > > AC(archive_read_open_filename(a, bsdar->filename, DEF_BLKSZ)); > > > > @@ -122,7 +102,7 @@ read_archive(struct bsdar *bsdar, char mode) > > if (*av == NULL) > > continue; > > if ((bname = basename(*av)) == NULL) > > - bsdar_errc(bsdar, EXIT_FAILURE, errno, > > + bsdar_errc(bsdar, errno, > > "basename failed"); > > if (strcmp(bname, name) != 0) > > continue; > [...] -- Cheers, Cy Schubert <Cy.Schubert@cschubert.com> FreeBSD UNIX: <cy@FreeBSD.org> Web: https://FreeBSD.org NTP: <cy@nwtime.org> Web: https://nwtime.org The need of the many outweighs the greed of the few.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108121829.17CIT71Q034598>