From: Dmitry V. Levin Date: Sat, 17 Jun 2017 19:20:11 +0000 (+0000) Subject: Fix a few initialization style issues X-Git-Tag: v4.18~73 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3baf7ef953bdce93c455e4357ec5733400546246;p=strace Fix a few initialization style issues Do not initialise statics and globals to 0, NULL, or false. Reported by kernel's checkpatch.pl script. --- diff --git a/pathtrace.c b/pathtrace.c index 4dfccbf5..9cb0ba77 100644 --- a/pathtrace.c +++ b/pathtrace.c @@ -33,8 +33,8 @@ #include "syscall.h" -const char **paths_selected = NULL; -static unsigned num_selected = 0; +const char **paths_selected; +static unsigned int num_selected; /* * Return true if specified path matches one that we're tracing. diff --git a/strace.c b/strace.c index ba2d6953..916d66b3 100644 --- a/strace.c +++ b/strace.c @@ -57,7 +57,7 @@ extern char *optarg; #ifdef USE_LIBUNWIND /* if this is true do the stack trace for every system call */ -bool stack_trace_enabled = false; +bool stack_trace_enabled; #endif #define my_tkill(tid, sig) syscall(__NR_tkill, (tid), (sig)) @@ -74,18 +74,18 @@ bool stack_trace_enabled = false; const unsigned int syscall_trap_sig = SIGTRAP | 0x80; cflag_t cflag = CFLAG_NONE; -unsigned int followfork = 0; +unsigned int followfork; unsigned int ptrace_setoptions = PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXEC | PTRACE_O_TRACEEXIT; -unsigned int xflag = 0; -bool debug_flag = 0; -bool Tflag = 0; -bool iflag = 0; -bool count_wallclock = 0; -unsigned int qflag = 0; -static unsigned int tflag = 0; -static bool rflag = 0; -static bool print_pid_pfx = 0; +unsigned int xflag; +bool debug_flag; +bool Tflag; +bool iflag; +bool count_wallclock; +unsigned int qflag; +static unsigned int tflag; +static bool rflag; +static bool print_pid_pfx; /* -I n */ enum { @@ -112,7 +112,7 @@ static int opt_intr; * wait() etc. Without -D, strace process gets lodged in between, * disrupting parent<->child link. */ -static bool daemonized_tracer = 0; +static bool daemonized_tracer; #if USE_SEIZE static int post_attach_sigstop = TCB_IGNORE_ONE_SIGSTOP; @@ -123,18 +123,18 @@ static int post_attach_sigstop = TCB_IGNORE_ONE_SIGSTOP; #endif /* Sometimes we want to print only succeeding syscalls. */ -bool not_failing_only = 0; +bool not_failing_only; /* Show path associated with fd arguments */ -unsigned int show_fd_path = 0; +unsigned int show_fd_path; -static bool detach_on_execve = 0; +static bool detach_on_execve; static int exit_code; -static int strace_child = 0; -static int strace_tracer_pid = 0; +static int strace_child; +static int strace_tracer_pid; -static char *username = NULL; +static char *username; static uid_t run_uid; static gid_t run_gid; @@ -142,11 +142,11 @@ unsigned int max_strlen = DEFAULT_STRLEN; static int acolumn = DEFAULT_ACOLUMN; static char *acolumn_spaces; -static char *outfname = NULL; +static char *outfname; /* If -ff, points to stderr. Else, it's our common output log */ static FILE *shared_log; -struct tcb *printing_tcp = NULL; +struct tcb *printing_tcp; static struct tcb *current_tcp; static struct tcb **tcbtab; @@ -520,7 +520,7 @@ strace_fopen(const char *path) return fp; } -static int popen_pid = 0; +static int popen_pid; #ifndef _PATH_BSHELL # define _PATH_BSHELL "/bin/sh" diff --git a/tests/btrfs.c b/tests/btrfs.c index 7e5ccfff..ff5feaad 100644 --- a/tests/btrfs.c +++ b/tests/btrfs.c @@ -61,8 +61,8 @@ typedef __u64 u64; static const char *btrfs_test_root; static int btrfs_test_dir_fd; -static bool verbose = false; -static bool write_ok = false; +static bool verbose; +static bool write_ok; const unsigned char uuid_reference[BTRFS_UUID_SIZE] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, diff --git a/tests/keyctl.c b/tests/keyctl.c index 2e26076b..492c62a3 100644 --- a/tests/keyctl.c +++ b/tests/keyctl.c @@ -74,7 +74,7 @@ static const size_t limit = 10; * significantly breaking interface. */ bool nul_terminated_buf = true; -bool buf_in_arg = false; +bool buf_in_arg; /* * When this is called with positive size, the buffer provided is an "out" diff --git a/util.c b/util.c index dc6c765d..5aea68b2 100644 --- a/util.c +++ b/util.c @@ -745,8 +745,9 @@ void printstr_ex(struct tcb *const tcp, const kernel_ulong_t addr, const kernel_ulong_t len, const unsigned int user_style) { - static char *str = NULL; + static char *str; static char *outstr; + unsigned int size; unsigned int style = user_style; int rc; @@ -924,7 +925,8 @@ dumpstr(struct tcb *const tcp, const kernel_ulong_t addr, const int len) } } -static bool process_vm_readv_not_supported = 0; +static bool process_vm_readv_not_supported; + #ifndef HAVE_PROCESS_VM_READV /* * Need to do this since process_vm_readv() is not yet available in libc. diff --git a/xmalloc.c b/xmalloc.c index 11589270..a0176200 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -29,7 +29,7 @@ void die_out_of_memory(void) { - static bool recursed = false; + static bool recursed; if (recursed) exit(1);