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

commit f660790ff114e6f8e56535c6047bb1eb72b2d6d4
Author: Michel Hermier <herm...@frugalware.org>
Date:   Tue Oct 21 10:40:47 2014 +0200

libpacman: Move a bunch of NULL to nullptr in preparation of the refcounted 
package_ptr.

diff --git a/lib/libpacman/conflict.cpp b/lib/libpacman/conflict.cpp
index 5617527..cc04672 100644
--- a/lib/libpacman/conflict.cpp
+++ b/lib/libpacman/conflict.cpp
@@ -65,7 +65,7 @@ FPtrList pmtrans_t::checkconflicts()

for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++i) {
package_ptr tp = (*i)->pkg_new;
-               if(tp == NULL) {
+               if(tp == nullptr) {
continue;
}
remain = flib::count(i, end);
@@ -289,7 +289,7 @@ FPtrList pmtrans_t::find_conflicts()
/* if it's a directory, then we have no conflict */
ok = 1;
} else {
-                                       if(dbpkg == NULL) {
+                                       if(dbpkg == nullptr) {
dbpkg = db_local->find(p->name());
}
if(dbpkg && !(dbpkg->flags & INFRQ_FILES)) {
diff --git a/lib/libpacman/database_cache.cpp b/lib/libpacman/database_cache.cpp
index 4720fe4..7d8863c 100644
--- a/lib/libpacman/database_cache.cpp
+++ b/lib/libpacman/database_cache.cpp
@@ -69,7 +69,7 @@ int _pacman_db_load_pkgcache(Database *db)
inforeq, db->treename());

db->rewind();
-       while((info = db->readpkg(inforeq)) != NULL) {
+       while((info = db->readpkg(inforeq)) != nullptr) {
/* add to the collective */
db->pkgcache.add(info);
}
@@ -101,7 +101,7 @@ libpacman::package_set &Database::get_packages()

int Database::add_pkgincache(package_ptr pkg)
{
-       if(pkg == NULL) {
+       if(pkg == nullptr) {
return(-1);
}

@@ -115,7 +115,7 @@ int Database::add_pkgincache(package_ptr pkg)

int Database::remove_pkgfromcache(package_ptr pkg)
{
-       if(pkg == NULL) {
+       if(pkg == nullptr) {
return(-1);
}

diff --git a/lib/libpacman/db.cpp b/lib/libpacman/db.cpp
index db4bf81..8efa4ce 100644
--- a/lib/libpacman/db.cpp
+++ b/lib/libpacman/db.cpp
@@ -157,7 +157,7 @@ package_ptr Database::find(const PackageMatcher 
&packagematcher)
if(packagematcher.match(pkg)) {
if(packagematcher.match(pkg, ~PM_PACKAGE_FLAG_PROVIDES)) {
return pkg;
-                       } else if (ret == NULL) {
+                       } else if (ret == nullptr) {
/* Store provide match */
ret = pkg;
}
@@ -247,7 +247,7 @@ const char *Database::treename() const

int Database::write(package_ptr info, unsigned int inforeq)
{
-       ASSERT(info != NULL, RET_ERR(PM_ERR_PKG_INVALID, -1));
+       ASSERT(info != nullptr, RET_ERR(PM_ERR_PKG_INVALID, -1));
RET_ERR(PM_ERR_WRONG_ARGS, -1); // Not supported
}

diff --git a/lib/libpacman/db/fakedb.cpp b/lib/libpacman/db/fakedb.cpp
index 16101ff..8c4bafd 100644
--- a/lib/libpacman/db/fakedb.cpp
+++ b/lib/libpacman/db/fakedb.cpp
@@ -41,7 +41,7 @@ package_ptr _pacman_fakedb_pkg_new(const char *name)
char *str = NULL;

package_ptr dummy(new package(NULL, NULL));
-       if(dummy == NULL) {
+       if(dummy == nullptr) {
RET_ERR(PM_ERR_MEMORY, NULL);
}

diff --git a/lib/libpacman/db/localdb.cpp b/lib/libpacman/db/localdb.cpp
index 185bb83..ce7590d 100644
--- a/lib/libpacman/db/localdb.cpp
+++ b/lib/libpacman/db/localdb.cpp
@@ -61,7 +61,7 @@ LocalDatabase *LocalPackage::database() const
}

static
-int _pacman_localpkg_file_reader(Database *db, package_ptr pkg, unsigned int 
flags, unsigned int flags_masq, const char *file, int (*reader)(package *, FILE 
*))
+int _pacman_localpkg_file_reader(Database *db, package *pkg, unsigned int 
flags, unsigned int flags_masq, const char *file, int (*reader)(package *, FILE 
*))
{
int ret = 0;

@@ -403,7 +403,7 @@ int LocalDatabase::write(package_ptr info, unsigned int 
inforeq)
mode_t oldmask;
int retval = 0;

-       ASSERT(info != NULL, RET_ERR(PM_ERR_PKG_INVALID, -1));
+       ASSERT(info != nullptr, RET_ERR(PM_ERR_PKG_INVALID, -1));

snprintf(path, PATH_MAX, "%s/%s-%s", this->path, info->name(), info->version());
oldmask = umask(0000);
diff --git a/lib/libpacman/db/localdb_files.cpp 
b/lib/libpacman/db/localdb_files.cpp
index b84c90a..16fbe26 100644
--- a/lib/libpacman/db/localdb_files.cpp
+++ b/lib/libpacman/db/localdb_files.cpp
@@ -60,7 +60,7 @@ int _pacman_db_read_lines(FStringList &list, char *s, size_t 
size, FILE *fp)
return lines;
}

-int _pacman_localdb_desc_fread(package_ptr info, FILE *fp)
+int _pacman_localdb_desc_fread(package *info, FILE *fp)
{
char line[512];
int sline = sizeof(line)-1;
@@ -183,7 +183,7 @@ error:
return -1;
}

-int _pacman_localdb_depends_fread(package_ptr info, FILE *fp)
+int _pacman_localdb_depends_fread(package *info, FILE *fp)
{
char line[512];
int sline = sizeof(line)-1;
@@ -219,7 +219,7 @@ int _pacman_localdb_depends_fread(package_ptr info, FILE 
*fp)
return 0;
}

-int _pacman_localdb_files_fread(package_ptr info, FILE *fp)
+int _pacman_localdb_files_fread(package *info, FILE *fp)
{
char line[512];
int sline = sizeof(line)-1;
diff --git a/lib/libpacman/db/localdb_files.h b/lib/libpacman/db/localdb_files.h
index c4f182b..8d841b5 100644
--- a/lib/libpacman/db/localdb_files.h
+++ b/lib/libpacman/db/localdb_files.h
@@ -84,9 +84,9 @@
#define INFRQ_SCRIPLET PM_LOCALPACKAGE_FLAGS_SCRIPLET
#define INFRQ_ALL PM_LOCALPACKAGE_FLAGS_ALL

-int _pacman_localdb_desc_fread(libpacman::package_ptr info, FILE *fp);
-int _pacman_localdb_depends_fread(libpacman::package_ptr info, FILE *fp);
-int _pacman_localdb_files_fread(libpacman::package_ptr info, FILE *fp);
+int _pacman_localdb_desc_fread(libpacman::package *info, FILE *fp);
+int _pacman_localdb_depends_fread(libpacman::package *info, FILE *fp);
+int _pacman_localdb_files_fread(libpacman::package *info, FILE *fp);

#endif /* _PACMAN_LOCALDB_FILES_H */

diff --git a/lib/libpacman/db/syncdb.cpp b/lib/libpacman/db/syncdb.cpp
index f0002a0..447919a 100644
--- a/lib/libpacman/db/syncdb.cpp
+++ b/lib/libpacman/db/syncdb.cpp
@@ -74,7 +74,7 @@ SyncDatabase *SyncPackage::database() const
}

static
-int _pacman_syncpkg_file_reader(SyncDatabase *db, package_ptr pkg, unsigned 
int flags, unsigned int flags_masq, int (*reader)(package_ptr, FILE *))
+int _pacman_syncpkg_file_reader(SyncDatabase *db, package *pkg, unsigned int 
flags, unsigned int flags_masq, int (*reader)(package *, FILE *))
{
int ret = 0;

diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp
index 47141c6..a07cae6 100644
--- a/lib/libpacman/deps.cpp
+++ b/lib/libpacman/deps.cpp
@@ -131,10 +131,10 @@ void pmtrans_t::sortbydeps(int mode)

/* We compute the edges */
for(auto i = vertices.begin(), end = vertices.end(); i != end; ++i) {
-               package_ptr p_i = (*i)->data->pkg_new != NULL ? 
(*i)->data->pkg_new : (*i)->data->pkg_local;
+               package_ptr p_i = (*i)->data->pkg_new != nullptr ? 
(*i)->data->pkg_new : (*i)->data->pkg_local;
/* TODO this should be somehow combined with _pacman_checkdeps */
for(auto j = vertices.begin(); j != end; ++j) {
-                       package_ptr p_j = (*j)->data->pkg_new != NULL ? 
(*j)->data->pkg_new : (*j)->data->pkg_local;
+                       package_ptr p_j = (*j)->data->pkg_new != nullptr ? 
(*j)->data->pkg_new : (*j)->data->pkg_local;
int child = 0;
auto &depends = p_i->depends();
for(auto k = depends.begin(), k_end = depends.end(); k != k_end && !child; ++k) 
{
@@ -209,7 +209,7 @@ FPtrList pmtrans_t::checkdeps(unsigned char op)
pmsyncpkg_t *syncpkg = *i;
package_ptr pkg_new = syncpkg->pkg_new, pkg_local = syncpkg->pkg_local;

-               if(pkg_local != NULL) {
+               if(pkg_local != nullptr) {
bool found = false;
auto &requiredby = pkg_local->requiredby();
for(auto j = requiredby.begin(), j_end = requiredby.end(); j != j_end; ++j) {
@@ -221,7 +221,7 @@ FPtrList pmtrans_t::checkdeps(unsigned char op)
*/
package_ptr p;

-                                       if((p = 
db_local->find(requiredby_name)) == NULL) {
+                                       if((p = 
db_local->find(requiredby_name)) == nullptr) {
/* hmmm... package isn't installed.. */
continue;
}
@@ -250,7 +250,7 @@ FPtrList pmtrans_t::checkdeps(unsigned char op)
for(auto k = syncpkgs.begin(), k_end = syncpkgs.end(); !found && k != k_end; 
++k) {
pmsyncpkg_t *ps = *k;

-                                                       if(ps->pkg_new != NULL 
&& ps->pkg_new->provides(pkg_local->name())) {
+                                                       if(ps->pkg_new != 
nullptr && ps->pkg_new->provides(pkg_local->name())) {
found = true;
}
}
@@ -380,7 +380,7 @@ void pmtrans_t::removedeps()
}

dep = db->find(depend.name);
-                       if(dep == NULL) {
+                       if(dep == nullptr) {
/* package not found... look for a provisio instead */
auto whatPackagesProvide = db->whatPackagesProvide(depend.name);
if(whatPackagesProvide.empty()) {
@@ -388,7 +388,7 @@ void pmtrans_t::removedeps()
continue;
}
dep = db->find((*whatPackagesProvide.begin())->name());
-                               if(dep == NULL) {
+                               if(dep == nullptr) {
_pacman_log(PM_LOG_ERROR, _("dep is NULL!"));
/* wtf */
continue;
@@ -477,7 +477,7 @@ int pmtrans_t::resolvedeps(FPtrList **data)
ps = *provides.begin();
}
}
-               if(ps == NULL) {
+               if(ps == nullptr) {
_pacman_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\" (\"%s\" is 
not in the package set)"),
miss->target, miss->depend.name);
if(data != NULL) {
@@ -610,7 +610,7 @@ int pacman_output_generate(FStringList *targets, FPtrList 
*dblist) {
do {
foundMatch = 0;
package_ptr pkg = db->readpkg(inforeq);
-            while(pkg != NULL) {
+            while(pkg != nullptr) {
const char *pname = pkg->name();
if(targets != NULL && targets->remove(pname)) {
foundMatch = 1;
diff --git a/lib/libpacman/kernel/frefcounted.h 
b/lib/libpacman/kernel/frefcounted.h
index c5c9921..32147bb 100644
--- a/lib/libpacman/kernel/frefcounted.h
+++ b/lib/libpacman/kernel/frefcounted.h
@@ -80,11 +80,9 @@ namespace flib

template <class Y>
explicit refcounted_ptr(Y *ptr)
-                       : m_refcounted_ptr(ptr)
+                       : refcounted_ptr()
{
-                       if(m_refcounted_ptr != nullptr) {
-                               m_refcounted_ptr->acquire();
-                       }
+                       reset(ptr);
}

template <class Y>
@@ -94,13 +92,11 @@ namespace flib

~refcounted_ptr()
{
-                       if(m_refcounted_ptr != nullptr) {
-                               m_refcounted_ptr->release();
-                       }
+                       reset();
}

template <class Y>
-               refcounted_ptr<Y> &operator = (const refcounted_ptr<Y> &o)
+               refcounted_ptr<T> &operator = (const refcounted_ptr<Y> &o)
{
reset(o.m_refcounted_ptr);
return *this;
@@ -109,13 +105,19 @@ namespace flib
/* Manipulators */
void reset()
{
-                       reset<T>(*this, nullptr);
+                       reset<T>(nullptr);
}

template <class Y>
void reset(Y *ptr)
{
-                       swap(*this, refcounted_ptr<T>(ptr));
+                       if(m_refcounted_ptr != nullptr) {
+                               m_refcounted_ptr->release();
+                       }
+                       if(ptr != nullptr) {
+                               ptr->acquire();
+                       }
+                       m_refcounted_ptr = ptr;
}

void swap(refcounted_ptr<T> &o)
@@ -161,12 +163,36 @@ bool operator == (const flib::refcounted_ptr<T> &lhs, 
const flib::refcounted_ptr
return lhs.get() == rhs.get();
}

+template <class T>
+bool operator == (const flib::refcounted_ptr<T> &lhs, std::nullptr_t rhs)
+{
+       return lhs.get() == rhs;
+}
+
+template <class T>
+bool operator == (std::nullptr_t lhs, const flib::refcounted_ptr<T> &rhs)
+{
+       return lhs == rhs.get();
+}
+
template <class T, class U>
bool operator != (const flib::refcounted_ptr<T> &lhs, const 
flib::refcounted_ptr<U> &rhs)
{
return lhs.get() != rhs.get();
}

+template <class T>
+bool operator != (const flib::refcounted_ptr<T> &lhs, std::nullptr_t rhs)
+{
+       return lhs.get() != rhs;
+}
+
+template <class T>
+bool operator != (std::nullptr_t lhs, const flib::refcounted_ptr<T> &rhs)
+{
+       return lhs != rhs.get();
+}
+
#endif /* FREFCOUNTED_H */

/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libpacman/package.cpp b/lib/libpacman/package.cpp
index 23fc92d..c8d81ef 100644
--- a/lib/libpacman/package.cpp
+++ b/lib/libpacman/package.cpp
@@ -48,7 +48,7 @@

using namespace libpacman;

-package::package(Database *database = 0)
+package::package(Database *database)
: m_database(database)
, m_reason(PM_PKG_REASON_EXPLICIT)
{ }
@@ -153,13 +153,13 @@ const package_ptr _pacman_pkg_isin(const char *needle, 
const package_list &hayst
}

for(auto lp = haystack.begin(), end = haystack.end(); lp != end; ++lp) {
-               package *info = *lp;
+               package_ptr info = *lp;

if(info && !strcmp(info->name(), needle)) {
return info;
}
}
-       return NULL;
+       return nullptr;
}

bool package::splitname(const char *target, char *name, char *version, int 
witharch)
@@ -214,7 +214,7 @@ int package::write(unsigned int flags)

ASSERT(m_database != NULL, RET_ERR(PM_ERR_DB_NULL, -1));

-       if((ret = m_database->write(this, flags)) != 0) {
+       if((ret = m_database->write(package_ptr(this), flags)) != 0) {
_pacman_log(PM_LOG_ERROR, _("could not update requiredby for database entry 
%s-%s"),
name(), version());
}
@@ -353,8 +353,8 @@ struct FPackageStrMatcher
};

static
-int _pacman_strmatcher_match(const FStrMatcher *strmatcher, package_ptr pkg, 
int flags) {
-       ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, 0));
+int _pacman_strmatcher_match(const FStrMatcher *strmatcher, const package_ptr 
&pkg, int flags) {
+       ASSERT(pkg != nullptr, RET_ERR(PM_ERR_WRONG_ARGS, 0));

/* FIXME: Make const when const accessors are available */
if(((flags & PM_PACKAGE_FLAG_NAME) && strmatcher->match(pkg->name())) ||
@@ -394,7 +394,7 @@ PackageMatcher::PackageMatcher(const FStrMatcher 
*strmatcher, int flags)
PackageMatcher::~PackageMatcher()
{ }

-bool PackageMatcher::match(const package_ptr package, int mask = ~0) const
+bool PackageMatcher::match(const package_ptr package, int mask) const
{
return _pacman_strmatcher_match(m_strmatcher, package, m_flags & mask);
}
diff --git a/lib/libpacman/package.h b/lib/libpacman/package.h
index c892ad7..38612c6 100644
--- a/lib/libpacman/package.h
+++ b/lib/libpacman/package.h
@@ -222,7 +222,7 @@ private:

private:
char m_name[PKG_NAME_LEN];
-               flib::set<libpacman::package_ptr> m_packages;
+               libpacman::package_set m_packages;
};

struct package_node_less
@@ -230,11 +230,13 @@ private:
bool operator () (const package_node *p1, const package_node *p2);
};

+       typedef flib::set<flib::refcounted_ptr<libpacman::package_node>, 
package_node_less> package_node_set;
+
class package_graph
-               : flib::set<flib::refcounted_ptr<libpacman::package_node>, 
package_node_less>
+               : package_node_set
{
public:
-               using set::set;
+               using package_node_set::package_node_set;
};
} // namespace libpacman

diff --git a/lib/libpacman/package/fpmpackage.cpp 
b/lib/libpacman/package/fpmpackage.cpp
index ebd5913..67d92a9 100644
--- a/lib/libpacman/package/fpmpackage.cpp
+++ b/lib/libpacman/package/fpmpackage.cpp
@@ -147,7 +147,7 @@ package_ptr _pacman_fpmpackage_load(const char *pkgfile)
RET_ERR(PM_ERR_PKG_OPEN, NULL);
}
package_ptr info(new package(NULL, NULL));
-       if(info == NULL) {
+       if(info == nullptr) {
archive_read_finish (archive);
RET_ERR(PM_ERR_MEMORY, NULL);
}
diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp
index 978a9ac..cb587e4 100644
--- a/lib/libpacman/trans.cpp
+++ b/lib/libpacman/trans.cpp
@@ -110,10 +110,10 @@ int _pacman_trans_compute_triggers(pmtrans_t *trans)
for(auto lp = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); lp != end; 
++lp) {
pmsyncpkg_t *ps = *lp;

-               if(ps->pkg_new != NULL) {
+               if(ps->pkg_new != nullptr) {
trans->triggers.add(ps->pkg_new->triggers());
}
-               if(ps->pkg_local != NULL) {
+               if(ps->pkg_local != nullptr) {
trans->triggers.add(ps->pkg_local->triggers());
}
}
@@ -292,7 +292,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
Database *dbs = *i;
if(strcmp(dbs->treename(), targline) == 0) {
pkg_new = dbs->find(targ);
-                                       if(pkg_new == NULL) {
+                                       if(pkg_new == nullptr) {
/* Search provides */
_pacman_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), 
targ);
auto p = dbs->whatPackagesProvide(targ);
@@ -310,7 +310,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
Database *dbs = *i;
pkg_new = dbs->find(targ);
}
-                       if(pkg_new == NULL) {
+                       if(pkg_new == nullptr) {
/* Search provides */
_pacman_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), 
targ);
for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != 
end && !pkg_new; ++i) {
@@ -323,7 +323,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
}
}
}
-               if(pkg_new == NULL) {
+               if(pkg_new == nullptr) {
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
}

@@ -357,7 +357,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
}

pkg_new = _pacman_filedb_load(NULL, target);
-                       if(pkg_new == NULL || !pkg_new->is_valid(this, target)) 
{
+                       if(pkg_new == nullptr || !pkg_new->is_valid(this, 
target)) {
/* pm_errno is already set by _pacman_filedb_load() */
goto error;
}
@@ -365,14 +365,14 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
pkg_local = db_local->find(pkg_new->name());
if(type != PM_TRANS_TYPE_UPGRADE) {
/* only install this package if it is not already installed */
-                               if(pkg_local != NULL) {
+                               if(pkg_local != nullptr) {
pm_errno = PM_ERR_PKG_INSTALLED;
goto error;
}
} else {
if(flags & PM_TRANS_FLAG_FRESHEN) {
/* only upgrade/install this package if it is already installed and at a lesser 
version */
-                                       if(pkg_local == NULL || 
_pacman_versioncmp(pkg_local->version(), pkg_new->version()) >= 0) {
+                                       if(pkg_local == nullptr || 
_pacman_versioncmp(pkg_local->version(), pkg_new->version()) >= 0) {
pm_errno = PM_ERR_PKG_CANT_FRESH;
goto error;
}
@@ -409,7 +409,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk
RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
}

-                       if((pkg_local = db_local->scan(target, INFRQ_ALL)) == 
NULL) {
+                       if((pkg_local = db_local->scan(target, INFRQ_ALL)) == 
nullptr) {
_pacman_log(PM_LOG_ERROR, _("could not find %s in database"), target);
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
}
@@ -427,7 +427,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t 
type, int flags, pmsyncpk

add:
/* add the package to the transaction */
-       name = pkg_new != NULL ? pkg_new->name() : pkg_local->name();
+       name = pkg_new != nullptr ? pkg_new->name() : pkg_local->name();
if(!find(name)) {
pmsyncpkg_t *ps = new __pmsyncpkg_t();

@@ -456,7 +456,7 @@ int __pmtrans_t::prepare(FPtrList **data)
int ret = 0;

/* Sanity checks */
-       ASSERT((db_local = m_handle->db_local) != NULL, RET_ERR(PM_ERR_DB_NULL, 
-1));
+       ASSERT((db_local = m_handle->db_local) != nullptr, 
RET_ERR(PM_ERR_DB_NULL, -1));

if(data != NULL) {
*data = new FPtrList();
@@ -615,7 +615,7 @@ int __pmtrans_t::prepare(FPtrList **data)
if(doremove) {
pmsyncpkg_t *rsync = find(miss->depend.name);
package_ptr q(new package(miss->depend.name, NULL));
-                                                       if(q == NULL) {
+                                                       if(q == nullptr) {
if(data) {
FREELIST(*data);
}
@@ -984,7 +984,7 @@ int _pacman_fpmpackage_install(package_ptr pkg, 
pmtranstype_t type, pmtrans_t *t
if(handle->noupgrade.contains(pathname)) {
notouch = 1;
} else {
-                                                       if(type == 
PM_TRANS_TYPE_ADD || oldpkg == NULL) {
+                                                       if(type == 
PM_TRANS_TYPE_ADD || oldpkg == nullptr) {
nb = pkg->backup().contains(pathname);
} else {
/* op == PM_TRANS_TYPE_UPGRADE */
@@ -1483,7 +1483,7 @@ int __pmtrans_t::commit(FPtrList **data)
if(tr->add(str, tr->m_type, tr->flags, &ps_new) == -1) {
goto error;
}
-               if(ps_new != NULL && ps_new->pkg_new != NULL) {
+               if(ps_new != NULL && ps_new->pkg_new != nullptr) {
spkg = ps_new->pkg_new;
if(ps->m_flags & PM_TRANS_FLAG_ALLDEPS || flags & PM_TRANS_FLAG_ALLDEPS) {
spkg->m_reason = PM_PKG_REASON_DEPEND;
@@ -1518,7 +1518,7 @@ int __pmtrans_t::commit(FPtrList **data)
if(!pkg_new->requiredby().contains(*k)) {
/* replace old's name with new's name in the requiredby's dependency list */
package_ptr depender(db_local->find(*k));
-                                               if(depender == NULL) {
+                                               if(depender == nullptr) {
/* If the depending package no longer exists in the local db,
* then it must have ALSO conflicted with ps->pkg.  If
* that's the case, then we don't have anything to propagate
@@ -1579,7 +1579,7 @@ int __pmtrans_t::commit(FPtrList **data)
}

/* see if this is an upgrade.  if so, remove the old package first */
-               if(pkg_local == NULL) {
+               if(pkg_local == nullptr) {
/* no previous package version is installed, so this is actually
* just an install.  */
type &= ~PM_TRANS_TYPE_REMOVE;
@@ -1592,7 +1592,7 @@ int __pmtrans_t::commit(FPtrList **data)
}
}

-               if(pkg_new != NULL) {
+               if(pkg_new != nullptr) {
event_arg0 = pkg_new;
event_arg1 = pkg_local;
} else {
@@ -1671,7 +1671,7 @@ int __pmtrans_t::commit(FPtrList **data)
continue;
}
depinfo = db_local->find(depend.name);
-                       if(depinfo == NULL) {
+                       if(depinfo == nullptr) {
/* look for a provides package */
auto provides = db_local->whatPackagesProvide(depend.name);
if(!provides.empty()) {
@@ -1681,7 +1681,7 @@ int __pmtrans_t::commit(FPtrList **data)
/* use the first one */
depinfo = db_local->find((*provides.begin())->name());
}
-                               if(depinfo == NULL) {
+                               if(depinfo == nullptr) {
_pacman_log(PM_LOG_ERROR, _("could not find dependency '%s'"), depend.name);
/* wtf */
continue;
@@ -1719,7 +1719,7 @@ int __pmtrans_t::commit(FPtrList **data)
auto &cache = db_local->get_packages();
for(auto lp = cache.begin(), lp_end = cache.end(); lp != lp_end; ++lp) {
package_ptr tmpp(*lp);
-                       if(tmpp == NULL) {
+                       if(tmpp == nullptr) {
continue;
}
auto &depends = tmpp->depends();
@@ -1762,7 +1762,7 @@ int __pmtrans_t::commit(FPtrList **data)
continue;
}
package_ptr depinfo(db_local->find(depend.name));
-                       if(depinfo == NULL) {
+                       if(depinfo == nullptr) {
/* look for a provides package */
auto provides = db_local->whatPackagesProvide(depend.name);
if(!provides.empty()) {
@@ -1772,7 +1772,7 @@ int __pmtrans_t::commit(FPtrList **data)
/* use the first one */
depinfo = db_local->find((*provides.begin())->name());
}
-                               if(depinfo == NULL) {
+                               if(depinfo == nullptr) {
_pacman_log(PM_LOG_ERROR, _("could not find dependency '%s'"), depend.name);
/* wtf */
continue;
diff --git a/lib/libpacman/trans_sysupgrade.cpp 
b/lib/libpacman/trans_sysupgrade.cpp
index e7475a6..8f9dbdd 100644
--- a/lib/libpacman/trans_sysupgrade.cpp
+++ b/lib/libpacman/trans_sysupgrade.cpp
@@ -140,7 +140,7 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans)
for(auto j = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); !spkg && j 
!= end; ++j) {
spkg = ((Database *)*j)->find(local->name());
}
-               if(spkg == NULL) {
+               if(spkg == nullptr) {
_pacman_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), 
local->name());
continue;
}
diff --git a/lib/libpacman/util.cpp b/lib/libpacman/util.cpp
index db6413f..77d25f3 100644
--- a/lib/libpacman/util.cpp
+++ b/lib/libpacman/util.cpp
@@ -484,10 +484,10 @@ int _pacman_check_freespace(pmtrans_t *trans, pmlist_t 
**data)
for(auto i = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); i != end; 
++i) {
pmsyncpkg_t *ps = *i;

-               if(ps->pkg_new != NULL) {
+               if(ps->pkg_new != nullptr) {
pkgsize += ps->pkg_new->usize;
}
-               if(ps->pkg_local != NULL) {
+               if(ps->pkg_local != nullptr) {
pkgsize -= ps->pkg_local->size;
}
}
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to