Skip to content

Commit

Permalink
Fix more warnings in ucpp
Browse files Browse the repository at this point in the history
These warnings about potentially uninitialized
variables showed up when compiling with old gcc:
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
that comes with Xcode Version 3.2.6 (1761).
  • Loading branch information
alexfru committed Oct 15, 2017
1 parent 3d810f9 commit 711c57e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ bindir = $(prefix)/bin
libdir = $(prefix)/smlrc/lib
incdir = $(prefix)/smlrc/include

CFLAGS = -pipe -Wall -O0 -g
CFLAGS = -pipe -Wall -O2
CFLAGS += -DPATH_PREFIX='"$(prefix)"'

CC = gcc
Expand Down
6 changes: 3 additions & 3 deletions v0100/ucpp/assert.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ int cmp_token_list(struct token_fifo *f1, struct token_fifo *f2)
int handle_assert(struct lexer_state *ls)
{
int ina = 0, ltww;
struct token t;
struct token t = { 0 };
struct token_fifo *atl = 0;
struct assert *a;
struct assert *a = NULL;
char *aname = NULL;
int ret = -1;
long l = ls->line;
Expand Down Expand Up @@ -242,7 +242,7 @@ int handle_assert(struct lexer_state *ls)
int handle_unassert(struct lexer_state *ls)
{
int ltww;
struct token t;
struct token t = { 0 };
struct token_fifo atl;
struct assert *a;
int ret = -1;
Expand Down
16 changes: 8 additions & 8 deletions v0100/ucpp/cpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ static int handle_if(struct lexer_state *ls)
/* first, get the whole line */
tf.art = tf.nt = 0;
while (!next_token(ls) && ls->ctok->type != NEWLINE) {
struct token t;
struct token t = { 0 };

if (ltww && ttMWS(ls->ctok->type)) continue;
ltww = ttMWS(ls->ctok->type);
Expand All @@ -968,7 +968,7 @@ static int handle_if(struct lexer_state *ls)
/* handle the "defined" operator */
tf1.art = tf1.nt = 0;
while (tf.art < tf.nt) {
struct token *ct, rt;
struct token *ct, rt = { 0 };
struct macro *m;
size_t nidx, eidx;

Expand Down Expand Up @@ -1044,7 +1044,7 @@ static int handle_if(struct lexer_state *ls)
char *aname;
struct assert *a;
int av = 0;
struct token rt;
struct token rt = { 0 };

atl.art = atl.nt = 0;
while (i < tf1.nt && ttMWS(tf1.t[i].type)) i ++;
Expand Down Expand Up @@ -1116,7 +1116,7 @@ static int handle_if(struct lexer_state *ls)
/*
* a rogue identifier; we replace it with "0".
*/
struct token rt;
struct token rt = { 0 };

rt.type = NUMBER;
rt.name = "0";
Expand Down Expand Up @@ -1250,7 +1250,7 @@ static int handle_include(struct lexer_state *ls, unsigned long flags, int nex)
tf.art = tf.nt = 0;
while (!next_token(&alt_ls)) {
if (!ttMWS(alt_ls.ctok->type)) {
struct token t;
struct token t = { 0 };

t.type = alt_ls.ctok->type;
t.line = l;
Expand All @@ -1274,7 +1274,7 @@ static int handle_include(struct lexer_state *ls, unsigned long flags, int nex)
tf.art = tf.nt = 0;
while (!next_token(ls) && ls->ctok->type != NEWLINE) {
if (!ttMWS(ls->ctok->type)) {
struct token t;
struct token t = { 0 };

t.type = ls->ctok->type;
t.line = l;
Expand Down Expand Up @@ -1415,7 +1415,7 @@ static int handle_line(struct lexer_state *ls, unsigned long flags)
tf.art = tf.nt = 0;
while (!next_token(ls) && ls->ctok->type != NEWLINE) {
if (!ttMWS(ls->ctok->type)) {
struct token t;
struct token t = { 0 };

t.type = ls->ctok->type;
t.line = l;
Expand Down Expand Up @@ -1605,7 +1605,7 @@ static void handle_pragma(struct lexer_state *ls)
if (!ttMWS(ls->ctok->type)) break;
if (ls->ctok->type != NEWLINE) {
do {
struct token t;
struct token t = { 0 };

t.type = ls->ctok->type;
if (ttMWS(t.type)) continue;
Expand Down
2 changes: 1 addition & 1 deletion v0100/ucpp/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ static int OP_BIN(int x)

static ppval eval_opbin(int op, ppval v1, ppval v2)
{
ppval r;
ppval r = { 0 };
int iv2 = 0;

switch (op) {
Expand Down
4 changes: 2 additions & 2 deletions v0100/ucpp/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ int handle_define(struct lexer_state *ls)

/* now, we have the arguments. Let's get the macro contents. */
while (!next_token(ls) && ls->ctok->type != NEWLINE) {
struct token t;
struct token t = { 0 };

t.type = ls->ctok->type;
if (ltwws && ttMWS(t.type)) continue;
Expand Down Expand Up @@ -761,7 +761,7 @@ static int collect_arguments(struct lexer_state *ls, struct token_fifo *tfi,
}
}
while (!unravel(ls)) {
struct token t;
struct token t = { 0 };

if (ct->type == LPAR) npar ++;
else if (ct->type == RPAR && (-- npar) == 0) {
Expand Down

0 comments on commit 711c57e

Please sign in to comment.