systemctl: define main through macro and call ask_password_agent_close() from the macro

This doesn't save us anything, but I like consistency.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-11-20 10:22:26 +01:00
parent 0c760322a4
commit d1405af399
2 changed files with 8 additions and 8 deletions

View file

@ -4,6 +4,7 @@
#include <stdlib.h>
#include "pager.h"
#include "spawn-ask-password-agent.h"
#include "spawn-polkit-agent.h"
#include "static-destruct.h"
@ -12,6 +13,7 @@
int r; \
r = impl(argc, argv); \
static_destruct(); \
ask_password_agent_close(); \
polkit_agent_close(); \
pager_close(); \
return ret; \

View file

@ -51,6 +51,7 @@
#include "log.h"
#include "logs-show.h"
#include "macro.h"
#include "main-func.h"
#include "mkdir.h"
#include "pager.h"
#include "parse-util.h"
@ -8648,7 +8649,7 @@ static int logind_cancel_shutdown(void) {
#endif
}
int main(int argc, char*argv[]) {
static int run(int argc, char*argv[]) {
int r;
argv_cmdline = argv[0];
@ -8672,7 +8673,6 @@ int main(int argc, char*argv[]) {
goto finish;
if (arg_action != ACTION_SYSTEMCTL && running_in_chroot() > 0) {
if (!arg_quiet)
log_info("Running in chroot, ignoring request.");
r = 0;
@ -8738,10 +8738,6 @@ int main(int argc, char*argv[]) {
finish:
release_busses();
pager_close();
ask_password_agent_close();
polkit_agent_close();
strv_free(arg_types);
strv_free(arg_states);
strv_free(arg_properties);
@ -8750,6 +8746,8 @@ finish:
free(arg_root);
free(arg_esp_path);
/* Note that we return r here, not EXIT_SUCCESS, so that we can implement the LSB-like return codes */
return r < 0 ? EXIT_FAILURE : r;
/* Note that we return r here, not 0, so that we can implement the LSB-like return codes */
return r;
}
DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);