diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-03-20 22:35:33 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-03-20 22:35:33 +0000 |
commit | bbabca3fda32c4fe375a96dd6a484df6c4ee27da (patch) | |
tree | 515bcd93ff68d5ca69c220a9a522bbf98501a663 /lib/libarchive/archive_util.c | |
parent | b4abefb315f13813640f3ee4738e718eece44e45 (diff) | |
download | FreeBSD-src-bbabca3fda32c4fe375a96dd6a484df6c4ee27da.zip FreeBSD-src-bbabca3fda32c4fe375a96dd6a484df6c4ee27da.tar.gz |
Bug: Standard C still requires declarations to precede statements. <sigh>
Portability: Eliminate an accidental __unused, accomodate
systems with non-POSIX strerror_r
Diffstat (limited to 'lib/libarchive/archive_util.c')
-rw-r--r-- | lib/libarchive/archive_util.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libarchive/archive_util.c b/lib/libarchive/archive_util.c index 587e8af..11d151a 100644 --- a/lib/libarchive/archive_util.c +++ b/lib/libarchive/archive_util.c @@ -84,6 +84,7 @@ archive_set_error(struct archive *a, int error_number, const char *fmt, ...) { va_list ap; char errbuff[512]; + char *errp; a->archive_error_number = error_number; if (fmt == NULL) { @@ -95,8 +96,16 @@ archive_set_error(struct archive *a, int error_number, const char *fmt, ...) archive_string_vsprintf(&(a->error_string), fmt, ap); if(error_number > 0) { archive_strcat(&(a->error_string), ": "); +#if defined(HAVE_GLIBC_STRERROR_R) + errp = strerror_r(error_number, errbuff, sizeof(errbuff)); +#elif defined(HAVE_POSIX_STRERROR_R) strerror_r(error_number, errbuff, sizeof(errbuff)); - archive_strcat(&(a->error_string), errbuff); + errp = errbuff; +#else + /* Note: this is not threadsafe! */ + errp = strerror(error_number); +#endif + archive_strcat(&(a->error_string), errp); } a->error = a->error_string.s; va_end(ap); |