Skip to content

Commit

Permalink
Introduce cleanup function to free sd_bus
Browse files Browse the repository at this point in the history
  • Loading branch information
thkukuk committed May 8, 2024
1 parent ef1b8c5 commit c81f70f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wtmpdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

#if HAVE_SYSTEMD
#include <systemd/sd-bus.h>
#define _cleanup_(f) __attribute__((cleanup(f)))
#endif

#include "wtmpdb.h"
Expand Down Expand Up @@ -848,7 +849,7 @@ static int
soft_reboots_count (void)
{
unsigned soft_reboots_count = -1;
sd_bus *bus = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
sd_bus_error error = SD_BUS_ERROR_NULL;
int r;

Expand All @@ -863,7 +864,6 @@ soft_reboots_count (void)
"org.freedesktop.systemd1.Manager",
"SoftRebootsCount",
&error, 'u', &soft_reboots_count);
sd_bus_unref (bus);
if (r < 0)
{
/* systemd is too old, don't print error */
Expand Down

0 comments on commit c81f70f

Please sign in to comment.