summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-03-28 12:54:47 -0500
committerDan McGee <dan@archlinux.org>2011-04-15 18:37:09 -0500
commitdff2d916baac88b71dec0af81645ea2fe876cf6c (patch)
tree3297106e5c136a63b58960e3444553e2e8c551b7 /lib
parentdd8cf0c12dd5e8bf951933723558eadc5c6f04af (diff)
downloadpacman-dff2d916baac88b71dec0af81645ea2fe876cf6c.tar.xz
Remove indirection on get_name and get_version operations
For a package to be loaded from any of our backends, these two fields are always required upfront. Due to this fact, we don't need them to be backend-specific operations and can just refer to the field directly. Additionally, our static (and thus private) cache package accessors had a NULL check on pkg before returning the relevant field. Eliminate this since they only way they are ever called is via the packages attached callback struct, which would have caused the NULL pointer dereference in the first place. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/be_local.c19
-rw-r--r--lib/libalpm/package.c8
-rw-r--r--lib/libalpm/package.h2
3 files changed, 2 insertions, 27 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 788b3c6f..a60a0590 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -52,7 +52,6 @@
do { \
ALPM_LOG_FUNC; \
ASSERT(handle != NULL, return (errret)); \
- ASSERT(pkg != NULL, return (errret)); \
if(pkg->origin != PKG_FROM_FILE && !(pkg->infolevel & info)) { \
_alpm_local_db_read(pkg->origin_data.db, pkg, info); \
} \
@@ -71,18 +70,6 @@ static const char *_cache_get_filename(pmpkg_t *pkg)
return pkg->filename;
}
-static const char *_cache_get_name(pmpkg_t *pkg)
-{
- ASSERT(pkg != NULL, return NULL);
- return pkg->name;
-}
-
-static const char *_cache_get_version(pmpkg_t *pkg)
-{
- ASSERT(pkg != NULL, return NULL);
- return pkg->version;
-}
-
static const char *_cache_get_desc(pmpkg_t *pkg)
{
LAZY_LOAD(INFRQ_DESC, NULL);
@@ -161,7 +148,6 @@ static int _cache_has_scriptlet(pmpkg_t *pkg)
/* Sanity checks */
ASSERT(handle != NULL, return -1);
- ASSERT(pkg != NULL, return -1);
if(!(pkg->infolevel & INFRQ_SCRIPTLET)) {
_alpm_local_db_read(pkg->origin_data.db, pkg, INFRQ_SCRIPTLET);
@@ -211,7 +197,6 @@ static alpm_list_t *_cache_get_files(pmpkg_t *pkg)
/* Sanity checks */
ASSERT(handle != NULL, return NULL);
- ASSERT(pkg != NULL, return NULL);
if(pkg->origin == PKG_FROM_LOCALDB
&& !(pkg->infolevel & INFRQ_FILES)) {
@@ -226,7 +211,6 @@ static alpm_list_t *_cache_get_backup(pmpkg_t *pkg)
/* Sanity checks */
ASSERT(handle != NULL, return NULL);
- ASSERT(pkg != NULL, return NULL);
if(pkg->origin == PKG_FROM_LOCALDB
&& !(pkg->infolevel & INFRQ_FILES)) {
@@ -247,7 +231,6 @@ static void *_cache_changelog_open(pmpkg_t *pkg)
/* Sanity checks */
ASSERT(handle != NULL, return NULL);
- ASSERT(pkg != NULL, return NULL);
char clfile[PATH_MAX];
snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
@@ -299,8 +282,6 @@ static int _cache_changelog_close(const pmpkg_t *pkg, void *fp)
*/
static struct pkg_operations local_pkg_ops = {
.get_filename = _cache_get_filename,
- .get_name = _cache_get_name,
- .get_version = _cache_get_version,
.get_desc = _cache_get_desc,
.get_url = _cache_get_url,
.get_builddate = _cache_get_builddate,
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 59a1283b..3a4f23fd 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -99,8 +99,6 @@ int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg)
* a lazy-load cache. However, the defaults will work just fine for fully-
* populated package structures. */
static const char *_pkg_get_filename(pmpkg_t *pkg) { return pkg->filename; }
-static const char *_pkg_get_name(pmpkg_t *pkg) { return pkg->name; }
-static const char *_pkg_get_version(pmpkg_t *pkg) { return pkg->version; }
static const char *_pkg_get_desc(pmpkg_t *pkg) { return pkg->desc; }
static const char *_pkg_get_url(pmpkg_t *pkg) { return pkg->url; }
static time_t _pkg_get_builddate(pmpkg_t *pkg) { return pkg->builddate; }
@@ -133,8 +131,6 @@ static int _pkg_changelog_close(const pmpkg_t *pkg, void *fp) { return EOF; }
*/
struct pkg_operations default_pkg_ops = {
.get_filename = _pkg_get_filename,
- .get_name = _pkg_get_name,
- .get_version = _pkg_get_version,
.get_desc = _pkg_get_desc,
.get_url = _pkg_get_url,
.get_builddate = _pkg_get_builddate,
@@ -173,12 +169,12 @@ const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg)
const char SYMEXPORT *alpm_pkg_get_name(pmpkg_t *pkg)
{
- return pkg->ops->get_name(pkg);
+ return pkg->name;
}
const char SYMEXPORT *alpm_pkg_get_version(pmpkg_t *pkg)
{
- return pkg->ops->get_version(pkg);
+ return pkg->version;
}
const char SYMEXPORT *alpm_pkg_get_desc(pmpkg_t *pkg)
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 0b5f32d4..35e4500d 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -46,8 +46,6 @@ typedef enum _pmpkgfrom_t {
*/
struct pkg_operations {
const char *(*get_filename) (pmpkg_t *);
- const char *(*get_name) (pmpkg_t *);
- const char *(*get_version) (pmpkg_t *);
const char *(*get_desc) (pmpkg_t *);
const char *(*get_url) (pmpkg_t *);
time_t (*get_builddate) (pmpkg_t *);