Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=7c73094180a8190c89bf76e02394555ea8d467d3

commit 7c73094180a8190c89bf76e02394555ea8d467d3
Author: Michel Hermier <herm...@frugalware.org>
Date:   Tue Oct 21 15:45:21 2014 +0200

libpacman: Make refcounted_ptr auto conversion operator to pointer explicit.

diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp
index a07cae6..3e76f2c 100644
--- a/lib/libpacman/deps.cpp
+++ b/lib/libpacman/deps.cpp
@@ -503,7 +503,7 @@ int pmtrans_t::resolvedeps(FPtrList **data)
int usedep = 1;
if(m_handle->ignorepkg.contains(ps->name())) {
package_ptr dummypkg(new package(miss->target, NULL));
-                               QUESTION(this, PM_TRANS_CONV_INSTALL_IGNOREPKG, 
dummypkg, ps, NULL, &usedep);
+                               QUESTION(this, PM_TRANS_CONV_INSTALL_IGNOREPKG, 
dummypkg.get(), ps.get(), NULL, &usedep);
}
if(usedep) {
_pacman_log(PM_LOG_DEBUG, _("pulling dependency %s"), ps->name());
diff --git a/lib/libpacman/handle.cpp b/lib/libpacman/handle.cpp
index bd52f31..e0efbfe 100644
--- a/lib/libpacman/handle.cpp
+++ b/lib/libpacman/handle.cpp
@@ -173,7 +173,6 @@ Database *Handle::getDatabase(const char *treename)
return sdb;
}
}
-
return NULL;
}

diff --git a/lib/libpacman/kernel/frefcounted.h 
b/lib/libpacman/kernel/frefcounted.h
index 6ab9f08..68f7a5e 100644
--- a/lib/libpacman/kernel/frefcounted.h
+++ b/lib/libpacman/kernel/frefcounted.h
@@ -164,7 +164,7 @@ namespace flib
return get();
}

-               operator T * () const
+               explicit operator T * () const
{
return get();
}
diff --git a/lib/libpacman/package.cpp b/lib/libpacman/package.cpp
index a119579..a1f035c 100644
--- a/lib/libpacman/package.cpp
+++ b/lib/libpacman/package.cpp
@@ -418,7 +418,7 @@ const char *package_node::name() const
return m_name;
}

-bool package_node_less::operator () (const package_node *p1, const 
package_node *p2)
+bool package_node_less::operator () (const package_node_ptr p1, const 
package_node_ptr p2)
{
return strcmp(p1->name(), p2->name()) < 0;
}
diff --git a/lib/libpacman/package.h b/lib/libpacman/package.h
index 69fa218..ee51686 100644
--- a/lib/libpacman/package.h
+++ b/lib/libpacman/package.h
@@ -221,7 +221,7 @@ private:
typedef flib::refcounted_ptr<libpacman::package_node> package_node_ptr;
struct package_node_less
{
-               bool operator () (const package_node *p1, const package_node 
*p2);
+               bool operator () (const package_node_ptr p1, const 
package_node_ptr p2);
};
typedef flib::set<libpacman::package_node_ptr, package_node_less> 
package_node_set;

diff --git a/lib/libpacman/package/fpmpackage.cpp 
b/lib/libpacman/package/fpmpackage.cpp
index 67d92a9..fc7a78f 100644
--- a/lib/libpacman/package/fpmpackage.cpp
+++ b/lib/libpacman/package/fpmpackage.cpp
@@ -221,7 +221,7 @@ package_ptr _pacman_fpmpackage_load(const char *pkgfile)
/* internal */
info->m_path = strdup(pkgfile);

-       return(info);
+       return info;

error:
if(!ret) {
diff --git a/lib/libpacman/pacman.cpp b/lib/libpacman/pacman.cpp
index 8685c2a..d44abd9 100644
--- a/lib/libpacman/pacman.cpp
+++ b/lib/libpacman/pacman.cpp
@@ -932,7 +932,7 @@ void *pacman_sync_getinfo(pmsyncpkg_t *ps, unsigned char 
parm)
switch(parm) {
case PM_SYNC_TYPE: data = (void *)(long)ps->type; break;
case PM_SYNC_NAME: data = ps->pkg_name; break;
-               case PM_SYNC_PKG:  data = ps->pkg_new; break;
+               case PM_SYNC_PKG:  data = ps->pkg_new.get(); break;
case PM_SYNC_REPLACES: data = &ps->m_replaces; break;
default:
data = NULL;
diff --git a/lib/libpacman/pacman_p.h b/lib/libpacman/pacman_p.h
index dcaaff5..cbcf173 100644
--- a/lib/libpacman/pacman_p.h
+++ b/lib/libpacman/pacman_p.h
@@ -24,6 +24,7 @@
#include "pacman.h"

#include "util/fptrlist.h"
+#include "package.h"

#define DEFINE_CAST(c_type, cxx_type)         \
static inline c_type *c_cast(cxx_type *obj)   \
@@ -60,6 +61,9 @@ template <typename T>
static inline __pmlist_t *c_cast(FList<T> *obj)
{ return (__pmlist_t *)obj; }

+static inline struct __pmpkg_t *c_cast(const libpacman::package_ptr &obj)
+{ return (__pmpkg_t *)obj.get(); }
+
#undef DEFINE_CAST

#endif /* _PACMAN_P_H */
diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp
index cb587e4..76730ee 100644
--- a/lib/libpacman/trans.cpp
+++ b/lib/libpacman/trans.cpp
@@ -333,7 +333,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
if(cmp > 0) {
/* pkg_local version is newer -- get confirmation before adding */
int resp = 0;
-                               QUESTION(this, PM_TRANS_CONV_LOCAL_NEWER, 
pkg_local, NULL, NULL, &resp);
+                               QUESTION(this, PM_TRANS_CONV_LOCAL_NEWER, 
pkg_local.get(), NULL, NULL, &resp);
if(!resp) {
_pacman_log(PM_LOG_WARNING, _("%s-%s: local version is newer -- skipping"), 
pkg_local->name(), pkg_local->version());
return(0);
@@ -341,7 +341,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
} else if(cmp == 0) {
/* versions are identical -- get confirmation before adding */
int resp = 0;
-                               QUESTION(this, PM_TRANS_CONV_LOCAL_UPTODATE, 
pkg_local, NULL, NULL, &resp);
+                               QUESTION(this, PM_TRANS_CONV_LOCAL_UPTODATE, 
pkg_local.get(), NULL, NULL, &resp);
if(!resp) {
_pacman_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping"), 
pkg_local->name(), pkg_local->version());
return(0);
@@ -417,7 +417,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
/* ignore holdpkgs on upgrade */
if((this == m_handle->trans) && m_handle->holdpkg.contains(pkg_local->name())) {
int resp = 0;
-                               QUESTION(this, PM_TRANS_CONV_REMOVE_HOLDPKG, 
pkg_local, NULL, NULL, &resp);
+                               QUESTION(this, PM_TRANS_CONV_REMOVE_HOLDPKG, 
pkg_local.get(), NULL, NULL, &resp);
if(!resp) {
RET_ERR(PM_ERR_PKG_HOLD, -1);
}
@@ -1593,10 +1593,10 @@ int __pmtrans_t::commit(FPtrList **data)
}

if(pkg_new != nullptr) {
-                       event_arg0 = pkg_new;
-                       event_arg1 = pkg_local;
+                       event_arg0 = pkg_new.get();
+                       event_arg1 = pkg_local.get();
} else {
-                       event_arg0 = pkg_local;
+                       event_arg0 = pkg_local.get();
}

EVENT(this, trans_event_table[type].pre.event, event_arg0, event_arg1);
diff --git a/lib/libpacman/trans_sysupgrade.cpp 
b/lib/libpacman/trans_sysupgrade.cpp
index 8f9dbdd..987aefe 100644
--- a/lib/libpacman/trans_sysupgrade.cpp
+++ b/lib/libpacman/trans_sysupgrade.cpp
@@ -98,7 +98,7 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans)
} else {
/* get confirmation for the replacement */
int doreplace = 0;
-                                                       QUESTION(trans, 
PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, (void *)((Database *)*i)->treename(), 
&doreplace);
+                                                       QUESTION(trans, 
PM_TRANS_CONV_REPLACE_PKG, lpkg.get(), spkg.get(), (void *)((Database 
*)*i)->treename(), &doreplace);

if(doreplace) {
/* if confirmed, add this to the 'final' list, designating 'lpkg' as
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to