[PATCH v1] Initialize local variables in functions

zubin.mithra at gmail.com zubin.mithra at gmail.com
Mon Aug 4 03:05:02 UTC 2014


From: Zubin Mithra <zubin.mithra at gmail.com>

* desc.c (decode_select): Initialize fds to NULL.
* strace.c (expand_tcbtab): Change type to unsigned.
(startup_child): Initialize pathname array.

Signed-off-by: Zubin Mithra <zubin.mithra at gmail.com>
---
 desc.c   | 2 +-
 strace.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/desc.c b/desc.c
index 5b8869b..de513a6 100644
--- a/desc.c
+++ b/desc.c
@@ -314,7 +314,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
 {
 	int i, j;
 	int nfds, fdsize;
-	fd_set *fds;
+	fd_set *fds = NULL;
 	const char *sep;
 	long arg;
 
diff --git a/strace.c b/strace.c
index 4154cde..c9056c5 100644
--- a/strace.c
+++ b/strace.c
@@ -675,7 +675,7 @@ expand_tcbtab(void)
 	   callers have pointers and it would be a pain.
 	   So tcbtab is a table of pointers.  Since we never
 	   free the TCBs, we allocate a single chunk of many.  */
-	int i = tcbtabsize;
+	unsigned int i = tcbtabsize;
 	struct tcb *newtcbs = calloc(tcbtabsize, sizeof(newtcbs[0]));
 	struct tcb **newtab = realloc(tcbtab, tcbtabsize * 2 * sizeof(tcbtab[0]));
 	if (!newtab || !newtcbs)
@@ -1160,7 +1160,7 @@ startup_child(char **argv)
 {
 	struct_stat statbuf;
 	const char *filename;
-	char pathname[MAXPATHLEN];
+	char pathname[MAXPATHLEN] = "";
 	int pid;
 	struct tcb *tcp;
 
-- 
1.8.4





More information about the Strace-devel mailing list