tree-wide: Simplify variable declarations behind #ifdef

This commit is contained in:
Jan Janssen 2022-04-23 15:53:29 +02:00 committed by Yu Watanabe
parent 5662811e34
commit d5a99b7c9c
5 changed files with 16 additions and 41 deletions

View 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

View 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;

View 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

View 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)

View file

@ -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