Permalink
Browse files

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.
  • Loading branch information...
1 parent 79d1452 commit 7dc0b6f40be172915783e26cd77e86cbdb7ddaba @daniel-j-h daniel-j-h committed Mar 7, 2014
Showing with 7 additions and 7 deletions.
  1. +1 −1 autoload.cpp
  2. +1 −1 builtin_commandline.cpp
  3. +1 −1 common.cpp
  4. +1 −1 common.h
  5. +1 −1 event.cpp
  6. +1 −1 expand.cpp
  7. +1 −1 parse_util.cpp
View
@@ -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))
{
View
@@ -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)
View
@@ -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;
View
@@ -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
View
@@ -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
View
@@ -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)
{
View
@@ -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)
{

0 comments on commit 7dc0b6f

Please sign in to comment.