Bug Summary

File:build/Linux-monkey/duktape/dom_token_list.c
Warning:line 319, column 4
Value stored to 'exc' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name dom_token_list.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/var/lib/jenkins/workspace/scan-build-netsurf -resource-dir /usr/lib/llvm-14/lib/clang/14.0.6 -I . -I include -I build/Linux-monkey -I frontends -I content/handlers -D WITH_JPEG -U WITH_PDF_EXPORT -D LIBICONV_PLUG -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -I /usr/include/x86_64-linux-gnu -D WITH_CURL -D WITH_OPENSSL -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D UTF8PROC_EXPORTS -D WITH_UTF8PROC -D WITH_WEBP -I /usr/include/libpng16 -D WITH_PNG -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include/ -D WITH_BMP -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D WITH_GIF -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D WITH_NSPSL -I /var/lib/jenkins/artifacts-x86_64-linux-gnu/include -D WITH_NSLOG -D NETSURF_UA_FORMAT_STRING="Mozilla/5.0 (%s) NetSurf/%d.%d" -D NETSURF_HOMEPAGE="about:welcome" -D NETSURF_LOG_LEVEL=VERBOSE -D NETSURF_BUILTIN_LOG_FILTER="(level:WARNING || cat:jserrors)" -D NETSURF_BUILTIN_VERBOSE_FILTER="(level:VERBOSE || cat:jserrors)" -D STMTEXPR=1 -D monkey -D nsmonkey -D MONKEY_RESPATH="/var/lib/jenkins/artifacts-x86_64-linux-gnu/share/netsurf/" -D _POSIX_C_SOURCE=200809L -D _XOPEN_SOURCE=700 -D _BSD_SOURCE -D _DEFAULT_SOURCE -D _NETBSD_SOURCE -D DUK_OPT_HAVE_CUSTOM_H -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wwrite-strings -Wno-unused-parameter -Wno-unused-but-set-variable -std=c99 -fconst-strings -fdebug-compilation-dir=/var/lib/jenkins/workspace/scan-build-netsurf -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-display-progress -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/lib/jenkins/workspace/scan-build-netsurf/clangScanBuildReports/2024-12-06-010724-1990715-1 -x c build/Linux-monkey/duktape/dom_token_list.c
1/* Generated by nsgenbind
2 *
3 * nsgenbind is published under the MIT Licence.
4 * nsgenbind is similar to a compiler is a purely transformative tool which
5 * explicitly makes no copyright claim on this generated output
6 */
7
8/* DukTape JavaScript bindings for NetSurf browser
9 *
10 * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
11 * This file is part of NetSurf, http://www.netsurf-browser.org/
12 * Released under the terms of the MIT License,
13 * http://www.opensource.org/licenses/mit-license
14 */
15
16#include <dom/dom.h>
17
18#include "utils/log.h"
19#include "utils/nsurl.h"
20
21#include "javascript/duktape/duktape.h"
22
23struct browser_window;
24struct html_content;
25struct dom_node;
26struct dom_element;
27struct dom_document;
28struct dom_html_element;
29struct dom_node_character_data;
30struct dom_node_text;
31struct dom_node_list;
32struct dom_node_comment;
33struct dom_html_collection;
34struct dom_html_br_element;
35
36
37#include "build/Linux-monkey/duktape/binding.h"
38#include "build/Linux-monkey/duktape/private.h"
39#include "build/Linux-monkey/duktape/prototype.h"
40
41#include "javascript/duktape/dukky.h"
42
43void dukky_dom_token_list___init(duk_context *ctx, dom_token_list_private_t *priv, struct dom_tokenlist *tokens)
44{
45#line 16 "DOMTokenList.bnd"
46
47 priv->tokens = tokens;
48 dom_tokenlist_ref(tokens);
49#line 50 "dom_token_list.c"
50}
51
52void dukky_dom_token_list___fini(duk_context *ctx, dom_token_list_private_t *priv)
53{
54
55 dom_tokenlist_unref(priv->tokens);
56}
57
58static duk_ret_t dukky_dom_token_list___constructor(duk_context *ctx)
59{
60 /* create private data and attach to instance */
61 dom_token_list_private_t *priv = calloc(1, sizeof(*priv));
62 if (priv == NULL((void*)0)) return 0;
63 duk_push_pointer(ctx, priv);
64 duk_put_prop_string(ctx, 0, dukky_magic_string_private);
65
66 dukky_dom_token_list___init(ctx, priv, duk_get_pointer(ctx, 1));
67 duk_set_top(ctx, 1);
68 return 1;
69}
70
71static duk_ret_t dukky_dom_token_list___destructor(duk_context *ctx)
72{
73 dom_token_list_private_t *priv;
74 duk_get_prop_string(ctx, 0, dukky_magic_string_private);
75 priv = duk_get_pointer(ctx, -1);
76 duk_pop(ctx);
77 if (priv == NULL((void*)0)) return 0;
78
79 dukky_dom_token_list___fini(ctx, priv);
80 free(priv);
81 return 0;
82}
83
84static duk_ret_t dukky_dom_token_list_item(duk_context *ctx)
85{
86 /* ensure the parameters are present */
87 duk_idx_t dukky_argc = duk_get_top(ctx);
88 if (dukky_argc < 1) {
89 /* not enough arguments */
90 return duk_error(ctx, DUK_RET_TYPE_ERROR, dukky_error_fmt_argument, 1, dukky_argc)(duk_error_raw((ctx), (duk_errcode_t) ((-6)), (const char *) (
"dom_token_list.c"), (duk_int_t) (90), dukky_error_fmt_argument
, 1, dukky_argc), (duk_ret_t) 0)
;
91 } else if (dukky_argc > 1) {
92 /* remove extraneous parameters */
93 duk_set_top(ctx, 1);
94 }
95
96 /* check types of passed arguments are correct */
97 if (dukky_argc > 0) {
98 if (!duk_is_number(ctx, 0)) {
99 return duk_error(ctx, DUK_ERR_ERROR, dukky_error_fmt_number_type, 0, "index")(duk_error_raw((ctx), (duk_errcode_t) (1), (const char *) ("dom_token_list.c"
), (duk_int_t) (99), dukky_error_fmt_number_type, 0, "index")
, (duk_ret_t) 0)
;
100 }
101 }
102 /* Get private data for method */
103 dom_token_list_private_t *priv = NULL((void*)0);
104 duk_push_this(ctx);
105 duk_get_prop_string(ctx, -1, dukky_magic_string_private);
106 priv = duk_get_pointer(ctx, -1);
107 duk_pop_2(ctx);
108 if (priv == NULL((void*)0)) {
109 return 0; /* can do? No can do. */
110 }
111
112#line 41 "DOMTokenList.bnd"
113
114 unsigned long i = duk_to_uint(ctx, 0);
115 dom_exception err;
116 dom_string *value;
117
118 err = dom_tokenlist_item(priv->tokens, i, &value)_dom_tokenlist_item((dom_tokenlist *) (priv->tokens), (uint32_t
) (i), (struct dom_string **) (&value))
;
119
120 if (err != DOM_NO_ERR) return 0; /* coerced to undefined */
121
122 if (value == NULL((void*)0)) {
123 duk_push_null(ctx);
124 return 1;
125 }
126
127 duk_push_lstring(ctx, dom_string_data(value), dom_string_length(value));
128 dom_string_unref(value);
129
130 return 1;
131#line 132 "dom_token_list.c"
132}
133
134static duk_ret_t dukky_dom_token_list_contains(duk_context *ctx)
135{
136 /* ensure the parameters are present */
137 duk_idx_t dukky_argc = duk_get_top(ctx);
138 if (dukky_argc < 1) {
139 /* not enough arguments */
140 return duk_error(ctx, DUK_RET_TYPE_ERROR, dukky_error_fmt_argument, 1, dukky_argc)(duk_error_raw((ctx), (duk_errcode_t) ((-6)), (const char *) (
"dom_token_list.c"), (duk_int_t) (140), dukky_error_fmt_argument
, 1, dukky_argc), (duk_ret_t) 0)
;
141 } else if (dukky_argc > 1) {
142 /* remove extraneous parameters */
143 duk_set_top(ctx, 1);
144 }
145
146 /* check types of passed arguments are correct */
147 if (dukky_argc > 0) {
148 if (!duk_is_string(ctx, 0)) {
149 duk_to_string(ctx, 0);
150 }
151 }
152 /* Get private data for method */
153 dom_token_list_private_t *priv = NULL((void*)0);
154 duk_push_this(ctx);
155 duk_get_prop_string(ctx, -1, dukky_magic_string_private);
156 priv = duk_get_pointer(ctx, -1);
157 duk_pop_2(ctx);
158 if (priv == NULL((void*)0)) {
159 return 0; /* can do? No can do. */
160 }
161
162#line 108 "DOMTokenList.bnd"
163
164 dom_exception exc;
165 dom_string *value;
166 duk_size_t slen;
167 const char *s = duk_safe_to_lstring(ctx, 0, &slen);
168 bool_Bool present = false0;
169
170 exc = dom_string_create_interned((const uint8_t *)s, slen, &value);
171 if (exc != DOM_NO_ERR) return 0;
172
173 exc = dom_tokenlist_contains(priv->tokens, value, &present);
174 dom_string_unref(value);
175 if (exc != DOM_NO_ERR) return 0;
176
177 duk_push_boolean(ctx, present);
178
179 return 1;
180#line 181 "dom_token_list.c"
181}
182
183static duk_ret_t dukky_dom_token_list_add(duk_context *ctx)
184{
185 /* Get private data for method */
186 dom_token_list_private_t *priv = NULL((void*)0);
187 duk_push_this(ctx);
188 duk_get_prop_string(ctx, -1, dukky_magic_string_private);
189 priv = duk_get_pointer(ctx, -1);
190 duk_pop_2(ctx);
191 if (priv == NULL((void*)0)) {
192 return 0; /* can do? No can do. */
193 }
194
195#line 62 "DOMTokenList.bnd"
196
197 dom_exception exc;
198 dom_string *value;
199 duk_size_t slen;
200 const char *s;
201 duk_idx_t spos;
202
203 for (spos = 0; spos < duk_get_top(ctx); ++spos) {
204 s = duk_safe_to_lstring(ctx, spos, &slen);
205
206 duk_safe_to_lstring(ctx, 0, &slen);
207
208 exc = dom_string_create_interned((const uint8_t *)s, slen, &value);
209 if (exc != DOM_NO_ERR) return 0;
210
211 exc = dom_tokenlist_add(priv->tokens, value);
212 dom_string_unref(value);
213 }
214
215 return 0;
216#line 217 "dom_token_list.c"
217}
218
219static duk_ret_t dukky_dom_token_list_remove(duk_context *ctx)
220{
221 /* Get private data for method */
222 dom_token_list_private_t *priv = NULL((void*)0);
223 duk_push_this(ctx);
224 duk_get_prop_string(ctx, -1, dukky_magic_string_private);
225 priv = duk_get_pointer(ctx, -1);
226 duk_pop_2(ctx);
227 if (priv == NULL((void*)0)) {
228 return 0; /* can do? No can do. */
229 }
230
231#line 85 "DOMTokenList.bnd"
232
233 dom_exception exc;
234 dom_string *value;
235 duk_size_t slen;
236 const char *s;
237 duk_idx_t spos;
238
239 for (spos = 0; spos < duk_get_top(ctx); ++spos) {
240 s = duk_safe_to_lstring(ctx, spos, &slen);
241
242 duk_safe_to_lstring(ctx, 0, &slen);
243
244 exc = dom_string_create_interned((const uint8_t *)s, slen, &value);
245 if (exc != DOM_NO_ERR) return 0;
246
247 exc = dom_tokenlist_remove(priv->tokens, value);
248 dom_string_unref(value);
249 }
250
251 return 0;
252#line 253 "dom_token_list.c"
253}
254
255static duk_ret_t dukky_dom_token_list_toggle(duk_context *ctx)
256{
257 /* ensure the parameters are present */
258 duk_idx_t dukky_argc = duk_get_top(ctx);
259 if (dukky_argc < 1) {
260 /* not enough arguments */
261 return duk_error(ctx, DUK_RET_TYPE_ERROR, dukky_error_fmt_argument, 1, dukky_argc)(duk_error_raw((ctx), (duk_errcode_t) ((-6)), (const char *) (
"dom_token_list.c"), (duk_int_t) (261), dukky_error_fmt_argument
, 1, dukky_argc), (duk_ret_t) 0)
;
262 } else if (dukky_argc == 1) {
263 /* 1 optional arguments need adding */
264 duk_push_undefined(ctx);
265 } else if (dukky_argc > 2) {
266 /* remove extraneous parameters */
267 duk_set_top(ctx, 2);
268 }
269
270 /* check types of passed arguments are correct */
271 if (dukky_argc > 0) {
272 if (!duk_is_string(ctx, 0)) {
273 duk_to_string(ctx, 0);
274 }
275 }
276 if (dukky_argc > 1) {
277 if (!duk_is_boolean(ctx, 1)) {
278 if (duk_is_number(ctx, 1)) {
279 duk_to_boolean(ctx, 1);
280 } else {
281 return duk_error(ctx, DUK_ERR_ERROR, dukky_error_fmt_bool_type, 1, "force")(duk_error_raw((ctx), (duk_errcode_t) (1), (const char *) ("dom_token_list.c"
), (duk_int_t) (281), dukky_error_fmt_bool_type, 1, "force"),
(duk_ret_t) 0)
;
282 }
283 }
284 }
285 /* Get private data for method */
286 dom_token_list_private_t *priv = NULL((void*)0);
287 duk_push_this(ctx);
288 duk_get_prop_string(ctx, -1, dukky_magic_string_private);
289 priv = duk_get_pointer(ctx, -1);
290 duk_pop_2(ctx);
291 if (priv == NULL((void*)0)) {
292 return 0; /* can do? No can do. */
293 }
294
295#line 128 "DOMTokenList.bnd"
296
297 dom_exception exc;
298 dom_string *value;
299 duk_size_t slen;
300 const char *s = duk_require_lstring(ctx, 0, &slen);
301 bool_Bool toggle_set = duk_get_top(ctx) > 1;
302 bool_Bool toggle = duk_opt_boolean(ctx, 1, 0);
303 bool_Bool present;
304
305 exc = dom_string_create_interned((const uint8_t *)s, slen, &value);
306 if (exc != DOM_NO_ERR) return 0;
307
308 exc = dom_tokenlist_contains(priv->tokens, value, &present);
309 if (exc != DOM_NO_ERR) {
310 dom_string_unref(value);
311 return 0;
312 }
313
314 /* Decision matrix is based on present, toggle_set, and toggle */
315 if (toggle_set) {
316 if (toggle) {
317 exc = dom_tokenlist_add(priv->tokens, value);
318 } else {
319 exc = dom_tokenlist_remove(priv->tokens, value);
Value stored to 'exc' is never read
320 }
321 } else {
322 if (present) {
323 exc = dom_tokenlist_add(priv->tokens, value);
324 } else {
325 exc = dom_tokenlist_remove(priv->tokens, value);
326 }
327 }
328 dom_string_unref(value);
329
330 return 0;
331#line 332 "dom_token_list.c"
332}
333
334static duk_ret_t dukky_dom_token_list_length_getter(duk_context *ctx)
335{
336 /* Get private data for method */
337 dom_token_list_private_t *priv = NULL((void*)0);
338 duk_push_this(ctx);
339 duk_get_prop_string(ctx, -1, dukky_magic_string_private);
340 priv = duk_get_pointer(ctx, -1);
341 duk_pop_2(ctx);
342 if (priv == NULL((void*)0)) {
343 return 0; /* can do? No can do. */
344 }
345
346#line 27 "DOMTokenList.bnd"
347
348 dom_exception err;
349 uint32_t len;
350
351 err = dom_tokenlist_get_length(priv->tokens, &len);
352
353 if (err != DOM_NO_ERR) return 0; /* coerced to undefined */
354
355 duk_push_uint(ctx, (duk_uint_t)len);
356
357 return 1;
358#line 359 "dom_token_list.c"
359}
360
361duk_ret_t dukky_dom_token_list___proto(duk_context *ctx, void *udata)
362{
363 /* Add a method */
364 duk_dup(ctx, 0);
365 duk_push_string(ctx, "item");
366 duk_push_c_function(ctx, dukky_dom_token_list_item, DUK_VARARGS((duk_int_t) (-1)));
367 duk_def_prop(ctx, -3,
368 DUK_DEFPROP_HAVE_VALUE(1U << 6) |
369 DUK_DEFPROP_HAVE_WRITABLE(1U << 3) |
370 DUK_DEFPROP_HAVE_ENUMERABLE(1U << 4) |
371 DUK_DEFPROP_ENUMERABLE(1U << 1) |
372 DUK_DEFPROP_HAVE_CONFIGURABLE(1U << 5));
373 duk_pop(ctx);
374
375 /* Add a method */
376 duk_dup(ctx, 0);
377 duk_push_string(ctx, "contains");
378 duk_push_c_function(ctx, dukky_dom_token_list_contains, DUK_VARARGS((duk_int_t) (-1)));
379 duk_def_prop(ctx, -3,
380 DUK_DEFPROP_HAVE_VALUE(1U << 6) |
381 DUK_DEFPROP_HAVE_WRITABLE(1U << 3) |
382 DUK_DEFPROP_HAVE_ENUMERABLE(1U << 4) |
383 DUK_DEFPROP_ENUMERABLE(1U << 1) |
384 DUK_DEFPROP_HAVE_CONFIGURABLE(1U << 5));
385 duk_pop(ctx);
386
387 /* Add a method */
388 duk_dup(ctx, 0);
389 duk_push_string(ctx, "add");
390 duk_push_c_function(ctx, dukky_dom_token_list_add, DUK_VARARGS((duk_int_t) (-1)));
391 duk_def_prop(ctx, -3,
392 DUK_DEFPROP_HAVE_VALUE(1U << 6) |
393 DUK_DEFPROP_HAVE_WRITABLE(1U << 3) |
394 DUK_DEFPROP_HAVE_ENUMERABLE(1U << 4) |
395 DUK_DEFPROP_ENUMERABLE(1U << 1) |
396 DUK_DEFPROP_HAVE_CONFIGURABLE(1U << 5));
397 duk_pop(ctx);
398
399 /* Add a method */
400 duk_dup(ctx, 0);
401 duk_push_string(ctx, "remove");
402 duk_push_c_function(ctx, dukky_dom_token_list_remove, DUK_VARARGS((duk_int_t) (-1)));
403 duk_def_prop(ctx, -3,
404 DUK_DEFPROP_HAVE_VALUE(1U << 6) |
405 DUK_DEFPROP_HAVE_WRITABLE(1U << 3) |
406 DUK_DEFPROP_HAVE_ENUMERABLE(1U << 4) |
407 DUK_DEFPROP_ENUMERABLE(1U << 1) |
408 DUK_DEFPROP_HAVE_CONFIGURABLE(1U << 5));
409 duk_pop(ctx);
410
411 /* Add a method */
412 duk_dup(ctx, 0);
413 duk_push_string(ctx, "toggle");
414 duk_push_c_function(ctx, dukky_dom_token_list_toggle, DUK_VARARGS((duk_int_t) (-1)));
415 duk_def_prop(ctx, -3,
416 DUK_DEFPROP_HAVE_VALUE(1U << 6) |
417 DUK_DEFPROP_HAVE_WRITABLE(1U << 3) |
418 DUK_DEFPROP_HAVE_ENUMERABLE(1U << 4) |
419 DUK_DEFPROP_ENUMERABLE(1U << 1) |
420 DUK_DEFPROP_HAVE_CONFIGURABLE(1U << 5));
421 duk_pop(ctx);
422
423 /* Add readonly property */
424 duk_dup(ctx, 0);
425 duk_push_string(ctx, "length");
426 duk_push_c_function(ctx, dukky_dom_token_list_length_getter, 0);
427 duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER(1U << 7) |
428 DUK_DEFPROP_HAVE_ENUMERABLE(1U << 4) | DUK_DEFPROP_ENUMERABLE(1U << 1) |
429 DUK_DEFPROP_HAVE_CONFIGURABLE(1U << 5));
430 duk_pop(ctx);
431
432 /* Set the destructor */
433 duk_dup(ctx, 0);
434 duk_push_c_function(ctx, dukky_dom_token_list___destructor, 1);
435 duk_set_finalizer(ctx, -2);
436 duk_pop(ctx);
437
438 /* Set the constructor */
439 duk_dup(ctx, 0);
440 duk_push_c_function(ctx, dukky_dom_token_list___constructor, 2);
441 duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT");
442 duk_pop(ctx);
443
444 return 1; /* The prototype object */
445}
446
447