diff options
author | Allan McRae <allan@archlinux.org> | 2020-04-13 14:24:23 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2020-04-13 15:44:46 +0200 |
commit | 6ba250e4001740ca428226abf157b25aa121c7bf (patch) | |
tree | ffed2284aad82174e784e01f1ded9af126880cf9 /lib/libalpm/be_package.c | |
parent | 0eda92c5d4f8810a68066ee72713ffdfa878dd8c (diff) | |
download | pacman-6ba250e4001740ca428226abf157b25aa121c7bf.tar.gz pacman-6ba250e4001740ca428226abf157b25aa121c7bf.tar.xz |
Use GOTO_ERR throughout
The GOTO_ERR define was added in commit 80ae8014 for use in future commits.
There are plenty of places in the code base it can be used, so convert them.
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_package.c')
-rw-r--r-- | lib/libalpm/be_package.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 38ba365d..f98832f4 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -459,8 +459,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str /* create a new archive to parse the mtree and load it from archive into memory */ /* TODO: split this into a function */ if((mtree = archive_read_new()) == NULL) { - handle->pm_errno = ALPM_ERR_LIBARCHIVE; - goto error; + GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error); } _alpm_archive_read_support_filter_all(mtree); @@ -479,8 +478,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str if(size < 0) { _alpm_log(handle, ALPM_LOG_DEBUG, _("error while reading package %s: %s\n"), pkg->filename, archive_error_string(archive)); - handle->pm_errno = ALPM_ERR_LIBARCHIVE; - goto error; + GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error); } if(size == 0) { break; @@ -493,8 +491,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str _alpm_log(handle, ALPM_LOG_DEBUG, _("error while reading mtree of package %s: %s\n"), pkg->filename, archive_error_string(mtree)); - handle->pm_errno = ALPM_ERR_LIBARCHIVE; - goto error; + GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error); } while((ret = archive_read_next_header(mtree, &mtree_entry)) == ARCHIVE_OK) { @@ -517,8 +514,7 @@ static int build_filelist_from_mtree(alpm_handle_t *handle, alpm_pkg_t *pkg, str if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occurred */ _alpm_log(handle, ALPM_LOG_DEBUG, _("error while reading mtree of package %s: %s\n"), pkg->filename, archive_error_string(mtree)); - handle->pm_errno = ALPM_ERR_LIBARCHIVE; - goto error; + GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error); } /* throw away any files we loaded directly from the archive */ @@ -583,11 +579,9 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, newpkg = _alpm_pkg_new(); if(newpkg == NULL) { - handle->pm_errno = ALPM_ERR_MEMORY; - goto error; + GOTO_ERR(handle, ALPM_ERR_MEMORY, error); } - STRDUP(newpkg->filename, pkgfile, - handle->pm_errno = ALPM_ERR_MEMORY; goto error); + STRDUP(newpkg->filename, pkgfile, GOTO_ERR(handle, ALPM_ERR_MEMORY, error)); newpkg->size = st.st_size; _alpm_log(handle, ALPM_LOG_DEBUG, "starting package load for %s\n", pkgfile); @@ -637,8 +631,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, if(archive_read_data_skip(archive)) { _alpm_log(handle, ALPM_LOG_ERROR, _("error while reading package %s: %s\n"), pkgfile, archive_error_string(archive)); - handle->pm_errno = ALPM_ERR_LIBARCHIVE; - goto error; + GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error); } /* if we are not doing a full read, see if we have all we need */ @@ -650,8 +643,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occurred */ _alpm_log(handle, ALPM_LOG_ERROR, _("error while reading package %s: %s\n"), pkgfile, archive_error_string(archive)); - handle->pm_errno = ALPM_ERR_LIBARCHIVE; - goto error; + GOTO_ERR(handle, ALPM_ERR_LIBARCHIVE, error); } if(!config) { |