[tracker] libtracker-data: Use optional() to parse a few tokens



commit 1561d7c8e3e123119575079e332774d07b0dd9fd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Aug 5 20:23:46 2017 +0200

    libtracker-data: Use optional() to parse a few tokens
    
    Fixes a bunch of "unchecked return value" warnings on coverity,
    it's also clearer to read.
    
    Spotted by Coverity (CID#: 1188417, 1188418, 1188428, 1452443,
    1452445, 1452449)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785863

 src/libtracker-data/tracker-sparql-pattern.vala |    7 +++----
 src/libtracker-data/tracker-sparql-query.vala   |    6 +++---
 2 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index 96efc13..490498b 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -286,7 +286,7 @@ class Tracker.Sparql.Pattern : Object {
                        expect (SparqlTokenType.IRI_REF);
                }
 
-               accept (SparqlTokenType.WHERE);
+               optional (SparqlTokenType.WHERE);
 
                var pattern = translate_group_graph_pattern (pattern_sql);
                foreach (var key in pattern.var_set.get_keys ()) {
@@ -904,8 +904,7 @@ class Tracker.Sparql.Pattern : Object {
                        var right_variable = context.get_variable (get_last_string ().substring (1));
                        var right_variable_state = context.var_set.lookup (right_variable);
 
-                       // optional .
-                       accept (SparqlTokenType.DOT);
+                       optional (SparqlTokenType.DOT);
 
                        // check it is only one triple pattern
                        if (!accept (SparqlTokenType.CLOSE_BRACE)) {
@@ -1185,7 +1184,7 @@ class Tracker.Sparql.Pattern : Object {
                                break;
                        }
 
-                       accept (SparqlTokenType.DOT);
+                       optional (SparqlTokenType.DOT);
 
                        // optional TriplesBlock
                        parse_triples (sql, group_graph_pattern_start, ref in_triples_block, ref first_where, 
ref in_group_graph_pattern, found_simple_optional);
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index e611b0f..b25f416 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -503,7 +503,7 @@ public class Tracker.Sparql.Query : Object {
 
                        // semicolon is used to separate multiple operations in the current SPARQL Update 
draft
                        // keep it optional for now to reatin backward compatibility
-                       accept (SparqlTokenType.SEMICOLON);
+                       optional (SparqlTokenType.SEMICOLON);
                }
 
                if (blank) {
@@ -579,7 +579,7 @@ public class Tracker.Sparql.Query : Object {
 
                expect (SparqlTokenType.ASK);
 
-               accept (SparqlTokenType.WHERE);
+               optional (SparqlTokenType.WHERE);
 
                context = pattern.translate_group_graph_pattern (pattern_sql);
 
@@ -904,7 +904,7 @@ public class Tracker.Sparql.Query : Object {
 
                                current_graph = old_graph;
 
-                               accept (SparqlTokenType.DOT);
+                               optional (SparqlTokenType.DOT);
                        } else {
                                current_subject = parse_construct_var_or_term (var_value_map, type, out 
is_null);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]