]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
More bug fixes and dead code elimination
authorDale Weiler <killfieldengine@gmail.com>
Sat, 22 Jun 2013 01:23:59 +0000 (01:23 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Sat, 22 Jun 2013 01:23:59 +0000 (01:23 +0000)
ast.c
parser.c
test.c

diff --git a/ast.c b/ast.c
index a23aa75667710d23f7268ee565a9aa9a30c52150..584bda0714a5f923524ff828c66eaa6919ac9c84 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -2893,10 +2893,13 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
     if (bprecond)
     {
         ir_block *ontrue, *onfalse;
-        if      (bbody)      ontrue = bbody;
+        ontrue = bbody; /* can never be null */
+
+        /* all of this is dead code 
         else if (bincrement) ontrue = bincrement;
-        else if (bpostcond)  ontrue = bpostcond;
-        else                 ontrue = bprecond;
+        else                 ontrue = bpostcond;
+        */
+
         onfalse = bout;
         if (self->pre_not) {
             tmpblock = ontrue;
index 49e965a097f0e5813023824e85062b38e3100da8..f9793471f94f93bc4314c3be5f9d3ea88dd221a8 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2755,7 +2755,12 @@ static bool parse_dowhile(parser_t *parser, ast_block *block, ast_expression **o
     if (vec_last(parser->breaks) != label || vec_last(parser->continues) != label) {
         parseerror(parser, "internal error: label stack corrupted");
         rv = false;
-        ast_delete(*out);
+        /*
+         * Test for NULL otherwise ast_delete dereferences null pointer
+         * and boom.
+         */
+        if (*out)
+            ast_delete(*out);
         *out = NULL;
     }
     else {
diff --git a/test.c b/test.c
index cdb90415f4ed8532ae067b0ccb2a632206b33f59..29aefc10106093b3cce7a4ccf90e457fb06965b4 100644 (file)
--- a/test.c
+++ b/test.c
@@ -896,7 +896,7 @@ static void task_destroy(void) {
             else
                 util_debug("TEST", "removed stderr log file: %s\n", task_tasks[i].stderrlogfile);
 
-            remove(task_tasks[i].tmpl->tempfilename);
+            (void)!remove(task_tasks[i].tmpl->tempfilename);
         }
 
         /* free util_strdup data for log files */