From: Jan Janssen Date: Sat, 23 Apr 2022 13:53:29 +0000 (+0200) Subject: tree-wide: Simplify variable declarations behind #ifdef X-Git-Tag: v251-rc2~66 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d5a99b7c9c65ab7651c51de4db81d34cfd51f143;p=thirdparty%2Fsystemd.git tree-wide: Simplify variable declarations behind #ifdef --- diff --git a/src/basic/random-util.c b/src/basic/random-util.c index f2e68fcddde..a9fe25432ce 100644 --- a/src/basic/random-util.c +++ b/src/basic/random-util.c @@ -100,9 +100,7 @@ static void clear_srand_initialization(void) { void initialize_srand(void) { static bool pthread_atfork_registered = false; unsigned x; -#if HAVE_SYS_AUXV_H - const void *auxv; -#endif + if (srand_called) return; @@ -113,7 +111,7 @@ void initialize_srand(void) { * AT_RANDOM data might be used by other stuff too (in particular: ASLR), and we probably shouldn't * leak the seed for that. */ - auxv = ULONG_TO_PTR(getauxval(AT_RANDOM)); + const void *auxv = ULONG_TO_PTR(getauxval(AT_RANDOM)); if (auxv) { static const uint8_t auxval_hash_key[16] = { 0x92, 0x6e, 0xfe, 0x1b, 0xcf, 0x00, 0x52, 0x9c, 0xcc, 0x42, 0xcf, 0xdc, 0x94, 0x1f, 0x81, 0x0f diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 65eec8f6b7e..a4c37307d21 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -354,10 +354,6 @@ static int property_get_syscall_filter( _cleanup_strv_free_ char **l = NULL; int r; -#if HAVE_SECCOMP - void *id, *val; -#endif - assert(bus); assert(reply); assert(c); @@ -371,6 +367,7 @@ static int property_get_syscall_filter( return r; #if HAVE_SECCOMP + void *id, *val; HASHMAP_FOREACH_KEY(val, id, c->syscall_filter) { _cleanup_free_ char *name = NULL; const char *e = NULL; @@ -423,10 +420,6 @@ static int property_get_syscall_log( _cleanup_strv_free_ char **l = NULL; int r; -#if HAVE_SECCOMP - void *id, *val; -#endif - assert(bus); assert(reply); assert(c); @@ -440,6 +433,7 @@ static int property_get_syscall_log( return r; #if HAVE_SECCOMP + void *id, *val; HASHMAP_FOREACH_KEY(val, id, c->syscall_log) { char *name = NULL; @@ -475,15 +469,12 @@ static int property_get_syscall_archs( _cleanup_strv_free_ char **l = NULL; int r; -#if HAVE_SECCOMP - void *id; -#endif - assert(bus); assert(reply); assert(c); #if HAVE_SECCOMP + void *id; SET_FOREACH(id, c->syscall_archs) { const char *name; diff --git a/src/core/execute.c b/src/core/execute.c index 61bfedfcd3d..b3e64ade1bd 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -6012,11 +6012,6 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { prefix, yes_no(c->lock_personality)); if (c->syscall_filter) { -#if HAVE_SECCOMP - void *id, *val; - bool first = true; -#endif - fprintf(f, "%sSystemCallFilter: ", prefix); @@ -6025,6 +6020,8 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { fputc('~', f); #if HAVE_SECCOMP + void *id, *val; + bool first = true; HASHMAP_FOREACH_KEY(val, id, c->syscall_filter) { _cleanup_free_ char *name = NULL; const char *errno_name = NULL; @@ -6052,15 +6049,12 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { } if (c->syscall_archs) { -#if HAVE_SECCOMP - void *id; -#endif - fprintf(f, "%sSystemCallArchitectures:", prefix); #if HAVE_SECCOMP + void *id; SET_FOREACH(id, c->syscall_archs) fprintf(f, " %s", strna(seccomp_arch_to_string(PTR_TO_UINT32(id) - 1))); #endif @@ -6090,14 +6084,10 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { prefix, c->network_namespace_path); if (c->syscall_errno > 0) { -#if HAVE_SECCOMP - const char *errno_name; -#endif - fprintf(f, "%sSystemCallErrorNumber: ", prefix); #if HAVE_SECCOMP - errno_name = seccomp_errno_or_action_to_string(c->syscall_errno); + const char *errno_name = seccomp_errno_or_action_to_string(c->syscall_errno); if (errno_name) fputs(errno_name, f); else diff --git a/src/shared/bus-polkit.c b/src/shared/bus-polkit.c index 4d733a81737..6ad6c08b238 100644 --- a/src/shared/bus-polkit.c +++ b/src/shared/bus-polkit.c @@ -258,11 +258,6 @@ int bus_verify_polkit_async( Hashmap **registry, sd_bus_error *ret_error) { -#if ENABLE_POLKIT - _cleanup_(sd_bus_message_unrefp) sd_bus_message *pk = NULL; - AsyncPolkitQuery *q; - int c; -#endif const char *sender; int r; @@ -275,7 +270,7 @@ int bus_verify_polkit_async( return r; #if ENABLE_POLKIT - q = hashmap_get(*registry, call); + AsyncPolkitQuery *q = hashmap_get(*registry, call); if (q) { int authorized, challenge; @@ -331,7 +326,9 @@ int bus_verify_polkit_async( return -EBADMSG; #if ENABLE_POLKIT - c = sd_bus_message_get_allow_interactive_authorization(call); + _cleanup_(sd_bus_message_unrefp) sd_bus_message *pk = NULL; + + int c = sd_bus_message_get_allow_interactive_authorization(call); if (c < 0) return c; if (c > 0) diff --git a/src/shared/journal-util.c b/src/shared/journal-util.c index 9e1870e176c..bc3d38bb947 100644 --- a/src/shared/journal-util.c +++ b/src/shared/journal-util.c @@ -10,10 +10,6 @@ #include "user-util.h" static int access_check_var_log_journal(sd_journal *j, bool want_other_users) { -#if HAVE_ACL - _cleanup_strv_free_ char **g = NULL; - const char* dir; -#endif int r; assert(j); @@ -31,6 +27,9 @@ static int access_check_var_log_journal(sd_journal *j, bool want_other_users) { return 0; #if HAVE_ACL + _cleanup_strv_free_ char **g = NULL; + const char* dir; + if (laccess("/run/log/journal", F_OK) >= 0) dir = "/run/log/journal"; else