]> granicus.if.org Git - strace/commitdiff
Fix a few initialization style issues
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 17 Jun 2017 19:20:11 +0000 (19:20 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 17 Jun 2017 20:49:09 +0000 (20:49 +0000)
Do not initialise statics and globals to 0, NULL, or false.

Reported by kernel's checkpatch.pl script.

pathtrace.c
strace.c
tests/btrfs.c
tests/keyctl.c
util.c
xmalloc.c

index 4dfccbf5fd9405fcfbd2aee685d752aefbe421d6..9cb0ba77626617336197e8a8fa2dcdd4236c08e1 100644 (file)
@@ -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.
index ba2d695361ea89e44d504ec1939709caec641b29..916d66b365d2b6aeabaf33dab81d49e5994dc94e 100644 (file)
--- 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"
index 7e5ccfffffa8f9d4f9d8cf053ee3cd26ce154052..ff5feaad8d3eb83d5825bfdeb248c2cf9c1052d1 100644 (file)
@@ -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,
index 2e26076b152ac3a5d1346d07428c46023db5e6ca..492c62a3dcbd65d5592c62b93e910ee1bd0d6361 100644 (file)
@@ -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 dc6c765dafd9840acae374a0c5e6d9e32671c83a..5aea68b2e62e8f7abb44f7d9fc804c064e9fdcf4 100644 (file)
--- 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.
index 1158927061e6a1c978a662a48483b19ea0dc954e..a0176200935ead03ac2f00d69bd96f7234f84584 100644 (file)
--- 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);