From 0117349af8bd78180b623edbcfa6932ac1b6cb91 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Mar 04 2021 13:33:37 +0000 Subject: Apply clang-format to reflow the code --- diff --git a/src/txnupd.cpp b/src/txnupd.cpp index dbcc701..dacf41a 100644 --- a/src/txnupd.cpp +++ b/src/txnupd.cpp @@ -39,8 +39,8 @@ static const PluginInfo info = {.name = "TxnUpd", .version = TXNUPD_PLUGIN_VERSI // Pointer to instance of this structure is returned by pluginInitHandle() as handle. struct _PluginHandle { PluginMode mode; - DnfContext * context; // store plugin context specific init data - bool transactional_update; // flag to determine if doing a transactional update + DnfContext * context; // store plugin context specific init data + bool transactional_update; // flag to determine if doing a transactional update TransactionalUpdate::Transaction transaction{}; // transactional update object }; @@ -54,14 +54,14 @@ const PluginInfo * pluginGetInfo(void) { PluginHandle * pluginInitHandle(int version, PluginMode mode, DnfPluginInitData * initData) { auto logger(libdnf::Log::getLogger()); if (version != 1) { - auto msg = std::string(info.name) + ": " + __func__ + ": Error: Unsupported API version"; - logger->error(msg); - return nullptr; + auto msg = std::string(info.name) + ": " + __func__ + ": Error: Unsupported API version"; + logger->error(msg); + return nullptr; } if (mode != PLUGIN_MODE_CONTEXT) { - auto msg = std::string(info.name) + ": " + __func__ + ": Warning: Unsupported mode"; - logger->warning(msg); - return nullptr; + auto msg = std::string(info.name) + ": " + __func__ + ": Warning: Unsupported mode"; + logger->warning(msg); + return nullptr; } auto handle = new PluginHandle; handle->mode = mode; @@ -73,7 +73,7 @@ PluginHandle * pluginInitHandle(int version, PluginMode mode, DnfPluginInitData // Destroys the plugin instance identified by given handle. void pluginFreeHandle(PluginHandle * handle) { if (handle) - delete handle; + delete handle; } @@ -94,10 +94,10 @@ static bool setupTransactionalUpdate(PluginHandle * handle) { */ const std::string installRoot = dnf_context_get_install_root(handle->context); if (!installRoot.empty() && installRoot.compare("/") != 0) { - auto instroot_msg = - std::string(info.name) + ": " + __func__ + ": Warning: Using installroot, disabling transactional-update!"; - logger->warning(instroot_msg); - return true; + auto instroot_msg = + std::string(info.name) + ": " + __func__ + ": Warning: Using installroot, disabling transactional-update!"; + logger->warning(instroot_msg); + return true; } /* Also, all of the transactional-update stuff only works as root. @@ -106,10 +106,10 @@ static bool setupTransactionalUpdate(PluginHandle * handle) { * as non-root. */ if (getuid() != 0) { - auto rootuid_msg = std::string(info.name) + ": " + __func__ + - ": Warning: operating as non-root, disabling transactional-update!"; - logger->warning(rootuid_msg); - return true; + auto rootuid_msg = std::string(info.name) + ": " + __func__ + + ": Warning: operating as non-root, disabling transactional-update!"; + logger->warning(rootuid_msg); + return true; } /* Now that we've gotten the basic early-bail conditions handled, @@ -122,14 +122,14 @@ static bool setupTransactionalUpdate(PluginHandle * handle) { * we try to proceed any further. */ if (!(handle->transaction.isInitialized())) { - auto txnfail_msg = - std::string(info.name) + ": " + __func__ + ": Error: failed to initialize transactional update!"; - logger->error(txnfail_msg); - return false; + auto txnfail_msg = + std::string(info.name) + ": " + __func__ + ": Error: failed to initialize transactional update!"; + logger->error(txnfail_msg); + return false; } auto txnupd_snapid_msg = - std::string(info.name) + ": " + __func__ + ": Info: Created snapshot ID " + handle->transaction.getSnapshot(); + std::string(info.name) + ": " + __func__ + ": Info: Created snapshot ID " + handle->transaction.getSnapshot(); logger->debug(txnupd_snapid_msg); auto transactionRoot = handle->transaction.getRoot(); dnf_context_set_install_root(handle->context, transactionRoot.c_str()); @@ -137,7 +137,7 @@ static bool setupTransactionalUpdate(PluginHandle * handle) { /* Disable SWDB as it currently causes crashes with transactional updates, * and it is not particularly useful for our case anyway. */ - dnf_context_set_write_history (handle->context, FALSE); + dnf_context_set_write_history(handle->context, FALSE); /* Mark as being in the transactional update mode, so that * other functions using the handle can do the right thing later. @@ -162,9 +162,9 @@ static bool configureTransactionContext(PluginHandle * handle) { * as we need it disabled for this type of transaction. */ if (!dnf_conf_main_set_option("installonlypkgs", DNF_CONF_PLUGINDEFAULT, "", NULL)) { - auto instonlypkgs_msg = std::string(info.name) + ": " + __func__ + - ": Error: installonlypkgs was not successfully overridden!"; - logger->error(instonlypkgs_msg); + auto instonlypkgs_msg = + std::string(info.name) + ": " + __func__ + ": Error: installonlypkgs was not successfully overridden!"; + logger->error(instonlypkgs_msg); return false; } @@ -172,9 +172,9 @@ static bool configureTransactionContext(PluginHandle * handle) { * impacts the running system and it could misguidedly stop upgrades. */ if (!dnf_conf_main_set_option("protect_running_kernel", DNF_CONF_PLUGINDEFAULT, "0", NULL)) { - auto protectkernel_msg = std::string(info.name) + ": " + __func__ + - ": Error: protect_running_kernel was not successfully disabled!"; - logger->error(protectkernel_msg); + auto protectkernel_msg = + std::string(info.name) + ": " + __func__ + ": Error: protect_running_kernel was not successfully disabled!"; + logger->error(protectkernel_msg); return false; } @@ -196,10 +196,10 @@ static bool completeTransactionalUpdate(PluginHandle * handle) { * and bail out early if we are not. */ if (!(handle->transactional_update)) { - auto txnupd_msg = - std::string(info.name) + ": " + __func__ + ": Warning: Not a transactional update, so doing nothing!"; - logger->warning(txnupd_msg); - return true; + auto txnupd_msg = + std::string(info.name) + ": " + __func__ + ": Warning: Not a transactional update, so doing nothing!"; + logger->warning(txnupd_msg); + return true; } /* Finally, complete the transaction and finalize @@ -213,17 +213,17 @@ static bool completeTransactionalUpdate(PluginHandle * handle) { // The plugin "main loop" int pluginHook(PluginHandle * handle, PluginHookId id, DnfPluginHookData * hookData, DnfPluginError * error) { if (!handle) - return 1; + return 1; switch (id) { - case PLUGIN_HOOK_ID_CONTEXT_PRE_REPOS_RELOAD: - return setupTransactionalUpdate(handle); - case PLUGIN_HOOK_ID_CONTEXT_CONF: - return configureTransactionContext(handle); - case PLUGIN_HOOK_ID_CONTEXT_TRANSACTION: - return completeTransactionalUpdate(handle); - default: - break; + case PLUGIN_HOOK_ID_CONTEXT_PRE_REPOS_RELOAD: + return setupTransactionalUpdate(handle); + case PLUGIN_HOOK_ID_CONTEXT_CONF: + return configureTransactionContext(handle); + case PLUGIN_HOOK_ID_CONTEXT_TRANSACTION: + return completeTransactionalUpdate(handle); + default: + break; } return 1; }