From: Yu Watanabe Date: Sun, 25 Nov 2018 20:13:00 +0000 (+0900) Subject: journal-gateway: use _cleanup_ attribute to stop microhttpd daemon X-Git-Tag: v240~107^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0d2a1a2085282d6226ecab284dfdda44a44bd53e;p=thirdparty%2Fsystemd.git journal-gateway: use _cleanup_ attribute to stop microhttpd daemon --- diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index 69bc447920e..b779a521d51 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -982,7 +982,7 @@ static int parse_argv(int argc, char *argv[]) { } int main(int argc, char *argv[]) { - struct MHD_Daemon *d = NULL; + _cleanup_(MHD_stop_daemonp) struct MHD_Daemon *d = NULL; int r, n; log_setup_service(); @@ -1068,8 +1068,5 @@ int main(int argc, char *argv[]) { r = EXIT_SUCCESS; finish: - if (d) - MHD_stop_daemon(d); - return r; } diff --git a/src/journal-remote/microhttpd-util.h b/src/journal-remote/microhttpd-util.h index a50a2a75c7f..364cd0f7cfd 100644 --- a/src/journal-remote/microhttpd-util.h +++ b/src/journal-remote/microhttpd-util.h @@ -73,3 +73,5 @@ int check_permissions(struct MHD_Connection *connection, int *code, char **hostn * interesting events without overwhelming detail. */ int setup_gnutls_logger(char **categories); + +DEFINE_TRIVIAL_CLEANUP_FUNC(struct MHD_Daemon*, MHD_stop_daemon);