Bug Summary

File:builds/wireshark/wireshark/epan/dfilter/sttype-op.c
Warning:line 74, column 14
Value stored to 's' during its initialization 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 sttype-op.c -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 -fhalf-no-semantic-interposition -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-22/lib/clang/22 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -D CARES_NO_DEPRECATED -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_BUILD_DLL -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -I /builds/wireshark/wireshark/epan/dfilter -I /builds/wireshark/wireshark/build/epan/dfilter -I /builds/wireshark/wireshark/epan -I /builds/wireshark/wireshark/tools/lemon -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-22/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-nonliteral -std=gnu17 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -faddrsig -fdwarf2-cfi-asm -o /builds/wireshark/wireshark/sbout/2026-12-02-100354-3661-1 -x c /builds/wireshark/wireshark/epan/dfilter/sttype-op.c
1/*
2 * Wireshark - Network traffic analyzer
3 * By Gerald Combs <gerald@wireshark.org>
4 * Copyright 2001 Gerald Combs
5 *
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10#include "syntax-tree.h"
11#include "sttype-op.h"
12
13typedef struct {
14 uint32_t magic;
15 stnode_op_t op;
16 stmatch_t how;
17 stnode_t *val1;
18 stnode_t *val2;
19} oper_t;
20
21#define OPER_MAGIC0xab9009ba 0xab9009ba
22
23static void *
24oper_new(void *junk _U___attribute__((unused)))
25{
26 oper_t *oper;
27
28 ws_assert(junk == NULL)do { if ((1) && !(junk == ((void*)0))) ws_log_fatal_full
("", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c", 28, __func__
, "assertion failed: %s", "junk == ((void*)0)"); } while (0)
;
29
30 oper = g_new(oper_t, 1)((oper_t *) g_malloc_n ((1), sizeof (oper_t)));
31
32 oper->magic = OPER_MAGIC0xab9009ba;
33 oper->op = STNODE_OP_UNINITIALIZED;
34 oper->how = STNODE_MATCH_DEF;
35 oper->val1 = NULL((void*)0);
36 oper->val2 = NULL((void*)0);
37
38 return oper;
39}
40
41static void *
42oper_dup(const void *data)
43{
44 const oper_t *org = data;
45 oper_t *oper;
46
47 oper = oper_new(NULL((void*)0));
48 oper->op = org->op;
49 oper->how = org->how;
50 oper->val1 = stnode_dup(org->val1);
51 if (org->val2)
52 oper->val2 = stnode_dup(org->val2);
53
54 return oper;
55}
56
57static void
58oper_free(void *value)
59{
60 oper_t *oper = value;
61 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 61, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 61, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
62
63 if (oper->val1)
64 stnode_free(oper->val1);
65 if (oper->val2)
66 stnode_free(oper->val2);
67
68 g_free(oper)(__builtin_object_size ((oper), 0) != ((size_t) - 1)) ? g_free_sized
(oper, __builtin_object_size ((oper), 0)) : (g_free) (oper)
;
69}
70
71static char *
72oper_todisplay(const oper_t *oper)
73{
74 const char *s = "(notset)";
Value stored to 's' during its initialization is never read
75
76 switch(oper->op) {
77 case STNODE_OP_NOT:
78 s = "!";
79 break;
80 case STNODE_OP_AND:
81 s = "&&";
82 break;
83 case STNODE_OP_OR:
84 s = "||";
85 break;
86 case STNODE_OP_XOR:
87 s = "^^";
88 break;
89 case STNODE_OP_ALL_EQ:
90 s = "===";
91 break;
92 case STNODE_OP_ANY_EQ:
93 s = "==";
94 break;
95 case STNODE_OP_ALL_NE:
96 s = "!=";
97 break;
98 case STNODE_OP_ANY_NE:
99 s = "~=";
100 break;
101 case STNODE_OP_GT:
102 s = ">";
103 break;
104 case STNODE_OP_GE:
105 s = ">=";
106 break;
107 case STNODE_OP_LT:
108 s = "<";
109 break;
110 case STNODE_OP_LE:
111 s = "<=";
112 break;
113 case STNODE_OP_BITWISE_AND:
114 s = "&";
115 break;
116 case STNODE_OP_ADD:
117 s = "+";
118 break;
119 case STNODE_OP_UNARY_MINUS:
120 case STNODE_OP_SUBTRACT:
121 s = "-";
122 break;
123 case STNODE_OP_MULTIPLY:
124 s = "*";
125 break;
126 case STNODE_OP_DIVIDE:
127 s = "/";
128 break;
129 case STNODE_OP_MODULO:
130 s = "%";
131 break;
132 case STNODE_OP_CONTAINS:
133 s = "contains";
134 break;
135 case STNODE_OP_MATCHES:
136 s = "matches";
137 break;
138 case STNODE_OP_IN:
139 s = "in";
140 break;
141 case STNODE_OP_NOT_IN:
142 s = "not in";
143 break;
144 case STNODE_OP_UNINITIALIZED:
145 s = "(uninitialized)";
146 break;
147 }
148 return g_strdup(s)g_strdup_inline (s);
149}
150
151static char *
152oper_todebug(const oper_t *oper)
153{
154 const char *s = stnode_op_name(oper->op);
155 if (oper->how == STNODE_MATCH_ALL)
156 return ws_strdup_printf("ALL %s", s)wmem_strdup_printf(((void*)0), "ALL %s", s);
157 if (oper->how == STNODE_MATCH_ANY)
158 return ws_strdup_printf("ANY %s", s)wmem_strdup_printf(((void*)0), "ANY %s", s);
159 return ws_strdup(s)wmem_strdup(((void*)0), s);
160}
161
162static char *
163oper_tostr(const void *value, bool_Bool pretty)
164{
165 const oper_t *oper = value;
166 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 166, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 166, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
167
168 if (pretty)
169 return oper_todisplay(oper);
170 return oper_todebug(oper);
171}
172
173static int
174num_operands(stnode_op_t op)
175{
176 switch(op) {
177 case STNODE_OP_NOT:
178 case STNODE_OP_UNARY_MINUS:
179 return 1;
180 case STNODE_OP_AND:
181 case STNODE_OP_OR:
182 case STNODE_OP_XOR:
183 case STNODE_OP_ALL_EQ:
184 case STNODE_OP_ANY_EQ:
185 case STNODE_OP_ALL_NE:
186 case STNODE_OP_ANY_NE:
187 case STNODE_OP_GT:
188 case STNODE_OP_GE:
189 case STNODE_OP_LT:
190 case STNODE_OP_LE:
191 case STNODE_OP_BITWISE_AND:
192 case STNODE_OP_ADD:
193 case STNODE_OP_SUBTRACT:
194 case STNODE_OP_MULTIPLY:
195 case STNODE_OP_DIVIDE:
196 case STNODE_OP_MODULO:
197 case STNODE_OP_CONTAINS:
198 case STNODE_OP_MATCHES:
199 case STNODE_OP_IN:
200 case STNODE_OP_NOT_IN:
201 return 2;
202 case STNODE_OP_UNINITIALIZED:
203 ASSERT_STNODE_OP_NOT_REACHED(op)ws_log_fatal_full("", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 203, __func__, "Invalid stnode op '%s'.", stnode_op_name(op
))
;
204 }
205
206 ws_assert_not_reached()ws_log_fatal_full("", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 206, __func__, "assertion \"not reached\" failed")
;
207}
208
209
210void
211sttype_oper_set1(stnode_t *node, stnode_op_t op, stnode_t *val1)
212{
213 oper_t *oper = stnode_data(node);
214 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 214, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 214, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
215
216 ws_assert(num_operands(op) == 1)do { if ((1) && !(num_operands(op) == 1)) ws_log_fatal_full
("", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c", 216, __func__
, "assertion failed: %s", "num_operands(op) == 1"); } while (
0)
;
217 oper->op = op;
218 oper->val1 = val1;
219 oper->val2 = NULL((void*)0);
220 stnode_update_depth(node, val1);
221}
222
223void
224sttype_oper_set2(stnode_t *node, stnode_op_t op, stnode_t *val1, stnode_t *val2)
225{
226 oper_t *oper = stnode_data(node);
227 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 227, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 227, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
228
229 ws_assert(num_operands(op) == 2)do { if ((1) && !(num_operands(op) == 2)) ws_log_fatal_full
("", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c", 229, __func__
, "assertion failed: %s", "num_operands(op) == 2"); } while (
0)
;
230 oper->op = op;
231 oper->val1 = val1;
232 oper->val2 = val2;
233 stnode_update_depth(node, val1);
234 stnode_update_depth(node, val2);
235}
236
237void
238sttype_oper_set1_args(stnode_t *node, stnode_t *val1)
239{
240 oper_t *oper;
241
242 oper = (oper_t*)stnode_data(node);
243 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 243, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 243, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
244
245 ws_assert(num_operands(oper->op) == 1)do { if ((1) && !(num_operands(oper->op) == 1)) ws_log_fatal_full
("", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c", 245, __func__
, "assertion failed: %s", "num_operands(oper->op) == 1"); }
while (0)
;
246 oper->val1 = val1;
247 oper->val2 = NULL((void*)0);
248 stnode_update_depth(node, val1);
249}
250
251void
252sttype_oper_set2_args(stnode_t *node, stnode_t *val1, stnode_t *val2)
253{
254 oper_t *oper;
255
256 oper = (oper_t*)stnode_data(node);
257 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 257, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 257, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
258
259 ws_assert(num_operands(oper->op) == 2)do { if ((1) && !(num_operands(oper->op) == 2)) ws_log_fatal_full
("", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c", 259, __func__
, "assertion failed: %s", "num_operands(oper->op) == 2"); }
while (0)
;
260 oper->val1 = val1;
261 oper->val2 = val2;
262 stnode_update_depth(node, val1);
263 stnode_update_depth(node, val2);
264}
265
266void
267sttype_oper_set_op(stnode_t *node, stnode_op_t op)
268{
269 oper_t *oper = stnode_data(node);
270 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 270, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 270, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
271 ws_assert(oper->op == STNODE_OP_UNINITIALIZED)do { if ((1) && !(oper->op == STNODE_OP_UNINITIALIZED
)) ws_log_fatal_full("", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 271, __func__, "assertion failed: %s", "oper->op == STNODE_OP_UNINITIALIZED"
); } while (0)
;
272 oper->op = op;
273}
274
275stnode_op_t
276sttype_oper_get_op(stnode_t *node)
277{
278 oper_t *oper = stnode_data(node);
279 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 279, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 279, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
280 return oper->op;
281}
282
283void
284sttype_oper_get(stnode_t *node, stnode_op_t *p_op, stnode_t **p_val1, stnode_t **p_val2)
285{
286 oper_t *oper = stnode_data(node);
287 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 287, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 287, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
288
289 if (p_op)
290 *p_op = oper->op;
291 if (p_val1)
292 *p_val1 = oper->val1;
293 if (p_val2)
294 *p_val2 = oper->val2;
295}
296
297void
298sttype_test_set_match(stnode_t *node, stmatch_t how)
299{
300 oper_t *oper = stnode_data(node);
301 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 301, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 301, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
302 oper->how = how;
303}
304
305stmatch_t
306sttype_test_get_match(stnode_t *node)
307{
308 oper_t *oper = stnode_data(node);
309 ws_assert_magic(oper, OPER_MAGIC)do { do { if ((1) && !(oper)) ws_log_fatal_full("", LOG_LEVEL_ERROR
, "epan/dfilter/sttype-op.c", 309, __func__, "assertion failed: %s"
, "oper"); } while (0); if ((oper)->magic != (0xab9009ba))
{ ws_log_full("DFilter", LOG_LEVEL_ERROR, "epan/dfilter/sttype-op.c"
, 309, __func__, "Magic num is 0x%08" "x"", " "but should be 0x%08"
"x", (oper)->magic, (0xab9009ba)); } } while(0)
;
310 return oper->how;
311}
312
313void
314sttype_register_opers(void)
315{
316 static sttype_t test_type = {
317 STTYPE_TEST,
318 oper_new,
319 oper_free,
320 oper_dup,
321 oper_tostr
322 };
323 static sttype_t arithmetic_type = {
324 STTYPE_ARITHMETIC,
325 oper_new,
326 oper_free,
327 oper_dup,
328 oper_tostr
329 };
330
331 sttype_register(&test_type);
332 sttype_register(&arithmetic_type);
333}
334
335/*
336 * Editor modelines - https://www.wireshark.org/tools/modelines.html
337 *
338 * Local variables:
339 * c-basic-offset: 8
340 * tab-width: 8
341 * indent-tabs-mode: t
342 * End:
343 *
344 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
345 * :indentSize=8:tabSize=8:noTabs=false:
346 */