Bug Summary

File:src/formatters.c
Warning:line 385, column 40
Dereference of null pointer

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name formatters.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 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/kfp/aldor/aldor/aldor/src -fcoverage-compilation-dir=/home/kfp/aldor/aldor/aldor/src -resource-dir /usr/local/lib/clang/18 -D PACKAGE_NAME="aldor" -D PACKAGE_TARNAME="aldor" -D PACKAGE_VERSION="1.4.0" -D PACKAGE_STRING="aldor 1.4.0" -D PACKAGE_BUGREPORT="aldor@xinutec.org" -D PACKAGE_URL="" -D PACKAGE="aldor" -D VERSION="1.4.0" -D YYTEXT_POINTER=1 -D HAVE_STDIO_H=1 -D HAVE_STDLIB_H=1 -D HAVE_STRING_H=1 -D HAVE_INTTYPES_H=1 -D HAVE_STDINT_H=1 -D HAVE_STRINGS_H=1 -D HAVE_SYS_STAT_H=1 -D HAVE_SYS_TYPES_H=1 -D HAVE_UNISTD_H=1 -D STDC_HEADERS=1 -D HAVE_LIBREADLINE=1 -D HAVE_READLINE_READLINE_H=1 -D HAVE_READLINE_HISTORY=1 -D HAVE_READLINE_HISTORY_H=1 -D USE_GLOOP_SHELL=1 -D GENERATOR_COROUTINES=0 -D HAVE_DLFCN_H=1 -D LT_OBJDIR=".libs/" -I . -D VCSVERSION="2c53e759f1e00e345f8b172e7139debda72fda13" -internal-isystem /usr/local/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-empty-body -Wno-enum-compare -Wno-missing-field-initializers -Wno-unused -Wno-unused-parameter -Wno-error=format -Wno-error=type-limits -Wno-error=strict-aliasing -Wno-sign-compare -Wno-error=shift-negative-value -Wno-error=clobbered -std=c99 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2026-01-15-223856-845667-1 -x c formatters.c
1#include "absub.h"
2#include "axlobs.h"
3#include "bigint.h"
4#include "errorset.h"
5#include "flog.h"
6#include "format.h"
7#include "formatters.h"
8#include "freevar.h"
9#include "java/javacode.h"
10#include "ostream.h"
11#include "sefo.h"
12#include "susage.h"
13#include "strops.h"
14#include "syme.h"
15#include "symeset.h"
16#include "tconst.h"
17#include "tfsat.h"
18#include "tposs.h"
19#include "ttable.h"
20#include "usedef.h"
21
22localstatic int tfFormatter(OStream stream, Pointer p);
23localstatic int tfFormatterAlt(OStream stream, int lvl, Pointer p);
24localstatic int tfListFormatter(OStream stream, Pointer p);
25
26localstatic int tpossFormatter(OStream stream, Pointer p);
27localstatic int fvFormatter(OStream stream, Pointer p);
28localstatic int absFormatter(OStream stream, Pointer p);
29localstatic int abbFormatter(OStream stream, Pointer p);
30
31localstatic int tconstFormatter(OStream stream, Pointer p);
32
33localstatic int symeFormatter(OStream stream, Pointer p);
34localstatic int symeSetFormatter(OStream stream, Pointer p);
35localstatic int symeListFormatter(OStream stream, Pointer p);
36localstatic int symeListListFormatter(OStream stream, Pointer p);
37
38localstatic int symeConditionFormatter(OStream stream, Pointer p);
39localstatic int symeConditionListFormatter(OStream stream, Pointer p);
40
41localstatic int tsetFormatter(OStream stream, Pointer p);
42
43localstatic int ptrFormatter(OStream stream, Pointer p);
44localstatic int ptrListFormatter(OStream stream, Pointer p);
45
46localstatic int aintFormatter(OStream stream, Pointer p);
47localstatic int aintListFormatter(OStream stream, Pointer p);
48
49localstatic int stringFormatter(OStream stream, Pointer p);
50localstatic int stringListFormatter(OStream stream, Pointer p);
51
52localstatic int bintFormatter(OStream stream, Pointer p);
53localstatic int symbolFormatter(OStream stream, Pointer p);
54
55localstatic int errorSetFormatter(OStream stream, Pointer p);
56localstatic int javaCodeFormatter(OStream stream, Pointer p);
57
58localstatic int boolFormatter(OStream ostream, int p);
59
60localstatic int slotUsageFormatter(OStream ostream, Pointer p);
61localstatic int slotUsageListFormatter(OStream ostream, Pointer p);
62
63localstatic int udInfoFormatter(OStream ostream, Pointer p);
64localstatic int udInfoListFormatter(OStream ostream, Pointer p);
65
66void
67fmttsInit()
68{
69 fmtRegisterI("Bool", boolFormatter);
70
71 fmtRegister("TForm", tfFormatter);
72 fmtRegisterAlt("TForm", tfFormatterAlt);
73 fmtRegister("TFormList", tfListFormatter);
74
75 fmtRegister("FreeVar", fvFormatter);
76 fmtRegister("TPoss", tpossFormatter);
77 fmtRegister("AbSub", absFormatter);
78 fmtRegister("AbBind", abbFormatter);
79
80 fmtRegister("TConst", tconstFormatter);
81
82 fmtRegister("Syme", symeFormatter);
83 fmtRegister("SymeSet", symeSetFormatter);
84 fmtRegister("SymeList", symeListFormatter);
85 fmtRegister("SymeListList", symeListListFormatter);
86
87 fmtRegister("SymeC", symeConditionFormatter);
88 fmtRegister("SymeCList", symeConditionListFormatter);
89
90 fmtRegister("TSet", tsetFormatter);
91
92 fmtRegister("Ptr", ptrFormatter);
93 fmtRegister("PtrList", ptrListFormatter);
94
95 fmtRegister("AInt", aintFormatter);
96 fmtRegister("AIntList", aintListFormatter);
97
98 fmtRegister("String", stringFormatter);
99 fmtRegister("StringList", stringListFormatter);
100
101 fmtRegister("SlotUsage", slotUsageFormatter);
102 fmtRegister("SlotUsageList", slotUsageListFormatter);
103
104 fmtRegister("UdInfo", udInfoFormatter);
105 fmtRegister("UdInfoList", udInfoListFormatter);
106
107 fmtRegister("BInt", bintFormatter);
108 fmtRegister("Symbol", symbolFormatter);
109
110 fmtRegister("ErrorSet", errorSetFormatter);
111 fmtRegister("JavaCode", javaCodeFormatter);
112}
113
114
115/*
116 * :: Formatted output
117 */
118
119localstatic int
120symeFormatter(OStream ostream, Pointer p)
121{
122 int c;
123
124 c = symeOStreamWrite(ostream, p);
125
126 return c;
127}
128
129localstatic int
130symeConditionFormatter(OStream ostream, Pointer p)
131{
132 Syme syme = (Syme) p;
133 int c;
134
135 c = symeOStreamWrite(ostream, syme);
136 c += listFormat(AbSyn)(AbSyn_listPointer->Format)(ostream, "AbSyn", (AbSynList) symeCondition(syme));
137
138 return c;
139}
140
141localstatic int
142tsetFormatter(OStream ostream, Pointer p)
143{
144 PointerTSet tset = (PointerTSet) p;
145 PointerTSetIter iter;
146 String sep = "";
147 int c = 0;
148
149 c += ostreamWrite(ostream, "{", -1);
150 for (iter = tsetIter(Pointer)(Pointer_tsetPointer->Iter)(tset);
151 tsetIterHasNext(Pointer)(Pointer_tsetPointer->IterHasNext)(iter);
152 iter = tsetIterNext(Pointer)(Pointer_tsetPointer->IterNext)(iter)) {
153 c += ostreamWrite(ostream, sep, -1);
154 c += ptrFormatter(ostream, tsetIterElt(Pointer)(Pointer_tsetPointer->IterElt)(iter));
155 sep = ", ";
156 }
157
158 c += ostreamWrite(ostream, ")", -1);
159 return c;
160}
161
162localstatic int
163ptrFormatter(OStream ostream, Pointer p)
164{
165 char buf[20];
166 int c;
167
168 sprintf(buf, "%p", p);
169 c = ostreamWrite(ostream, buf, -1);
170
171 return c;
172}
173
174localstatic int
175aintFormatter(OStream ostream, Pointer p)
176{
177 char buf[20];
178 int c;
179
180 sprintf(buf, AINT_FMT"%ld", (AInt) p);
181 c = ostreamWrite(ostream, buf, -1);
182
183 return c;
184}
185
186
187localstatic int
188stringFormatter(OStream ostream, Pointer p)
189{
190 String string = (String) p;
191 return ostreamWrite(ostream, string, -1);
192}
193
194
195localstatic int
196bintFormatter(OStream ostream, Pointer p)
197{
198 String s = bintToString((BInt) p);
199 int c = ostreamWrite(ostream, s, -1);
200 strFree(s);
201
202 return c;
203}
204
205localstatic int
206symbolFormatter(OStream ostream, Pointer p)
207{
208 String s = symString((Symbol) p)(((Symbol) p)->str);
209 int c = ostreamWrite(ostream, s, -1);
210
211 return c;
212}
213
214
215localstatic int
216tfFormatter(OStream ostream, Pointer p)
217{
218 int c;
219
220 c = tformOStreamWrite(ostream, false((int) 0), p);
221
222 return c;
223}
224
225localstatic int
226tfFormatterAlt(OStream ostream, int lvl, Pointer p)
227{
228 int c;
229
230 c = tformOStreamWrite(ostream, true1, p);
231
232 return c;
233}
234
235localstatic int
236fvFormatter(OStream ostream, Pointer p)
237{
238 FreeVar fv = (FreeVar) p;
239 int c;
240
241 c = ostreamPrintf(ostream, "[FV: %pSymeList]", fvSymes(fv)((fv)->symes));
242
243 return c;
244}
245
246localstatic int
247tpossFormatter(OStream ostream, Pointer p)
248{
249 TPoss tp = (TPoss) p;
250 int c;
251
252 c = tpossOStreamWrite(ostream, tp);
253
254 return c;
255}
256
257localstatic int
258absFormatter(OStream ostream, Pointer p)
259{
260 AbSub tp = (AbSub) p;
261 int c;
262
263 c = absOStreamWrite(ostream, tp);
264
265 return c;
266}
267
268
269localstatic int
270abbFormatter(OStream ostream, Pointer p)
271{
272 AbBind tp = (AbBind) p;
273 int c;
274
275 c = abbOStreamWrite(ostream, tp);
276
277 return c;
278}
279
280localstatic int
281errorSetFormatter(OStream ostream, Pointer p)
282{
283 ErrorSet errorSet = (ErrorSet) p;
284 int i;
285
286 i = ostreamPrintf(ostream, "[E: %pStringList]", errorSet->list);
287
288 return i;
289}
290
291localstatic int
292javaCodeFormatter(OStream ostream, Pointer p)
293{
294 JavaCode jco = (JavaCode) p;
295 int c;
296
297 c = ostreamPrintf(ostream, "%pSExpr", jcoSExpr(jco));
298
299 return c;
300}
301localstatic int
302tconstFormatter(OStream ostream, Pointer p)
303{
304 TConst tc = (TConst) p;
305 int i;
306
307 i = ostreamPrintf(ostream, "[TC: %d %pTForm %pTForm]", tc->serial, tc->argv[0], tc->argv[1]);
308
309 return i;
310}
311
312localstatic int
313symeSetFormatter(OStream ostream, Pointer p)
314{
315 SymeSet symeSet = (SymeSet) p;
316 return symeSetFormat(ostream, symeSet);
317}
318
319localstatic int
320tfListFormatter(OStream ostream, Pointer p)
321{
322 TFormList list = (TFormList) p;
323 return listFormat(TForm)(TForm_listPointer->Format)(ostream, "TForm", list);
324}
325
326localstatic int
327symeListFormatter(OStream ostream, Pointer p)
328{
329 SymeList list = (SymeList) p;
330 return listFormat(Syme)(Syme_listPointer->Format)(ostream, "Syme", list);
331}
332
333localstatic int
334symeListListFormatter(OStream ostream, Pointer p)
335{
336 SymeListList list = (SymeListList) p;
337 return listFormat(SymeList)(SymeList_listPointer->Format)(ostream, "SymeList", list);
338}
339
340localstatic int
341symeConditionListFormatter(OStream ostream, Pointer p)
342{
343 SymeList list = (SymeList) p;
344 return listFormat(Syme)(Syme_listPointer->Format)(ostream, "SymeC", list);
345}
346
347localstatic int
348ptrListFormatter(OStream ostream, Pointer p)
349{
350 AbSynList list = (AbSynList) p;
351 return listFormat(AbSyn)(AbSyn_listPointer->Format)(ostream, "Ptr", list);
352}
353
354localstatic int
355aintListFormatter(OStream ostream, Pointer p)
356{
357 AIntList list = (AIntList) p;
358 return listFormat(AInt)(AInt_listPointer->Format)(ostream, "AInt", list);
359}
360
361localstatic int
362stringListFormatter(OStream ostream, Pointer p)
363{
364 StringList list = (StringList) p;
365 return listFormat(String)(String_listPointer->Format)(ostream, "String", list);
366}
367
368localstatic int
369boolFormatter(OStream ostream, int p)
370{
371 Bool flg = p;
372
373 if (flg < 0 || flg > 1) {
374 return ostreamPrintf(ostream, "Bool[%d]", flg);
375 }
376 else {
377 return ostreamPrintf(ostream, "%s", flg ? "true": "false");
378 }
379}
380
381localstatic int
382slotUsageFormatter(OStream ostream, Pointer p)
383{
384 SlotUsage usage = (AInt) p;
385 return ostreamPrintf(ostream, "%d%s", suVal(usage)( (usage & 2) == 2 ? ((usage) >> 2): *(int*) 0), suIsUsed(usage)( (usage) & 1) ? "R" : "");
1
Assuming the condition is false
2
'?' condition is false
3
Dereference of null pointer
386}
387
388localstatic int
389slotUsageListFormatter(OStream ostream, Pointer p)
390{
391 SlotUsageList list = (SlotUsageList) p;
392 return listFormat(SlotUsage)(SlotUsage_listPointer->Format)(ostream, "SlotUsage", list);
393}
394
395localstatic int
396udInfoFormatter(OStream ostream, Pointer p)
397{
398 UdInfo udInfo = (UdInfo) p;
399 return ostreamPrintf(ostream, "(UD %d %pFoam)", udInfo->block->label, udInfo->foam);
400}
401
402localstatic int
403udInfoListFormatter(OStream ostream, Pointer p)
404{
405 UdInfoList list = (UdInfoList) p;
406 return listFormat(UdInfo)(UdInfo_listPointer->Format)(ostream, "UdInfo", list);
407}