1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-03-01 09:51:50 -05:00

libalpm error cleanup, step 1

Remove unused error codes, begin refactoring some of the others.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2008-04-06 20:09:27 -05:00
parent 4004bf9caf
commit e4a4cf7ce5
6 changed files with 22 additions and 29 deletions

View File

@ -695,7 +695,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
_alpm_log(PM_LOG_DEBUG, "extracting files\n"); _alpm_log(PM_LOG_DEBUG, "extracting files\n");
if ((archive = archive_read_new()) == NULL) { if ((archive = archive_read_new()) == NULL) {
RET_ERR(PM_ERR_LIBARCHIVE_ERROR, -1); RET_ERR(PM_ERR_LIBARCHIVE, -1);
} }
archive_read_support_compression_all(archive); archive_read_support_compression_all(archive);

View File

@ -433,12 +433,6 @@ enum _pmerrno_t {
PM_ERR_DB_REMOVE, PM_ERR_DB_REMOVE,
/* Servers */ /* Servers */
PM_ERR_SERVER_BAD_URL, PM_ERR_SERVER_BAD_URL,
/* Configuration */
PM_ERR_OPT_LOGFILE,
PM_ERR_OPT_DBPATH,
PM_ERR_OPT_LOCALDB,
PM_ERR_OPT_SYNCDB,
PM_ERR_OPT_USESYSLOG,
/* Transactions */ /* Transactions */
PM_ERR_TRANS_NOT_NULL, PM_ERR_TRANS_NOT_NULL,
PM_ERR_TRANS_NULL, PM_ERR_TRANS_NULL,
@ -470,14 +464,16 @@ enum _pmerrno_t {
/* Misc */ /* Misc */
PM_ERR_USER_ABORT, PM_ERR_USER_ABORT,
PM_ERR_INTERNAL_ERROR, PM_ERR_INTERNAL_ERROR,
PM_ERR_LIBARCHIVE_ERROR,
PM_ERR_DB_SYNC, PM_ERR_DB_SYNC,
PM_ERR_RETRIEVE, PM_ERR_RETRIEVE,
PM_ERR_PKG_HOLD, PM_ERR_PKG_HOLD,
PM_ERR_INVALID_REGEX, PM_ERR_INVALID_REGEX,
/* Downloading */ /* Downloading */
PM_ERR_CONNECT_FAILED, PM_ERR_CONNECT_FAILED,
PM_ERR_FORK_FAILED PM_ERR_FORK_FAILED,
/* External library errors */
PM_ERR_LIBARCHIVE,
PM_ERR_LIBDOWNLOAD
}; };
extern enum _pmerrno_t pm_errno; extern enum _pmerrno_t pm_errno;

View File

@ -1,10 +1,7 @@
/* /*
* error.c * error.c
* *
* Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2002-2008 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -22,12 +19,13 @@
#include "config.h" #include "config.h"
#include <download.h> /* downloadLastErrString */
/* libalpm */ /* libalpm */
#include "error.h" #include "error.h"
#include "util.h" #include "util.h"
#include "alpm.h" #include "alpm.h"
/* TODO does this really need a file all on its own? */
const char SYMEXPORT *alpm_strerrorlast(void) const char SYMEXPORT *alpm_strerrorlast(void)
{ {
return alpm_strerror(pm_errno); return alpm_strerror(pm_errno);
@ -74,13 +72,6 @@ const char SYMEXPORT *alpm_strerror(int err)
/* Servers */ /* Servers */
case PM_ERR_SERVER_BAD_URL: case PM_ERR_SERVER_BAD_URL:
return _("invalid url for server"); return _("invalid url for server");
/* Configuration */
case PM_ERR_OPT_LOGFILE:
case PM_ERR_OPT_DBPATH:
case PM_ERR_OPT_LOCALDB:
case PM_ERR_OPT_SYNCDB:
case PM_ERR_OPT_USESYSLOG:
return _("could not set parameter");
/* Transactions */ /* Transactions */
case PM_ERR_TRANS_NOT_NULL: case PM_ERR_TRANS_NOT_NULL:
return _("transaction already initialized"); return _("transaction already initialized");
@ -137,8 +128,6 @@ const char SYMEXPORT *alpm_strerror(int err)
return _("user aborted the operation"); return _("user aborted the operation");
case PM_ERR_INTERNAL_ERROR: case PM_ERR_INTERNAL_ERROR:
return _("internal error"); return _("internal error");
case PM_ERR_LIBARCHIVE_ERROR:
return _("libarchive error");
case PM_ERR_PKG_HOLD: case PM_ERR_PKG_HOLD:
/* TODO wow this is not descriptive at all... what does this mean? */ /* TODO wow this is not descriptive at all... what does this mean? */
return _("not confirmed"); return _("not confirmed");
@ -147,6 +136,14 @@ const char SYMEXPORT *alpm_strerror(int err)
/* Downloading */ /* Downloading */
case PM_ERR_CONNECT_FAILED: case PM_ERR_CONNECT_FAILED:
return _("connection to remote host failed"); return _("connection to remote host failed");
/* Errors from external libraries- our own wrapper error */
case PM_ERR_LIBARCHIVE:
/* it would be nice to use archive_error_string() here, but that
* requires the archive struct, so we can't. Just use a generic
* error string instead. */
return _("libarchive error");
case PM_ERR_LIBDOWNLOAD:
return downloadLastErrString;
/* Unknown error! */ /* Unknown error! */
default: default:
return _("unexpected error"); return _("unexpected error");

View File

@ -509,7 +509,7 @@ void SYMEXPORT *alpm_pkg_changelog_open(pmpkg_t *pkg)
int ret = ARCHIVE_OK; int ret = ARCHIVE_OK;
if((archive = archive_read_new()) == NULL) { if((archive = archive_read_new()) == NULL) {
RET_ERR(PM_ERR_LIBARCHIVE_ERROR, NULL); RET_ERR(PM_ERR_LIBARCHIVE, NULL);
} }
archive_read_support_compression_all(archive); archive_read_support_compression_all(archive);
@ -995,7 +995,7 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile, unsigned short full)
} }
if((archive = archive_read_new()) == NULL) { if((archive = archive_read_new()) == NULL) {
RET_ERR(PM_ERR_LIBARCHIVE_ERROR, NULL); RET_ERR(PM_ERR_LIBARCHIVE, NULL);
} }
archive_read_support_compression_all(archive); archive_read_support_compression_all(archive);
@ -1052,7 +1052,7 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile, unsigned short full)
if(archive_read_data_skip(archive)) { if(archive_read_data_skip(archive)) {
_alpm_log(PM_LOG_ERROR, _("error while reading package %s: %s\n"), _alpm_log(PM_LOG_ERROR, _("error while reading package %s: %s\n"),
pkgfile, archive_error_string(archive)); pkgfile, archive_error_string(archive));
pm_errno = PM_ERR_LIBARCHIVE_ERROR; pm_errno = PM_ERR_LIBARCHIVE;
goto error; goto error;
} }
@ -1065,7 +1065,7 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile, unsigned short full)
if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occured */ if(ret != ARCHIVE_EOF && ret != ARCHIVE_OK) { /* An error occured */
_alpm_log(PM_LOG_ERROR, _("error while reading package %s: %s\n"), _alpm_log(PM_LOG_ERROR, _("error while reading package %s: %s\n"),
pkgfile, archive_error_string(archive)); pkgfile, archive_error_string(archive));
pm_errno = PM_ERR_LIBARCHIVE_ERROR; pm_errno = PM_ERR_LIBARCHIVE;
goto error; goto error;
} }

View File

@ -382,7 +382,7 @@ int _alpm_unpack(const char *archive, const char *prefix, const char *fn)
ALPM_LOG_FUNC; ALPM_LOG_FUNC;
if((_archive = archive_read_new()) == NULL) if((_archive = archive_read_new()) == NULL)
RET_ERR(PM_ERR_LIBARCHIVE_ERROR, -1); RET_ERR(PM_ERR_LIBARCHIVE, -1);
archive_read_support_compression_all(_archive); archive_read_support_compression_all(_archive);
archive_read_support_format_all(_archive); archive_read_support_format_all(_archive);

View File

@ -63,7 +63,7 @@ int main(int argc, char **argv)
case PM_ERR_PKG_OPEN: case PM_ERR_PKG_OPEN:
printf("Cannot open the given file.\n"); printf("Cannot open the given file.\n");
break; break;
case PM_ERR_LIBARCHIVE_ERROR: case PM_ERR_LIBARCHIVE:
case PM_ERR_PKG_INVALID: case PM_ERR_PKG_INVALID:
printf("Package is invalid.\n"); printf("Package is invalid.\n");
break; break;