build-sys: use a single ENABLE_LOGIND conditional

We used ENABLE_LOGIND for the automake conditional, and HAVE_LOGIND
for the ifdef. That wasn't wrong, but it certainly was confusing.

Also, move the ifdeffery to avoid warning about unused static function
logind_set_wall_message() when logind is disabled.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-04-02 20:12:36 -04:00
parent a75e27eb70
commit 79f1c8f619
2 changed files with 8 additions and 9 deletions

View file

@ -1113,7 +1113,7 @@ if test "x$enable_logind" != "xno"; then
have_logind=yes
fi
AM_CONDITIONAL(ENABLE_LOGIND, [test "$have_logind" = "yes"])
AS_IF([test "$have_logind" = "yes"], [ AC_DEFINE(HAVE_LOGIND, [1], [Logind support available]) ])
AS_IF([test "$have_logind" = "yes"], [ AC_DEFINE(ENABLE_LOGIND, [1], [Logind support available]) ])
AC_ARG_WITH([kill-user-processes],
[AS_HELP_STRING([--without-kill-user-processes], [set logind's KillUserProcesses=no by default])])

View file

@ -3191,8 +3191,8 @@ static int start_unit(int argc, char *argv[], void *userdata) {
return r;
}
#ifdef ENABLE_LOGIND
static int logind_set_wall_message(void) {
#ifdef HAVE_LOGIND
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus;
_cleanup_free_ char *m = NULL;
@ -3220,15 +3220,14 @@ static int logind_set_wall_message(void) {
if (r < 0)
return log_warning_errno(r, "Failed to set wall message, ignoring: %s", bus_error_message(&error, r));
#endif
return 0;
}
#endif
/* Ask systemd-logind, which might grant access to unprivileged users
* through PolicyKit */
static int logind_reboot(enum action a) {
#ifdef HAVE_LOGIND
#ifdef ENABLE_LOGIND
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *method, *description;
sd_bus *bus;
@ -3291,7 +3290,7 @@ static int logind_reboot(enum action a) {
}
static int logind_check_inhibitors(enum action a) {
#ifdef HAVE_LOGIND
#ifdef ENABLE_LOGIND
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_strv_free_ char **sessions = NULL;
const char *what, *who, *why, *mode;
@ -3410,7 +3409,7 @@ static int logind_check_inhibitors(enum action a) {
}
static int logind_prepare_firmware_setup(void) {
#ifdef HAVE_LOGIND
#ifdef ENABLE_LOGIND
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus;
int r;
@ -8281,7 +8280,7 @@ static int halt_now(enum action a) {
static int logind_schedule_shutdown(void) {
#ifdef HAVE_LOGIND
#ifdef ENABLE_LOGIND
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
char date[FORMAT_TIMESTAMP_MAX];
const char *action;
@ -8409,7 +8408,7 @@ static int runlevel_main(void) {
}
static int logind_cancel_shutdown(void) {
#ifdef HAVE_LOGIND
#ifdef ENABLE_LOGIND
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus;
int r;