Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make code C++20 compatible #1615

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ if(ENABLE_SOLV_URPMREORDER)
add_definitions(-DLIBSOLV_FLAG_URPMREORDER=1)
endif()

# If defined, libsolv adds the prefix "dep_" to solvable dependencies.
# As a result, `requires` is renamed to `dep_requires`.
# Needed for C++20. `requires` is a keyword in C++20.
add_definitions(-DLIBSOLV_SOLVABLE_PREPEND_DEP)

if(WITH_SANITIZERS)
message(WARNING "Building with sanitizers enabled!")
Expand Down
8 changes: 4 additions & 4 deletions libdnf/goal/Goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,11 @@ static bool
*/
can_depend_on(Pool *pool, Solvable *sa, Id b)
{
IdQueue requires;
IdQueue dep_requires;

solvable_lookup_idarray(sa, SOLVABLE_REQUIRES, requires.getQueue());
for (int i = 0; i < requires.size(); ++i) {
Id req_dep = requires[i];
solvable_lookup_idarray(sa, SOLVABLE_REQUIRES, dep_requires.getQueue());
for (int i = 0; i < dep_requires.size(); ++i) {
Id req_dep = dep_requires[i];
Id p, pp;

FOR_PROVIDES(p, pp, req_dep)
Expand Down
6 changes: 3 additions & 3 deletions libdnf/module/ModulePackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ void ModulePackage::createDependencies(Solvable *solvable) const
Pool * pool = dnf_sack_get_pool(moduleSack);

for (const auto &dependency : getModuleDependencies()) {
for (const auto &requires : dependency.getRequires()) {
for (const auto &singleRequires : requires) {
for (const auto &dep_requires : dependency.getRequires()) {
for (const auto &singleRequires : dep_requires) {
auto moduleName = singleRequires.first;
std::vector<std::string> requiresStream;
for (const auto &moduleStream : singleRequires.second) {
Expand Down Expand Up @@ -192,7 +192,7 @@ void ModulePackage::createDependencies(Solvable *solvable) const
ss << "(";
ss << std::accumulate(std::next(requiresStream.begin()),
requiresStream.end(), requiresStream[0],
[](std::string & a, std::string & b)
[](const std::string & a, const std::string & b)
{ return a + " or " + b; });
ss << ")";
depId = pool_parserpmrichdep(pool, ss.str().c_str());
Expand Down
20 changes: 10 additions & 10 deletions libdnf/module/ModulePackageContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,11 @@ void ModulePackageContainer::enableDependencyTree(std::vector<ModulePackage *> &
Query query(pImpl->moduleSack);
query.addFilter(HY_PKG, HY_EQ, pImpl->activatedModules.get());
auto pkg = dnf_package_new(pImpl->moduleSack, modulePackage->getId());
auto requires = dnf_package_get_requires(pkg);
query.addFilter(HY_PKG_PROVIDES, requires);
auto dep_requires = dnf_package_get_requires(pkg);
query.addFilter(HY_PKG_PROVIDES, dep_requires);
auto set = query.runSet();
toEnable += *set;
delete requires;
delete dep_requires;
g_object_unref(pkg);
enable(modulePackage);
enabled.set(modulePackage->getId());
Expand All @@ -836,11 +836,11 @@ void ModulePackageContainer::enableDependencyTree(std::vector<ModulePackage *> &
query.addFilter(HY_PKG, HY_EQ, pImpl->activatedModules.get());
query.addFilter(HY_PKG, HY_NEQ, &enabled);
auto pkg = dnf_package_new(pImpl->moduleSack, moduleId);
auto requires = dnf_package_get_requires(pkg);
query.addFilter(HY_PKG_PROVIDES, requires);
auto dep_requires = dnf_package_get_requires(pkg);
query.addFilter(HY_PKG_PROVIDES, dep_requires);
auto set = query.runSet();
toEnable += *set;
delete requires;
delete dep_requires;
g_object_unref(pkg);
}
toEnable -= enabled;
Expand Down Expand Up @@ -1747,8 +1747,8 @@ void ModulePackageContainer::Impl::addVersion2Modules()
std::map<std::string, std::map<std::string, std::vector<ModulePackage *>>> v3_context_map;
for (auto const & module_pair : modules) {
auto * module = module_pair.second.get();
auto requires = module->getRequires(true);
auto concentratedRequires = concentrateVectorString(requires);
auto dep_requires = module->getRequires(true);
auto concentratedRequires = concentrateVectorString(dep_requires);
v3_context_map[module->getNameStream()][concentratedRequires].push_back(module);
}
libdnf::LibsolvRepo * repo;
Expand All @@ -1758,8 +1758,8 @@ void ModulePackageContainer::Impl::addVersion2Modules()
for (auto & module_tuple : modulesV2) {
std::tie(repo, mdStream, repoID) = module_tuple;
auto nameStream = ModulePackage::getNameStream(mdStream);
auto requires = ModulePackage::getRequires(mdStream, true);
auto concentratedRequires = concentrateVectorString(requires);
auto dep_requires = ModulePackage::getRequires(mdStream, true);
auto concentratedRequires = concentrateVectorString(dep_requires);
auto streamIterator = v3_context_map.find(nameStream);
if (streamIterator != v3_context_map.end()) {
auto contextIterator = streamIterator->second.find(concentratedRequires);
Expand Down
4 changes: 2 additions & 2 deletions libdnf/sack/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1669,7 +1669,7 @@ Query::Impl::filterObsoletes(const Filter & f, Map *m)
Solvable *s = pool_id2solvable(pool, id);
if (!s->repo)
continue;
for (Id *r_id = s->repo->idarraydata + s->obsoletes; *r_id; ++r_id) {
for (Id *r_id = s->repo->idarraydata + s->dep_obsoletes; *r_id; ++r_id) {
Id r, rr;

FOR_PROVIDES(r, rr, *r_id) {
Expand All @@ -1691,7 +1691,7 @@ Query::Impl::obsoletesByPriority(Pool * pool, Solvable * candidate, Map * m, con
{
if (!candidate->repo)
return;
for (Id *r_id = candidate->repo->idarraydata + candidate->obsoletes; *r_id; ++r_id) {
for (Id *r_id = candidate->repo->idarraydata + candidate->dep_obsoletes; *r_id; ++r_id) {
Id r, rr;
FOR_PROVIDES(r, rr, *r_id) {
if (!MAPTST(target, r))
Expand Down
10 changes: 5 additions & 5 deletions tests/hawkey/fixtures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <check.h>
#include <stdarg.h>
#include <unistd.h>


#include "libdnf/hy-package.h"
#include "libdnf/hy-repo.h"
#include "libdnf/hy-iutil.h"
#include "libdnf/dnf-sack-private.hpp"

#include "fixtures.h"
#include "testsys.h"

#include <check.h>
#include <stdarg.h>
#include <unistd.h>

/* define the global variable */
struct TestGlobals_s test_globals;

Expand Down
11 changes: 6 additions & 5 deletions tests/hawkey/test_goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <check.h>
#include <glib.h>
#include <stdarg.h>
#include <vector>

#include "libdnf/goal/Goal.hpp"
#include "libdnf/dnf-types.h"
#include "libdnf/hy-goal-private.hpp"
Expand All @@ -37,10 +32,16 @@
#include "libdnf/hy-selector.h"
#include "libdnf/hy-util-private.hpp"
#include "libdnf/sack/packageset.hpp"

#include "fixtures.h"
#include "testsys.h"
#include "test_suites.h"

#include <check.h>
#include <glib.h>
#include <stdarg.h>
#include <vector>

static DnfPackage *
get_latest_pkg(DnfSack *sack, const char *name)
{
Expand Down
18 changes: 9 additions & 9 deletions tests/hawkey/test_iutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <stdlib.h>
#include <unistd.h>
#include <glib.h>


#include <solv/pool.h>
#include <solv/repo.h>
#include <solv/repo_write.h>


#include "libdnf/hy-util.h"
#include "libdnf/hy-iutil.h"
#include "libdnf/hy-iutil-private.hpp"

#include "fixtures.h"
#include "test_suites.h"

#include <solv/pool.h>
#include <solv/repo.h>
#include <solv/repo_write.h>

#include <stdlib.h>
#include <unistd.h>
#include <glib.h>

static void
build_test_file(const char *filename)
{
Expand Down
14 changes: 6 additions & 8 deletions tests/hawkey/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "fixtures.h"
#include "test_suites.h"
#include "testsys.h"

#include <solv/util.h>

#include <assert.h>
#include <check.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>


#include <solv/util.h>


#include "fixtures.h"
#include "test_suites.h"
#include "testsys.h"

#define TESTREPODATADIR TESTDATADIR "/hawkey"

static int
Expand Down
8 changes: 4 additions & 4 deletions tests/hawkey/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/


#include <solv/util.h>


#include "libdnf/dnf-advisory.h"
#include "libdnf/hy-package.h"
Expand All @@ -30,12 +28,14 @@
#include "libdnf/dnf-reldep-list.h"
#include "libdnf/dnf-sack-private.hpp"
#include "libdnf/hy-util.h"
#include "libdnf/repo/solvable/Dependency.hpp"
#include "libdnf/repo/solvable/DependencyContainer.hpp"

#include "fixtures.h"
#include "test_suites.h"
#include "testsys.h"

#include "libdnf/repo/solvable/Dependency.hpp"
#include "libdnf/repo/solvable/DependencyContainer.hpp"
#include <solv/util.h>

START_TEST(test_package_summary)
{
Expand Down
3 changes: 2 additions & 1 deletion tests/hawkey/test_packageset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
#include "libdnf/hy-package-private.hpp"
#include "libdnf/hy-packageset-private.hpp"
#include "libdnf/dnf-sack-private.hpp"
#include "libdnf/sack/packageset.hpp"

#include "fixtures.h"
#include "test_suites.h"
#include "libdnf/sack/packageset.hpp"

static DnfPackageSet *pset;

Expand Down
13 changes: 6 additions & 7 deletions tests/hawkey/test_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <check.h>


#include <solv/testcase.h>


#include "libdnf/hy-query.h"
#include "libdnf/hy-query-private.hpp"
#include "libdnf/hy-package.h"
#include "libdnf/hy-packageset.h"
#include "libdnf/dnf-reldep.h"
#include "libdnf/dnf-reldep-list.h"
#include "libdnf/dnf-sack-private.hpp"
#include "libdnf/repo/solvable/DependencyContainer.hpp"
#include "libdnf/sack/packageset.hpp"
#include "libdnf/sack/query.hpp"

#include "fixtures.h"
#include "test_suites.h"
#include "testsys.h"

#include "libdnf/repo/solvable/DependencyContainer.hpp"
#include <solv/testcase.h>

#include <check.h>


static int
size_and_free(HyQuery query)
Expand Down
10 changes: 5 additions & 5 deletions tests/hawkey/test_reldep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/


#include <memory>

#include "libdnf/hy-package.h"
#include "libdnf/dnf-reldep.h"
#include "libdnf/dnf-reldep-list.h"
#include "libdnf/dnf-sack.h"
#include "libdnf/repo/solvable/DependencyContainer.hpp"
#include "libdnf/repo/solvable/Dependency.hpp"

#include <memory>

#include "fixtures.h"
#include "test_suites.h"
#include "testsys.h"
#include "libdnf/repo/solvable/DependencyContainer.hpp"
#include "libdnf/repo/solvable/Dependency.hpp"

START_TEST(test_reldeplist_add)
{
Expand Down
7 changes: 4 additions & 3 deletions tests/hawkey/test_repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <check.h>
#include <string.h>

#include "libdnf/hy-iutil-private.hpp"
#include "libdnf/hy-repo-private.hpp"
#include "libdnf/repo/Repo-private.hpp"

#include "fixtures.h"
#include "testshared.h"
#include "test_suites.h"

#include <check.h>
#include <string.h>

START_TEST(test_strings)
{
HyRepo hrepo = hy_repo_create("happy2");
Expand Down
22 changes: 11 additions & 11 deletions tests/hawkey/test_sack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <check.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>


#include <solv/testcase.h>

#include <glib/gstdio.h>

#include <libdnf/repo/Repo-private.hpp>
#include "libdnf/dnf-types.h"
#include "libdnf/hy-package-private.hpp"
#include "libdnf/hy-repo-private.hpp"
#include "libdnf/dnf-sack-private.hpp"
#include "libdnf/hy-util.h"
#include "libdnf/hy-iutil-private.hpp"

#include "fixtures.h"
#include "testsys.h"
#include "test_suites.h"

#include <solv/testcase.h>

#include <glib/gstdio.h>

#include <check.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

START_TEST(test_environment)
{
/* check the tmpdir was created */
Expand Down
Loading
Loading