X Tutup
Skip to content

Commit 360f3dc

Browse files
yuwatakeszybz
authored andcommitted
busctl: use static destructor and DEFINE_MAIN_FUNCTION() macro
1 parent 608f8ec commit 360f3dc

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/busctl/busctl.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "json.h"
1919
#include "locale-util.h"
2020
#include "log.h"
21+
#include "main-func.h"
2122
#include "pager.h"
2223
#include "parse-util.h"
2324
#include "path-util.h"
@@ -55,6 +56,8 @@ static bool arg_augment_creds = true;
5556
static bool arg_watch_bind = false;
5657
static usec_t arg_timeout = 0;
5758

59+
STATIC_DESTRUCTOR_REGISTER(arg_matches, strv_freep);
60+
5861
#define NAME_IS_ACQUIRED INT_TO_PTR(1)
5962
#define NAME_IS_ACTIVATABLE INT_TO_PTR(2)
6063

@@ -2417,24 +2420,17 @@ static int busctl_main(int argc, char *argv[]) {
24172420
return dispatch_verb(argc, argv, verbs, NULL);
24182421
}
24192422

2420-
int main(int argc, char *argv[]) {
2423+
static int run(int argc, char *argv[]) {
24212424
int r;
24222425

24232426
log_parse_environment();
24242427
log_open();
24252428

24262429
r = parse_argv(argc, argv);
24272430
if (r <= 0)
2428-
goto finish;
2429-
2430-
r = busctl_main(argc, argv);
2431-
2432-
finish:
2433-
/* make sure we terminate the bus connection first, and then close the
2434-
* pager, see issue #3543 for the details. */
2435-
pager_close();
2436-
2437-
arg_matches = strv_free(arg_matches);
2431+
return r;
24382432

2439-
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
2433+
return busctl_main(argc, argv);
24402434
}
2435+
2436+
DEFINE_MAIN_FUNCTION(run);

0 commit comments

Comments
 (0)
X Tutup