Port rpmostree-sysroot-core to C++

Prep for using https://cxx.rs
This commit is contained in:
Colin Walters 2020-12-11 20:14:56 +00:00 committed by OpenShift Merge Robot
parent 2409228d76
commit 7d96b598f6
2 changed files with 14 additions and 15 deletions

View File

@ -31,7 +31,7 @@ librpmostreed_la_SOURCES = \
src/daemon/rpmostreed-sysroot.h \ src/daemon/rpmostreed-sysroot.h \
src/daemon/rpmostreed-sysroot.c \ src/daemon/rpmostreed-sysroot.c \
src/daemon/rpmostree-sysroot-core.h \ src/daemon/rpmostree-sysroot-core.h \
src/daemon/rpmostree-sysroot-core.c \ src/daemon/rpmostree-sysroot-core.cxx \
src/daemon/rpmostree-sysroot-upgrader.h \ src/daemon/rpmostree-sysroot-upgrader.h \
src/daemon/rpmostree-sysroot-upgrader.cxx \ src/daemon/rpmostree-sysroot-upgrader.cxx \
src/daemon/rpmostreed-errors.h \ src/daemon/rpmostreed-errors.h \

View File

@ -79,13 +79,13 @@ generate_baselayer_refs (OstreeSysroot *sysroot,
/* existing deployments */ /* existing deployments */
for (; i < deployments->len; i++) for (; i < deployments->len; i++)
{ {
OstreeDeployment *deployment = deployments->pdata[i]; auto deployment = static_cast<OstreeDeployment*>(deployments->pdata[i]);
g_autofree char *base_rev = NULL; g_autofree char *base_rev = NULL;
if (!rpmostree_deployment_get_base_layer (repo, deployment, &base_rev, error)) if (!rpmostree_deployment_get_base_layer (repo, deployment, &base_rev, error))
return FALSE; return FALSE;
if (base_rev) if (base_rev)
g_hash_table_add (bases, g_steal_pointer (&base_rev)); g_hash_table_add (bases, util::move_nullify (base_rev));
} }
} }
@ -125,10 +125,10 @@ add_package_refs_to_set (RpmOstreeRefSack *rsack,
{ {
for (guint i = 0; i < pkglist->len; i++) for (guint i = 0; i < pkglist->len; i++)
{ {
DnfPackage *pkg = pkglist->pdata[i]; auto pkg = static_cast<DnfPackage *>(pkglist->pdata[i]);
g_autofree char *pkgref = g_autofree char *pkgref =
is_rojig ? rpmostree_get_rojig_branch_pkg (pkg) : rpmostree_get_cache_branch_pkg (pkg); is_rojig ? rpmostree_get_rojig_branch_pkg (pkg) : rpmostree_get_cache_branch_pkg (pkg);
g_hash_table_add (referenced_pkgs, g_steal_pointer (&pkgref)); g_hash_table_add (referenced_pkgs, util::move_nullify (pkgref));
} }
} }
@ -153,7 +153,7 @@ generate_pkgcache_refs (OstreeSysroot *sysroot,
g_autoptr(GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot); g_autoptr(GPtrArray) deployments = ostree_sysroot_get_deployments (sysroot);
for (guint i = 0; i < deployments->len; i++) for (guint i = 0; i < deployments->len; i++)
{ {
OstreeDeployment *deployment = deployments->pdata[i]; auto deployment = static_cast<OstreeDeployment *>(deployments->pdata[i]);
const char *current_checksum = ostree_deployment_get_csum (deployment); const char *current_checksum = ostree_deployment_get_csum (deployment);
g_autofree char *base_commit = NULL; g_autofree char *base_commit = NULL;
@ -209,7 +209,7 @@ generate_pkgcache_refs (OstreeSysroot *sysroot,
if (!rpmostree_nevra_to_cache_branch (nevra, &cachebranch, error)) if (!rpmostree_nevra_to_cache_branch (nevra, &cachebranch, error))
return FALSE; return FALSE;
g_hash_table_add (referenced_pkgs, g_steal_pointer (&cachebranch)); g_hash_table_add (referenced_pkgs, util::move_nullify (cachebranch));
} }
} }
@ -361,12 +361,12 @@ rpmostree_syscore_get_origin_merge_deployment (OstreeSysroot *self, const char *
for (guint i = 0; i < deployments->len; i++) for (guint i = 0; i < deployments->len; i++)
{ {
OstreeDeployment *deployment = deployments->pdata[i]; auto deployment = static_cast<OstreeDeployment*>(deployments->pdata[i]);
if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0) if (strcmp (ostree_deployment_get_osname (deployment), osname) != 0)
continue; continue;
return g_object_ref (deployment); return (OstreeDeployment*)g_object_ref (deployment);
} }
return NULL; return NULL;
@ -415,7 +415,7 @@ rpmostree_syscore_filter_deployments (OstreeSysroot *sysroot,
for (guint i = 0; i < deployments->len; i++) for (guint i = 0; i < deployments->len; i++)
{ {
OstreeDeployment *deployment = deployments->pdata[i]; auto deployment = static_cast<OstreeDeployment*>(deployments->pdata[i]);
/* Is this deployment booted? If so, note we're past the booted, /* Is this deployment booted? If so, note we're past the booted,
* and ensure it's added. */ * and ensure it's added. */
@ -449,7 +449,7 @@ rpmostree_syscore_filter_deployments (OstreeSysroot *sysroot,
if (new_deployments->len == deployments->len) if (new_deployments->len == deployments->len)
return NULL; return NULL;
return g_steal_pointer (&new_deployments); return util::move_nullify (new_deployments);
} }
/* A wrapper around ostree_sysroot_simple_write_deployment() that makes it easy to push /* A wrapper around ostree_sysroot_simple_write_deployment() that makes it easy to push
@ -465,11 +465,10 @@ rpmostree_syscore_write_deployment (OstreeSysroot *sysroot,
OstreeRepo *repo = ostree_sysroot_repo (sysroot); OstreeRepo *repo = ostree_sysroot_repo (sysroot);
/* we do our own cleanup afterwards */ /* we do our own cleanup afterwards */
OstreeSysrootSimpleWriteDeploymentFlags flags = auto flags = static_cast<OstreeSysrootSimpleWriteDeploymentFlags>(OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN);
OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN;
if (pushing_rollback) if (pushing_rollback)
flags |= (OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT | flags = static_cast<OstreeSysrootSimpleWriteDeploymentFlags>(flags | OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT |
OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_PENDING); OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_PENDING);
else else
{ {
@ -481,7 +480,7 @@ rpmostree_syscore_write_deployment (OstreeSysroot *sysroot,
if (!rpmostree_syscore_livefs_query (sysroot, booted, &is_live, error)) if (!rpmostree_syscore_livefs_query (sysroot, booted, &is_live, error))
return FALSE; return FALSE;
if (is_live) if (is_live)
flags |= OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_ROLLBACK; flags = static_cast<OstreeSysrootSimpleWriteDeploymentFlags>(flags | OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_ROLLBACK);
} }
} }