]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: Simplify variable declarations behind #ifdef
authorJan Janssen <medhefgo@web.de>
Sat, 23 Apr 2022 13:53:29 +0000 (15:53 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 23 Apr 2022 16:31:05 +0000 (01:31 +0900)
src/basic/random-util.c
src/core/dbus-execute.c
src/core/execute.c
src/shared/bus-polkit.c
src/shared/journal-util.c

index f2e68fcddde64138509fda313b6da19ccb9a3516..a9fe25432ce822448fd06a1e66941b906778d35e 100644 (file)
@@ -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
index 65eec8f6b7e8e0768d232871710274c2d8912cf6..a4c37307d21a9346e4d6c926a96cb9dc1bb27206 100644 (file)
@@ -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;
 
index 61bfedfcd3d5bcc70e305e67d1f10ccd258b14b1..b3e64ade1bd68fa6900c96da3a862c34b47a5f15 100644 (file)
@@ -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
index 4d733a81737a09448bda7bcb6932d1960f648835..6ad6c08b23801838e908a5fd14675077c19eee76 100644 (file)
@@ -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)
index 9e1870e176c763ef25b2562413016bc0cf017cca..bc3d38bb9474b675376b280a53283f3ab368ee99 100644 (file)
 #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