Location | Tool | Test ID | Function | Issue |
---|---|---|---|---|
tracker-utils.c:267:7 | gcc | unused-but-set-variable | tracker_sparql_get_uuid_urn | variable '_base_uuid_size_' set but not used |
tracker-utils.c:278:2 | clang-analyzer | Value stored to '_base_uuid_size_' is never read |
1 /* tracker-utils.c generated by valac 0.18.1, the Vala compiler
2 * generated from tracker-utils.vala, do not modify */
3
4 /*
5 * Copyright (C) 2010, Nokia <ivan.frade@nokia.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22
23 #include <glib.h>
24 #include <glib-object.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <stdarg.h>
28
29 #define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
30 #define _g_free0(var) (var = (g_free (var), NULL))
31
32
33
34 gchar* tracker_sparql_escape_uri_vprintf (const gchar* format, va_list args);
35 gchar* tracker_sparql_escape_uri_printf (const gchar* format, ...);
36 gchar* tracker_sparql_escape_string (const gchar* literal);
37 void uuid_generate (guchar* uuid);
38 void uuid_unparse_lower (guchar* uuid, gchar* out);
39 gchar* tracker_sparql_get_uuid_urn (void);
40
41
42 /**
43 * SECTION: tracker-misc
44 * @short_description: General purpose utilities provided by the library
45 * @title: Utilities
46 * @stability: Stable
47 * @include: tracker-sparql.h
48 *
49 * <para>
50 * The libtracker-sparql utilities help in the creation of proper SPARQL queries.
51 * </para>
52 */
53 /**
54 * tracker_sparql_escape_string:
55 * @literal: a string to escape
56 *
57 * Escapes a string so that it can be used in a SPARQL query.
58 *
59 * Returns: a newly-allocated string with the escaped version of @literal.
60 * The returned string should be freed with g_free() when no longer needed.
61 *
62 * Since: 0.10
63 */
64 gchar* tracker_sparql_escape_string (const gchar* literal) {
65 gchar* result = NULL;
66 GString* _tmp0_;
67 GString* str;
68 const gchar* _tmp1_;
69 gchar* p;
70 GString* _tmp19_;
71 const gchar* _tmp20_;
72 gchar* _tmp21_;
73 #line 48 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
74 g_return_val_if_fail (literal != NULL, NULL);
75 #line 49 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
76 _tmp0_ = g_string_new ("");
77 #line 49 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
78 str = _tmp0_;
79 #line 50 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
80 _tmp1_ = literal;
81 #line 50 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
82 p = _tmp1_;
83 #line 52 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
84 while (TRUE) {
85 #line 86 "tracker-utils.c"
86 gchar* _tmp2_;
87 gchar* _tmp3_;
88 gsize _tmp4_ = 0UL;
89 gsize len;
90 GString* _tmp5_;
91 gchar* _tmp6_;
92 gsize _tmp7_;
93 gchar* _tmp8_;
94 gsize _tmp9_;
95 gchar* _tmp10_;
96 gchar* _tmp18_;
97 #line 52 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
98 _tmp2_ = p;
99 #line 52 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
100 if (!((*_tmp2_) != '\0')) {
101 #line 52 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
102 break;
103 #line 104 "tracker-utils.c"
104 }
105 #line 53 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
106 _tmp3_ = p;
107 #line 53 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
108 _tmp4_ = strcspn ((const gchar*) _tmp3_, "\t\n\r\b\f\"\\");
109 #line 53 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
110 len = _tmp4_;
111 #line 54 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
112 _tmp5_ = str;
113 #line 54 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
114 _tmp6_ = p;
115 #line 54 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
116 _tmp7_ = len;
117 #line 54 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
118 g_string_append_len (_tmp5_, (const gchar*) _tmp6_, (gssize) ((glong) _tmp7_));
119 #line 55 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
120 _tmp8_ = p;
121 #line 55 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
122 _tmp9_ = len;
123 #line 55 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
124 p = _tmp8_ + _tmp9_;
125 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
126 _tmp10_ = p;
127 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
128 switch (*_tmp10_) {
129 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
130 case '\t':
131 #line 132 "tracker-utils.c"
132 {
133 GString* _tmp11_;
134 #line 59 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
135 _tmp11_ = str;
136 #line 59 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
137 g_string_append (_tmp11_, "\\t");
138 #line 60 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
139 break;
140 #line 141 "tracker-utils.c"
141 }
142 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
143 case '\n':
144 #line 145 "tracker-utils.c"
145 {
146 GString* _tmp12_;
147 #line 62 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
148 _tmp12_ = str;
149 #line 62 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
150 g_string_append (_tmp12_, "\\n");
151 #line 63 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
152 break;
153 #line 154 "tracker-utils.c"
154 }
155 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
156 case '\r':
157 #line 158 "tracker-utils.c"
158 {
159 GString* _tmp13_;
160 #line 65 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
161 _tmp13_ = str;
162 #line 65 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
163 g_string_append (_tmp13_, "\\r");
164 #line 66 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
165 break;
166 #line 167 "tracker-utils.c"
167 }
168 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
169 case '\b':
170 #line 171 "tracker-utils.c"
171 {
172 GString* _tmp14_;
173 #line 68 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
174 _tmp14_ = str;
175 #line 68 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
176 g_string_append (_tmp14_, "\\b");
177 #line 69 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
178 break;
179 #line 180 "tracker-utils.c"
180 }
181 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
182 case '\f':
183 #line 184 "tracker-utils.c"
184 {
185 GString* _tmp15_;
186 #line 71 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
187 _tmp15_ = str;
188 #line 71 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
189 g_string_append (_tmp15_, "\\f");
190 #line 72 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
191 break;
192 #line 193 "tracker-utils.c"
193 }
194 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
195 case '"':
196 #line 197 "tracker-utils.c"
197 {
198 GString* _tmp16_;
199 #line 74 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
200 _tmp16_ = str;
201 #line 74 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
202 g_string_append (_tmp16_, "\\\"");
203 #line 75 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
204 break;
205 #line 206 "tracker-utils.c"
206 }
207 #line 57 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
208 case '\\':
209 #line 210 "tracker-utils.c"
210 {
211 GString* _tmp17_;
212 #line 77 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
213 _tmp17_ = str;
214 #line 77 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
215 g_string_append (_tmp17_, "\\\\");
216 #line 78 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
217 break;
218 #line 219 "tracker-utils.c"
219 }
220 default:
221 {
222 #line 80 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
223 continue;
224 #line 225 "tracker-utils.c"
225 }
226 }
227 #line 83 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
228 _tmp18_ = p;
229 #line 83 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
230 p = _tmp18_ + 1;
231 #line 232 "tracker-utils.c"
232 }
233 #line 86 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
234 _tmp19_ = str;
235 #line 86 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
236 _tmp20_ = _tmp19_->str;
237 #line 86 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
238 _tmp21_ = g_strdup (_tmp20_);
239 #line 86 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
240 result = _tmp21_;
241 #line 86 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
242 _g_string_free0 (str);
243 #line 86 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
244 return result;
245 #line 246 "tracker-utils.c"
246 }
247
248
249 /**
250 * tracker_sparql_get_uuid_urn:
251 *
252 * Generates a unique universal identifier to be used for urns
253 * when inserting SPARQL into the database. The string returned is
254 * in lower case and has the format "urn:uuid:%s" where
255 * %s is the uuid generated.
256 *
257 * Returns: a newly-allocated string. The returned string should
258 * be freed with g_free() when no longer needed.
259 *
260 * Since: 0.10
261 */
262 gchar* tracker_sparql_get_uuid_urn (void) {
263 gchar* result = NULL;
264 guchar* _tmp0_ = NULL;
265 guchar* base_uuid;
266 gint base_uuid_length1;
267 gint _base_uuid_size_;
(emitted by gcc) 268 gchar* _tmp1_ = NULL;
269 gchar* lower;
270 gchar* _tmp2_ = NULL;
271 #line 109 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
272 _tmp0_ = g_new0 (guchar, 16);
273 #line 109 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
274 base_uuid = _tmp0_;
275 #line 109 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
276 base_uuid_length1 = 16;
277 #line 109 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
278 _base_uuid_size_ = base_uuid_length1;
(emitted by clang-analyzer)TODO: a detailed trace is available in the data model (not yet rendered in this report)
279 #line 110 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
280 _tmp1_ = g_new0 (gchar, 37);
281 #line 110 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
282 lower = (gchar*) _tmp1_;
283 #line 112 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
284 uuid_generate (base_uuid);
285 #line 113 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
286 uuid_unparse_lower (base_uuid, (gchar*) lower);
287 #line 116 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
288 _tmp2_ = g_strdup_printf ("urn:uuid:%s", lower);
289 #line 116 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
290 result = _tmp2_;
291 #line 116 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
292 _g_free0 (lower);
293 #line 116 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
294 base_uuid = (g_free (base_uuid), NULL);
295 #line 116 "/home/martyn/Source/tracker/src/libtracker-sparql/tracker-utils.vala"
296 return result;
297 #line 298 "tracker-utils.c"
298 }