From c3cff4f8f4153b9415fba23073fcbda7a98982d7 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 21 Dec 2020 16:08:51 +0000 Subject: [PATCH] Port rpmostree-builtin-status to C++ Prep for using https://cxx.rs/ --- Makefile-rpm-ostree.am | 2 +- ...n-status.c => rpmostree-builtin-status.cxx} | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) rename src/app/{rpmostree-builtin-status.c => rpmostree-builtin-status.cxx} (98%) diff --git a/Makefile-rpm-ostree.am b/Makefile-rpm-ostree.am index 1e46317a..41a1e757 100644 --- a/Makefile-rpm-ostree.am +++ b/Makefile-rpm-ostree.am @@ -37,7 +37,7 @@ rpm_ostree_SOURCES = src/app/main.cxx \ src/app/rpmostree-builtin-refresh-md.cxx \ src/app/rpmostree-builtin-reset.cxx \ src/app/rpmostree-pkg-builtins.cxx \ - src/app/rpmostree-builtin-status.c \ + src/app/rpmostree-builtin-status.cxx \ src/app/rpmostree-builtin-ex.c \ src/app/rpmostree-builtin-testutils.c \ src/app/rpmostree-builtin-shlib-backend.c \ diff --git a/src/app/rpmostree-builtin-status.c b/src/app/rpmostree-builtin-status.cxx similarity index 98% rename from src/app/rpmostree-builtin-status.c rename to src/app/rpmostree-builtin-status.cxx index c795fd33..e45c952b 100644 --- a/src/app/rpmostree-builtin-status.c +++ b/src/app/rpmostree-builtin-status.cxx @@ -114,7 +114,7 @@ print_packages (const char *k, guint max_key_len, continue; g_autofree char *quoted = rpmostree_maybe_shell_quote (pkg) ?: g_strdup (pkg); - g_ptr_array_add (packages_sorted, g_steal_pointer ("ed)); + g_ptr_array_add (packages_sorted, util::move_nullify (quoted)); } const guint n_packages = packages_sorted->len; @@ -128,7 +128,7 @@ print_packages (const char *k, guint max_key_len, guint current_width = 0; for (guint i = 0; i < n_packages; i++) { - const char *pkg = packages_sorted->pdata[i]; + auto pkg = static_cast(packages_sorted->pdata[i]); const guint pkg_width = strlen (pkg); /* first print */ @@ -166,7 +166,7 @@ lookup_array_and_canonicalize (GVariantDict *dict, g_clear_pointer (&ret, g_free); } - return g_steal_pointer (&ret); + return util::move_nullify (ret); } static void @@ -268,7 +268,7 @@ get_last_auto_update_run (GDBusConnection *connection, } *out_state = AUTO_UPDATE_SDSTATE_SERVICE_EXITED; - *out_last_run = g_steal_pointer (&last_run); + *out_last_run = util::move_nullify (last_run); return TRUE; } @@ -763,7 +763,7 @@ print_one_deployment (RPMOSTreeSysroot *sysroot_proxy, gv_nevra_to_evr (str, gv_nevra); const char *evr = str->str; - GPtrArray *pkgs = g_hash_table_lookup (grouped_evrs, evr); + auto pkgs = static_cast(g_hash_table_lookup (grouped_evrs, evr)); if (!pkgs) { pkgs = g_ptr_array_new_with_free_func (g_free); @@ -781,7 +781,7 @@ print_one_deployment (RPMOSTreeSysroot *sysroot_proxy, for (guint i = 0, n = pkgs->len; i < n; i++) { - const char *pkgname = g_ptr_array_index (pkgs, i); + auto pkgname = static_cast(g_ptr_array_index (pkgs, i)); if (i > 0) g_string_append_c (str, ' '); g_string_append (str, pkgname); @@ -829,7 +829,7 @@ print_one_deployment (RPMOSTreeSysroot *sysroot_proxy, g_string_append (str, " -> "); gv_nevra_to_evr (str, gv_nevra_new); const char *diff = str->str + original_size; - GPtrArray *pkgs = g_hash_table_lookup (grouped_diffs, diff); + auto pkgs = static_cast(g_hash_table_lookup (grouped_diffs, diff)); if (!pkgs) { pkgs = g_ptr_array_new_with_free_func (g_free); @@ -856,7 +856,7 @@ print_one_deployment (RPMOSTreeSysroot *sysroot_proxy, g_string_append (str, ", "); for (guint i = 0, n = pkgs->len; i < n; i++) { - const char *pkgname = g_ptr_array_index (pkgs, i); + auto pkgname = static_cast(g_ptr_array_index (pkgs, i)); if (i > 0) g_string_append_c (str, ' '); g_string_append (str, pkgname); @@ -1184,7 +1184,7 @@ fetch_history_deployment_gvariant (RORHistoryEntry *entry, if (!glnx_openat_rdonly (AT_FDCWD, fn, TRUE, &fd, &local_error)) { if (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) - return g_propagate_error (error, g_steal_pointer (&local_error)), FALSE; + return g_propagate_error (error, util::move_nullify (local_error)), FALSE; return TRUE; /* Note early return */ }