]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix usage of possibly unassigned out parameters
authorLuca Bruno <lucabru@src.gnome.org>
Wed, 13 Jul 2011 09:19:56 +0000 (11:19 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Fri, 15 Jul 2011 16:56:38 +0000 (18:56 +0200)
codegen/valaccodebasemodule.vala
codegen/valagdbusmodule.vala
codegen/valagvariantmodule.vala
vala/valageniescanner.vala
vala/valagirparser.vala
vala/valamarkupreader.vala
vala/valamethod.vala
vala/valascanner.vala
vapigen/valagidlparser.vala

index 5460b5e475b5d9de9d41d8d2fa06a9e3ab1f394e..d9b3800a512f86aaeafa930eda3389e6e58aeab3 100644 (file)
@@ -4501,11 +4501,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        }
 
        public virtual CCodeExpression? deserialize_expression (DataType type, CCodeExpression variant_expr, CCodeExpression? expr, CCodeExpression? error_expr = null, out bool may_fail = null) {
-               return null;
+               assert_not_reached ();
        }
 
        public virtual CCodeExpression? serialize_expression (DataType type, CCodeExpression expr) {
-               return null;
+               assert_not_reached ();
        }
 
        public override void visit_cast_expression (CastExpression expr) {
index 1708d03b12077d89aa54e456171d69d6714ef7d9..d82b573d9fbccd68cd5ae77e5fe084f5aa783a70 100644 (file)
@@ -215,6 +215,7 @@ public class Vala.GDBusModule : GVariantModule {
                        ccode.add_expression (get_fd);
 
                        ccode.add_assignment (target_expr, stream);
+                       may_fail = false;
                } else {
                        read_expression (type, iter_expr, target_expr, sym, error_expr, out may_fail);
                }
index 91b614a87b18dcd8d4371776ffc1ca93aad0bd91..f7d4d0cf87044334695b4a382688863edb20d91c 100644 (file)
@@ -79,6 +79,7 @@ public class Vala.GVariantModule : GAsyncModule {
                                return true;
                        }
                }
+               basic_type = BasicTypeInfo ();
                return false;
        }
 
@@ -458,6 +459,7 @@ public class Vala.GVariantModule : GAsyncModule {
        public override CCodeExpression? deserialize_expression (DataType type, CCodeExpression variant_expr, CCodeExpression? expr, CCodeExpression? error_expr = null, out bool may_fail = null) {
                BasicTypeInfo basic_type;
                CCodeExpression result = null;
+               may_fail = false;
                if (is_string_marshalled_enum (type.data_type)) {
                        get_basic_type_info ("s", out basic_type);
                        result = deserialize_basic (basic_type, variant_expr, true);
@@ -502,6 +504,7 @@ public class Vala.GVariantModule : GAsyncModule {
                if (sym != null && get_dbus_signature (sym) != null) {
                        // raw GVariant
                        ccode.add_assignment (target_expr, iter_call);
+                       may_fail = false;
                        return;
                }
 
index c853827632f8b6cda40ab72c132e23b426eb4c49..54a557a6e148da14f4ad29f622e6a858a856f06d 100644 (file)
@@ -113,9 +113,7 @@ public class Vala.Genie.Scanner {
        public TokenType read_regex_token (out SourceLocation token_begin, out SourceLocation token_end) {
                TokenType type;
                char* begin = current;
-               token_begin.pos = begin;
-               token_begin.line = line;
-               token_begin.column = column;
+               token_begin = SourceLocation (begin, line, column);
 
                int token_length_in_chars = -1;
 
@@ -267,9 +265,7 @@ public class Vala.Genie.Scanner {
                        column += token_length_in_chars;
                }
 
-               token_end.pos = current;
-               token_end.line = line;
-               token_end.column = column - 1;
+               token_end = SourceLocation (current, line, column - 1);
 
                return type;
        }
@@ -661,9 +657,7 @@ public class Vala.Genie.Scanner {
        public TokenType read_template_token (out SourceLocation token_begin, out SourceLocation token_end) {
                TokenType type;
                char* begin = current;
-               token_begin.pos = begin;
-               token_begin.line = line;
-               token_begin.column = column;
+               token_begin = SourceLocation (begin, line, column);
 
                int token_length_in_chars = -1;
 
@@ -767,9 +761,7 @@ public class Vala.Genie.Scanner {
                        column += token_length_in_chars;
                }
 
-               token_end.pos = current;
-               token_end.line = line;
-               token_end.column = column - 1;
+               token_end = SourceLocation (current, line, column - 1);
 
                return type;
        }
@@ -783,13 +775,8 @@ public class Vala.Genie.Scanner {
                } else if (in_template_part ()) {
                        state_stack.length--;
 
-                       token_begin.pos = current;
-                       token_begin.line = line;
-                       token_begin.column = column;
-
-                       token_end.pos = current;
-                       token_end.line = line;
-                       token_end.column = column - 1;
+                       token_begin = SourceLocation (current, line, column);
+                       token_end = SourceLocation (current, line, column - 1);
 
                        return TokenType.COMMA;
                } else if (in_regex_literal ()) {
@@ -804,14 +791,8 @@ public class Vala.Genie.Scanner {
                        pending_dedents--;
                        indent_level--;
 
-
-                       token_begin.pos = current;
-                       token_begin.line = line;
-                       token_begin.column = column;
-
-                       token_end.pos = current;
-                       token_end.line = line;
-                       token_end.column = column;
+                       token_begin = SourceLocation (current, line, column);
+                       token_end = SourceLocation (current, line, column);
 
                        last_token = TokenType.DEDENT;
 
@@ -841,13 +822,8 @@ public class Vala.Genie.Scanner {
 
                /* handle non-consecutive new line once parsing is underway - EOL */
                if (newline () && parse_started && last_token != TokenType.EOL && last_token != TokenType.SEMICOLON) {
-                       token_begin.pos = current;
-                       token_begin.line = line;
-                       token_begin.column = column;
-
-                       token_end.pos = current;
-                       token_end.line = line;
-                       token_end.column = column;
+                       token_begin = SourceLocation (current, line, column);
+                       token_end = SourceLocation (current, line, column);
 
                        last_token = TokenType.EOL;
 
@@ -856,9 +832,7 @@ public class Vala.Genie.Scanner {
 
 
                while (skip_newlines ()) {
-                       token_begin.pos = current;
-                       token_begin.line = line;
-                       token_begin.column = column;
+                       token_begin = SourceLocation (current, line, column);
 
                        current_indent_level = count_tabs ();
 
@@ -870,9 +844,7 @@ public class Vala.Genie.Scanner {
                        if (current_indent_level > indent_level) {
                                indent_level = current_indent_level;
 
-                               token_end.pos = current;
-                               token_end.line = line;
-                               token_end.column = column;
+                               token_end = SourceLocation (current, line, column);
 
                                last_token = TokenType.INDENT;
 
@@ -881,10 +853,7 @@ public class Vala.Genie.Scanner {
                                indent_level--;
 
                                pending_dedents = (indent_level - current_indent_level);
-
-                               token_end.pos = current;
-                               token_end.line = line;
-                               token_end.column = column;
+                               token_end = SourceLocation (current, line, column);
 
                                last_token = TokenType.DEDENT;
 
@@ -894,9 +863,7 @@ public class Vala.Genie.Scanner {
 
                TokenType type;
                char* begin = current;
-               token_begin.pos = begin;
-               token_begin.line = line;
-               token_begin.column = column;
+               token_begin = SourceLocation (begin, line, column);
 
                int token_length_in_chars = -1;
 
@@ -1354,9 +1321,7 @@ public class Vala.Genie.Scanner {
                        column += token_length_in_chars;
                }
 
-               token_end.pos = current;
-               token_end.line = line;
-               token_end.column = column - 1;
+               token_end = SourceLocation (current, line, column - 1);
                last_token = type;
 
                return type;
index 4980be82fdfa88e8ea3598cbe574c147cfddfccc..5276c8f0841d4faf08fbee851bad32d74945c9c6 100644 (file)
@@ -1984,6 +1984,7 @@ public class Vala.GirParser : CodeVisitor {
        DataType parse_type (out string? ctype = null, out int array_length_idx = null, bool transfer_elements = true, out bool no_array_length = null, out bool array_null_terminated = null) {
                bool is_array = false;
                string type_name = reader.get_attribute ("name");
+               ctype = null;
 
                array_length_idx = -1;
                no_array_length = true;
index 69170e556ed2b76518b5ea690d41290a94b626cd..7f50c2db318d91f05ebc5f4e72aa00c516ab59d1 100644 (file)
@@ -103,6 +103,8 @@ public class Vala.MarkupReader : Object {
 
                if (empty_element) {
                        empty_element = false;
+                       token_begin = SourceLocation (begin, line, column);
+                       token_end = SourceLocation (begin, line, column);
                        return MarkupTokenType.END_ELEMENT;
                }
 
@@ -110,9 +112,7 @@ public class Vala.MarkupReader : Object {
 
                MarkupTokenType type = MarkupTokenType.NONE;
                char* begin = current;
-               token_begin.pos = begin;
-               token_begin.line = line;
-               token_begin.column = column;
+               token_begin = SourceLocation (begin, line, column);
 
                if (current >= end) {
                        type = MarkupTokenType.EOF;
@@ -202,9 +202,7 @@ public class Vala.MarkupReader : Object {
                        type = MarkupTokenType.TEXT;
                }
 
-               token_end.pos = current;
-               token_end.line = line;
-               token_end.column = column - 1;
+               token_end = SourceLocation (current, line, column - 1);
 
                return type;
        }
index 966407240eb44beecd624d57f6806e5b4e728eb3..39b222302971d8c5d39bd854eeb9b6327075c921 100644 (file)
@@ -591,6 +591,7 @@ public class Vala.Method : Subroutine {
                        return false;
                }
 
+               invalid_match = null;
                return true;
        }
 
index 352ab686c6bafad5cc3d50d4182fe731a1861048..624c77d106fe48c0e100c9cff78834967de744f6 100644 (file)
@@ -97,9 +97,7 @@ public class Vala.Scanner {
        public TokenType read_regex_token (out SourceLocation token_begin, out SourceLocation token_end) {
                TokenType type;
                char* begin = current;
-               token_begin.pos = begin;
-               token_begin.line = line;
-               token_begin.column = column;
+               token_begin = SourceLocation (begin, line, column);
 
                int token_length_in_chars = -1;
 
@@ -251,9 +249,7 @@ public class Vala.Scanner {
                        column += token_length_in_chars;
                }
 
-               token_end.pos = current;
-               token_end.line = line;
-               token_end.column = column - 1;
+               token_end = SourceLocation (current, line, column - 1);
 
                return type;
        }
@@ -631,9 +627,7 @@ public class Vala.Scanner {
        public TokenType read_template_token (out SourceLocation token_begin, out SourceLocation token_end) {
                TokenType type;
                char* begin = current;
-               token_begin.pos = begin;
-               token_begin.line = line;
-               token_begin.column = column;
+               token_begin = SourceLocation (begin, line, column);
 
                int token_length_in_chars = -1;
 
@@ -740,9 +734,7 @@ public class Vala.Scanner {
                        column += token_length_in_chars;
                }
 
-               token_end.pos = current;
-               token_end.line = line;
-               token_end.column = column - 1;
+               token_end = SourceLocation (current, line, column - 1);
 
                return type;
        }
@@ -753,13 +745,8 @@ public class Vala.Scanner {
                } else if (in_template_part ()) {
                        state_stack.length--;
 
-                       token_begin.pos = current;
-                       token_begin.line = line;
-                       token_begin.column = column;
-
-                       token_end.pos = current;
-                       token_end.line = line;
-                       token_end.column = column - 1;
+                       token_begin = SourceLocation (current, line, column);
+                       token_end = SourceLocation (current, line, column - 1);
 
                        return TokenType.COMMA;
                } else if (in_regex_literal ()) {
@@ -770,9 +757,7 @@ public class Vala.Scanner {
 
                TokenType type;
                char* begin = current;
-               token_begin.pos = begin;
-               token_begin.line = line;
-               token_begin.column = column;
+               token_begin = SourceLocation (begin, line, column);
 
                int token_length_in_chars = -1;
 
@@ -1187,9 +1172,7 @@ public class Vala.Scanner {
                        column += token_length_in_chars;
                }
 
-               token_end.pos = current;
-               token_end.line = line;
-               token_end.column = column - 1;
+               token_end = SourceLocation (current, line, column - 1);
                previous = type;
 
                return type;
index f89441f7f01e9336ed81cb2570fd1d8474ce86e2..92fdb04677b886a44f44e21cf673d81872c84b8f 100644 (file)
@@ -1645,7 +1645,7 @@ public class Vala.GIdlParser : CodeVisitor {
        }
        
        private DataType? parse_type (IdlNodeType type_node, out ParameterDirection direction = null) {
-               ParameterDirection dir = ParameterDirection.IN;
+               direction = ParameterDirection.IN;
 
                var type = new UnresolvedType ();
                if (type_node.tag == TypeTag.VOID) {
@@ -1722,7 +1722,7 @@ public class Vala.GIdlParser : CodeVisitor {
                            (n == "gchar" || n == "char")) {
                                type.unresolved_symbol = new UnresolvedSymbol (null, "string");
                                if (type_node.unparsed.has_suffix ("**")) {
-                                       dir = ParameterDirection.OUT;
+                                       direction = ParameterDirection.OUT;
                                }
                        } else if (n == "gunichar") {
                                type.unresolved_symbol = new UnresolvedSymbol (null, "unichar");
@@ -1775,18 +1775,15 @@ public class Vala.GIdlParser : CodeVisitor {
                                }
                                if (is_simple_type (n)) {
                                        if (type_node.is_pointer) {
-                                               dir = ParameterDirection.OUT;
+                                               direction = ParameterDirection.OUT;
                                        }
                                } else if (type_node.unparsed.has_suffix ("**")) {
-                                       dir = ParameterDirection.OUT;
+                                       direction = ParameterDirection.OUT;
                                }
                        }
                } else {
                        stdout.printf ("%d\n", type_node.tag);
                }
-               if (&direction != null) {
-                       direction = dir;
-               }
                return type;
        }