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.
This commit is contained in:
Daniel J. Hofmann 2014-03-07 18:20:42 +01:00
parent 79d14521db
commit 7dc0b6f40b
7 changed files with 7 additions and 7 deletions

View file

@ -19,7 +19,7 @@ static const int kAutoloadStalenessInterval = 15;
file_access_attempt_t access_file(const wcstring &path, int mode) file_access_attempt_t access_file(const wcstring &path, int mode)
{ {
//printf("Touch %ls\n", path.c_str()); //printf("Touch %ls\n", path.c_str());
file_access_attempt_t result = {0}; file_access_attempt_t result = {};
struct stat statbuf; struct stat statbuf;
if (wstat(path, &statbuf)) if (wstat(path, &statbuf))
{ {

View file

@ -214,7 +214,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
int line_mode = 0; int line_mode = 0;
int search_mode = 0; int search_mode = 0;
int paging_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(); current_buffer = (wchar_t *)builtin_complete_get_temporary_buffer();
if (current_buffer) if (current_buffer)

View file

@ -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* */ /* 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; const wchar_t *arg;
va_list va; va_list va;

View file

@ -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 \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 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 Call read while blocking the SIGCHLD signal. Should only be called

View file

@ -58,7 +58,7 @@ signal_list_t;
active, which is the one that new events is written to. The inactive active, which is the one that new events is written to. The inactive
one contains the events that are currently beeing performed. 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 The index of sig_list that is the list of signals currently written to

View file

@ -846,7 +846,7 @@ void expand_variable_error(parser_t &parser, const wcstring &token, size_t token
*(cpy+token_pos)=0; *(cpy+token_pos)=0;
wchar_t *name = &cpy[stop_pos+1]; wchar_t *name = &cpy[stop_pos+1];
wchar_t *end = wcschr(name, BRACKET_END); wchar_t *end = wcschr(name, BRACKET_END);
wchar_t *post; wchar_t *post = NULL;
int is_var=0; int is_var=0;
if (end) if (end)
{ {

View file

@ -1013,7 +1013,7 @@ void parse_util_expand_variable_error(const parse_node_t &node, const wcstring &
*(cpy+token_pos)=0; *(cpy+token_pos)=0;
wchar_t *name = &cpy[stop_pos+1]; wchar_t *name = &cpy[stop_pos+1];
wchar_t *end = wcschr(name, BRACKET_END); wchar_t *end = wcschr(name, BRACKET_END);
wchar_t *post; wchar_t *post = NULL;
int is_var=0; int is_var=0;
if (end) if (end)
{ {