aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Daniel J. Hofmann <daniel@trvx.org>2014-03-07 18:20:42 +0100
committerGravatar Daniel J. Hofmann <daniel@trvx.org>2014-03-07 18:28:16 +0100
commit7dc0b6f40be172915783e26cd77e86cbdb7ddaba (patch)
treeef46bac818615f9d911eb72c1bced92f00194ffe
parent79d14521db4c71250109785b8317aeceecd539c9 (diff)
Fixed various Undefined Behavior occurrences.
Conditionally uninitialized: - builtin_commandline.cpp:577 - expand.cpp:869 - parse_util.cpp:1036 Initialization of POD structs: - event.cpp:61 - autoload.cpp:22 References used with va_start: - common.cpp:608:18 Found with clang-3.4's awesome -Wconditional-uninitialized, -Wmissing-field-initializers and -Wvarargs.
-rw-r--r--autoload.cpp2
-rw-r--r--builtin_commandline.cpp2
-rw-r--r--common.cpp2
-rw-r--r--common.h2
-rw-r--r--event.cpp2
-rw-r--r--expand.cpp2
-rw-r--r--parse_util.cpp2
7 files changed, 7 insertions, 7 deletions
diff --git a/autoload.cpp b/autoload.cpp
index e2e532de..5a72a5cd 100644
--- a/autoload.cpp
+++ b/autoload.cpp
@@ -19,7 +19,7 @@ static const int kAutoloadStalenessInterval = 15;
file_access_attempt_t access_file(const wcstring &path, int mode)
{
//printf("Touch %ls\n", path.c_str());
- file_access_attempt_t result = {0};
+ file_access_attempt_t result = {};
struct stat statbuf;
if (wstat(path, &statbuf))
{
diff --git a/builtin_commandline.cpp b/builtin_commandline.cpp
index 564eee7b..2b1ba6fb 100644
--- a/builtin_commandline.cpp
+++ b/builtin_commandline.cpp
@@ -214,7 +214,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
int line_mode = 0;
int search_mode = 0;
int paging_mode = 0;
- const wchar_t *begin, *end;
+ const wchar_t *begin = NULL, *end = NULL;
current_buffer = (wchar_t *)builtin_complete_get_temporary_buffer();
if (current_buffer)
diff --git a/common.cpp b/common.cpp
index 08e8d7a1..02591212 100644
--- a/common.cpp
+++ b/common.cpp
@@ -599,7 +599,7 @@ bool contains_internal(const wchar_t *a, ...)
}
/* wcstring variant of contains_internal. The first parameter is a wcstring, the rest are const wchar_t* */
-__sentinel bool contains_internal(const wcstring &needle, ...)
+__sentinel bool contains_internal(const wcstring needle, ...)
{
const wchar_t *arg;
va_list va;
diff --git a/common.h b/common.h
index 33fbb0e5..e5573fa7 100644
--- a/common.h
+++ b/common.h
@@ -689,7 +689,7 @@ wcstring wsetlocale(int category, const wchar_t *locale);
\return zero if needle is not found, of if needle is null, non-zero otherwise
*/
__sentinel bool contains_internal(const wchar_t *needle, ...);
-__sentinel bool contains_internal(const wcstring &needle, ...);
+__sentinel bool contains_internal(const wcstring needle, ...);
/**
Call read while blocking the SIGCHLD signal. Should only be called
diff --git a/event.cpp b/event.cpp
index 65d337f0..6851a9e3 100644
--- a/event.cpp
+++ b/event.cpp
@@ -58,7 +58,7 @@ signal_list_t;
active, which is the one that new events is written to. The inactive
one contains the events that are currently beeing performed.
*/
-static signal_list_t sig_list[]= {{0,0},{0,0}};
+static signal_list_t sig_list[]= {{},{}};
/**
The index of sig_list that is the list of signals currently written to
diff --git a/expand.cpp b/expand.cpp
index 5b92cac7..1bd7e024 100644
--- a/expand.cpp
+++ b/expand.cpp
@@ -846,7 +846,7 @@ void expand_variable_error(parser_t &parser, const wcstring &token, size_t token
*(cpy+token_pos)=0;
wchar_t *name = &cpy[stop_pos+1];
wchar_t *end = wcschr(name, BRACKET_END);
- wchar_t *post;
+ wchar_t *post = NULL;
int is_var=0;
if (end)
{
diff --git a/parse_util.cpp b/parse_util.cpp
index d6e1c9ea..2fcb24aa 100644
--- a/parse_util.cpp
+++ b/parse_util.cpp
@@ -1013,7 +1013,7 @@ void parse_util_expand_variable_error(const parse_node_t &node, const wcstring &
*(cpy+token_pos)=0;
wchar_t *name = &cpy[stop_pos+1];
wchar_t *end = wcschr(name, BRACKET_END);
- wchar_t *post;
+ wchar_t *post = NULL;
int is_var=0;
if (end)
{