Bug Summary

File:avlRead_BODY.c
Warning:line 190, column 9
3rd function call argument is an uninitialized value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name avlRead_BODY.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 -mthread-model posix -mframe-pointer=none -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I avlmrf -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-dangling-else -Wno-parentheses -Wno-unused-result -Wno-format-truncation -Wno-unused-function -fdebug-compilation-dir /home/jenkins/workspace/ESP_Stanalizer/LINUX64/CAPS/scan-build/CAPS/aim/avl -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/jenkins/workspace/ESP_Stanalizer/LINUX64/CAPS/scan-build/scanCAPS/2022-03-16-174428-58004-1 -x c avlmrf/avlRead_BODY.c

avlmrf/avlRead_BODY.c

1//**********************************************************************
2// Module: avlRead_BODY.c
3//
4// Copyright (C) 2022 Mark Drela, Harold Youngren, Steven Allmaras
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19//**********************************************************************
20
21#include "avlRead_BODY.h"
22#define AVL_MRF_INTERNAL
23#include "read_util.h"
24
25//----------------------------------------------------------------------------//
26// BODY: body forces
27//
28int avlRead_BODY( const char *filename, avlBody *body, bool_Bool verbose )
29{
30 int n, ibody;
31 char *string = NULL((void*)0), *version = NULL((void*)0);
32 double val[9];
33 bool_Bool isOK;
34 size_t stringsize = 128;
35 FILE *fp = NULL((void*)0);
36 avlLineBuffer line;
37 line.line = NULL((void*)0);
38 line.linesize = 0;
39
40 if (body == NULL((void*)0)) return -1;
1
Assuming 'body' is not equal to NULL
2
Taking false branch
41
42 avlFree_BODY( body );
43
44 fp = fopen( filename, "r" );
45 if (fp == NULL((void*)0))
3
Assuming 'fp' is not equal to NULL
4
Taking false branch
46 {
47 printf( "ERROR: unable to open %s\n", filename );
48 return -1;
49 }
50
51 string = (char *) malloc( stringsize * sizeof(char) );
52 if (string == NULL((void*)0))
5
Assuming 'string' is not equal to NULL
6
Taking false branch
53 {
54 printf( "ERROR: malloc error on 'string'\n" );
55 goto error;
56 }
57
58 version = (char *) malloc( stringsize * sizeof(char) );
59 if (version == NULL((void*)0))
7
Assuming 'version' is not equal to NULL
8
Taking false branch
60 {
61 printf( "ERROR: malloc error on 'version'\n" );
62 goto error;
63 }
64
65 // BODY
66 isOK = getLine_string1( fp, "BODY", &line, string );
9
Calling 'getLine_string1'
14
Returning from 'getLine_string1'
67 if (isOK
14.1
'isOK' is true
14.1
'isOK' is true
)
15
Taking true branch
68 {
69 if (strcmp(string, "BODY") != 0)
16
Assuming the condition is false
17
Taking false branch
70 {
71 printf( "ERROR in %s: expected 'BODY' file ID but got '%s'\n", __func__, string );
72 goto error;
73 }
74 if (verbose) printf( "%s\n", string );
18
Assuming 'verbose' is true
19
Taking true branch
75 }
76 else
77 goto error;
78
79 // VERSION
80 isOK = getLine_string2( fp, "VERSION", &line, string, version );
20
Calling 'getLine_string2'
25
Returning from 'getLine_string2'
81 if (isOK
25.1
'isOK' is true
25.1
'isOK' is true
)
26
Taking true branch
82 {
83 if (strcmp(string, "VERSION") != 0)
27
Assuming the condition is false
28
Taking false branch
84 {
85 printf( "ERROR: expected VERSION keyword but got '%s'\n", string );
86 goto error;
87 }
88 if (strcmp(version, "1.0") != 0)
29
Assuming the condition is false
30
Taking false branch
89 {
90 printf( "ERROR: unexpected VERSION number '%s'\n", version );
91 goto error;
92 }
93 if (verbose
30.1
'verbose' is true
30.1
'verbose' is true
) printf( "VERSION = %s\n", version );
31
Taking true branch
94 }
95 else
96 goto error;
97
98 // 'axis orientation'
99 isOK = getLine_line( fp, &line );
32
Calling 'getLine_line'
35
Returning from 'getLine_line'
100 if (isOK
35.1
'isOK' is true
35.1
'isOK' is true
)
36
Taking true branch
101 {
102 if (verbose
36.1
'verbose' is true
36.1
'verbose' is true
) printf( "%s\n", chop_newline(line.line) );
37
Taking true branch
103 }
104 else
105 goto error;
106
107 // 'Sref, Cref, Bref'
108 isOK = getLine_real3( fp, "Sref, Cref, Bref", &line, &body->Sref, &body->Cref, &body->Bref );
38
Calling 'getLine_real3'
43
Returning from 'getLine_real3'
109 if (isOK
43.1
'isOK' is true
43.1
'isOK' is true
)
44
Taking true branch
110 {
111 if (verbose
44.1
'verbose' is true
44.1
'verbose' is true
) printf( "Sref = %lf Cref = %lf Bref = %lf\n", body->Sref, body->Cref, body->Bref );
45
Taking true branch
112 }
113 else
114 goto error;
115
116 // 'Xref, Yref, Zref'
117 isOK = getLine_real3( fp, "Xref, Yref, Zref", &line, &body->Xref, &body->Yref, &body->Zref );
46
Calling 'getLine_real3'
51
Returning from 'getLine_real3'
118 if (isOK
51.1
'isOK' is true
51.1
'isOK' is true
)
52
Taking true branch
119 {
120 if (verbose
52.1
'verbose' is true
52.1
'verbose' is true
) printf( "Xref = %lf Yref = %lf Zref = %lf\n", body->Xref, body->Yref, body->Zref );
53
Taking true branch
121 }
122 else
123 goto error;
124
125 // # of bodies
126 body->nbody = 0;
127 isOK = getLine_int1( fp, "# of bodies", &line, &body->nbody );
54
Calling 'getLine_int1'
59
Returning from 'getLine_int1'
128 if (isOK
59.1
'isOK' is true
59.1
'isOK' is true
)
60
Taking true branch
129 {
130 if (verbose
60.1
'verbose' is true
60.1
'verbose' is true
) printf( "# bodies = %d\n", body->nbody );
61
Taking true branch
131 }
132 else
133 goto error;
134
135 // allocated bodies
136 body->body = (avlBodyProp *) malloc( body->nbody * sizeof(avlBodyProp) );
62
Uninitialized value stored to field 'Length'
137 if (body->body == NULL((void*)0))
63
Assuming field 'body' is not equal to NULL
64
Taking false branch
138 {
139 body->nbody = 0;
140 printf( "ERROR: malloc error on 'avlBodyProp'\n" );
141 goto error;
142 }
143 for (ibody = 0; ibody < body->nbody; ibody++)
65
Assuming 'ibody' is < field 'nbody'
66
Loop condition is true. Entering loop body
67
Assuming 'ibody' is >= field 'nbody'
68
Loop condition is false. Execution continues on line 147
144 body->body[ibody].name = NULL((void*)0);
145
146
147 for (ibody = 0; ibody < body->nbody; ibody++)
69
Loop condition is true. Entering loop body
148 {
149 // BODY
150 isOK = getLine_string1( fp, "BODY", &line, string );
70
Calling 'getLine_string1'
75
Returning from 'getLine_string1'
151 if (isOK
75.1
'isOK' is true
75.1
'isOK' is true
)
76
Taking true branch
152 {
153 if (strcmp(string, "BODY") != 0)
77
Assuming the condition is false
78
Taking false branch
154 {
155 printf( "ERROR: expected BODY keyword but got '%s'\n", string );
156 goto error;
157 }
158 if (verbose
78.1
'verbose' is true
78.1
'verbose' is true
) printf( "%s\n", string );
79
Taking true branch
159 }
160 else
161 goto error;
162
163 // body name
164 isOK = getLine_line( fp, &line );
80
Calling 'getLine_line'
83
Returning from 'getLine_line'
165 if (isOK
83.1
'isOK' is true
83.1
'isOK' is true
)
84
Taking true branch
166 {
167 body->body[ibody].name = strdup(chop_newline(line.line));
168 if (body->body[ibody].name == NULL((void*)0)) goto error;
85
Assuming field 'name' is not equal to NULL
86
Taking false branch
169 if (verbose
86.1
'verbose' is true
86.1
'verbose' is true
) printf( "%s\n", body->body[ibody].name );
87
Taking true branch
170 }
171 else
172 goto error;
173
174
175 // 'Ibdy Length Asurf Vol CL CD Cm CY Cn Cl'
176 isOK = getLine_int1_realn( fp, "Ibdy Length Asurf Vol CL CD Cm CY Cn Cl", &line, &n, val, 9 );
177 if (isOK)
88
Assuming 'isOK' is true
89
Taking true branch
178 {
179 body->body[ibody].Length = val[0];
180 body->body[ibody].Asurf = val[1];
181 body->body[ibody].Vol = val[2];
182 body->body[ibody].CL = val[3];
183 body->body[ibody].CD = val[4];
184 body->body[ibody].Cm = val[5];
185 body->body[ibody].CY = val[6];
186 body->body[ibody].Cn = val[7];
187 body->body[ibody].Cl = val[8];
188 if (verbose
89.1
'verbose' is true
89.1
'verbose' is true
)
90
Taking true branch
189 {
190 printf( "%d Length = %lf Asurf = %lf Vol = %lf CL = %lf ", n,
91
3rd function call argument is an uninitialized value
191 body->body[n-1].Length,
192 body->body[n-1].Asurf,
193 body->body[n-1].Vol,
194 body->body[n-1].CL );
195 printf( "CD = %lf Cm = %lf CY = %lf Cn = %lf Cl = %lf\n", body->body[n-1].CD,
196 body->body[n-1].Cm,
197 body->body[n-1].CY,
198 body->body[n-1].Cn,
199 body->body[n-1].Cl );
200 }
201 }
202 else
203 goto error;
204 }
205
206 avl_free( line.line );
207 avl_free( string );
208 avl_free( version );
209 fclose( fp );
210 if (verbose) printf( "BODY file read OK\n" );
211 return 0;
212
213error:
214 avl_free( line.line );
215 avl_free( string );
216 avl_free( version );
217 fclose( fp );
218 avlFree_BODY(body);
219 return -1;
220}
221
222//----------------------------------------------------------------------------//
223//
224void avlInit_BODY( avlBody *body )
225{
226 if (body == NULL((void*)0)) return;
227 body->body = NULL((void*)0);
228 body->nbody = 0;
229 body->Sref = body->Bref = body->Cref = 0;
230 body->Xref = body->Yref = body->Zref = 0;
231}
232
233//----------------------------------------------------------------------------//
234//
235void avlFree_BODY( avlBody *body )
236{
237 int i;
238 if (body == NULL((void*)0)) return;
239 for (i = 0; i < body->nbody; i++)
240 avl_free(body->body[i].name);
241 avl_free(body->body);
242 avlInit_BODY(body);
243}

avlmrf/read_util.h

1//**********************************************************************
2// Module: avlRead_util.c
3//
4// Copyright (C) 2022 Mark Drela, Harold Youngren, Steven Allmaras, Marshall Galbraith
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19//**********************************************************************
20
21#ifndef AVL_MRF_INTERNAL
22#error "This header is only intended for avlmrf internal use"
23#endif
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <stdbool.h>
29
30typedef struct
31{
32 char *line;
33 size_t linesize;
34} avlLineBuffer;
35
36// safe free
37static
38void avl_free( void *ptr )
39{
40 if (ptr == NULL((void*)0)) return;
41 free(ptr);
42}
43
44// replace newline (\n) with end-of-string (\0), and remove trailing white spaces
45static
46char* chop_newline( char *line )
47{
48 int len;
49 char *ptr;
50 if (line == NULL((void*)0)) return NULL((void*)0);
51 ptr = strchr(line, '\n');
52 if (ptr != NULL((void*)0)) *ptr = '\0';
53 while ((len = strlen(line)) > 0 && line[len-1] == ' ') line[len-1] = '\0';
54 return line;
55}
56
57static
58bool_Bool getLine_line( FILE *fp, avlLineBuffer *line )
59{
60 bool_Bool success = false0;
61
62 size_t readsize = getline( &line->line, &line->linesize, fp );
63 if (readsize
32.1
'readsize' is > 0
80.1
'readsize' is > 0
32.1
'readsize' is > 0
80.1
'readsize' is > 0
> 0)
33
Taking true branch
81
Taking true branch
64 {
65 success = true1;
66 }
67 else
68 {
69 printf( "ERROR on read in %s\n", __func__ );
70 }
71
72 return success;
34
Returning the value 1 (loaded from 'success'), which participates in a condition later
82
Returning the value 1 (loaded from 'success'), which participates in a condition later
73}
74
75static
76bool_Bool getLine_int1( FILE *fp, const char *msg, avlLineBuffer *line, int *val1 )
77{
78 bool_Bool success = false0;
79
80 size_t readsize = getline( &line->line, &line->linesize, fp );
81 if (readsize
54.1
'readsize' is > 0
54.1
'readsize' is > 0
> 0)
55
Taking true branch
82 {
83 size_t nread = sscanf( line->line, "%d", val1 );
84 if (nread == 1)
56
Assuming 'nread' is equal to 1
57
Taking true branch
85 {
86 success = true1;
87 }
88 else
89 {
90 printf( "ERROR: expected %s; got %s\n", msg, line->line );
91 }
92 }
93
94 return success;
58
Returning the value 1 (loaded from 'success'), which participates in a condition later
95}
96
97static
98bool_Bool getLine_int2( FILE *fp, const char *msg, avlLineBuffer *line, int *val1, int *val2 )
99{
100 bool_Bool success = false0;
101
102 size_t readsize = getline( &line->line, &line->linesize, fp );
103 if (readsize > 0)
104 {
105 size_t nread = sscanf( line->line, "%d %d", val1, val2 );
106 if (nread == 2)
107 {
108 success = true1;
109 }
110 else
111 {
112 printf( "ERROR: expected %s; got %s\n", msg, line->line );
113 }
114 }
115
116 return success;
117}
118
119static
120bool_Bool getLine_int3( FILE *fp, const char *msg, avlLineBuffer *line, int *val1, int *val2, int *val3 )
121{
122 bool_Bool success = false0;
123
124 size_t readsize = getline( &line->line, &line->linesize, fp );
125 if (readsize > 0)
126 {
127 size_t nread = sscanf( line->line, "%d %d %d", val1, val2, val3 );
128 if (nread == 3)
129 {
130 success = true1;
131 }
132 else
133 {
134 printf( "ERROR: expected %s; got %s\n", msg, line->line );
135 }
136 }
137
138 return success;
139}
140
141static
142bool_Bool getLine_int4( FILE *fp, const char *msg, avlLineBuffer *line, int *val1, int *val2, int *val3, int *val4 )
143{
144 bool_Bool success = false0;
145
146 size_t readsize = getline( &line->line, &line->linesize, fp );
147 if (readsize > 0)
148 {
149 size_t nread = sscanf( line->line, "%d %d %d %d", val1, val2, val3, val4 );
150 if (nread == 4)
151 {
152 success = true1;
153 }
154 else
155 {
156 printf( "ERROR: expected %s; got %s\n", msg, line->line );
157 }
158 }
159
160 return success;
161}
162
163static
164bool_Bool getLine_intn( FILE *fp, const char *msg, avlLineBuffer *line, int *valn, int nn )
165{
166 //printf( "%s: nn = %d\n", __func__, nn );
167 int n;
168 bool_Bool success = false0;
169
170 size_t readsize = getline( &line->line, &line->linesize, fp );
171 //printf( "%s: readsize = %zu linesize = %zu linesize0 = %zu\n", __func__, readsize, linesize, linesize0 );
172 if (readsize > 0)
173 {
174 char *ws = " "; // whitespace delimiter
175 char *token = NULL((void*)0);
176 size_t nread = 0;
177
178 token = strtok( line->line, ws );
179 if (token == NULL((void*)0)) goto error;
180 nread = sscanf( token, "%d", &(valn[0]) );
181 if (nread == 1)
182 {
183 for (n = 1; n < nn; n++)
184 {
185 token = strtok( NULL((void*)0), ws );
186 if (token == NULL((void*)0)) goto error;
187 nread += sscanf( token, "%d", &(valn[n]) );
188 }
189 if (nread == nn)
190 {
191 success = true1;
192 }
193 else
194 {
195 printf( "ERROR: expected %s; got %s\n", msg, line->line );
196 }
197 }
198 else
199 {
200 printf( "ERROR: expected %s; got %s\n", msg, line->line );
201 }
202 }
203
204 return success;
205error:
206 printf( "ERROR: expected %s; got %s\n", msg, line->line );
207 return false0;
208}
209
210static
211bool_Bool getLine_real1( FILE *fp, const char *msg, avlLineBuffer *line, double *val1 )
212{
213 bool_Bool success = false0;
214
215 size_t readsize = getline( &line->line, &line->linesize, fp );
216 if (readsize > 0)
217 {
218 size_t nread = sscanf( line->line, "%lf", val1 );
219 if (nread == 1)
220 {
221 success = true1;
222 }
223 else
224 {
225 printf( "ERROR: expected %s; got %s\n", msg, line->line );
226 }
227 }
228
229 return success;
230}
231
232static
233bool_Bool getLine_real2( FILE *fp, const char *msg, avlLineBuffer *line, double *val1, double *val2 )
234{
235 bool_Bool success = false0;
236
237 size_t readsize = getline( &line->line, &line->linesize, fp );
238 if (readsize > 0)
239 {
240 size_t nread = sscanf( line->line, "%lf %lf", val1, val2 );
241 if (nread == 2)
242 {
243 success = true1;
244 }
245 else
246 {
247 printf( "ERROR: expected %s; got %s\n", msg, line->line );
248 }
249 }
250
251 return success;
252}
253
254static
255bool_Bool getLine_real3( FILE *fp, const char *msg, avlLineBuffer *line, double *val1, double *val2, double *val3 )
256{
257 bool_Bool success = false0;
258
259 size_t readsize = getline( &line->line, &line->linesize, fp );
260 if (readsize
38.1
'readsize' is > 0
46.1
'readsize' is > 0
38.1
'readsize' is > 0
46.1
'readsize' is > 0
> 0)
39
Taking true branch
47
Taking true branch
261 {
262 size_t nread = sscanf( line->line, "%lf %lf %lf", val1, val2, val3 );
263 if (nread == 3)
40
Assuming 'nread' is equal to 3
41
Taking true branch
48
Assuming 'nread' is equal to 3
49
Taking true branch
264 {
265 success = true1;
266 }
267 else
268 {
269 printf( "ERROR: expected %s; got %s\n", msg, line->line );
270 }
271 }
272
273 return success;
42
Returning the value 1 (loaded from 'success'), which participates in a condition later
50
Returning the value 1 (loaded from 'success'), which participates in a condition later
274}
275
276static
277bool_Bool getLine_real4( FILE *fp, const char *msg, avlLineBuffer *line, double *val1, double *val2, double *val3, double *val4 )
278{
279 bool_Bool success = false0;
280 //printf( "%s: line = %p linesize = %zu\n", __func__, line, linesize );
281
282 size_t readsize = getline( &line->line, &line->linesize, fp );
283 if (readsize > 0)
284 {
285 size_t nread = sscanf( line->line, "%lf %lf %lf %lf", val1, val2, val3, val4 );
286 if (nread == 4)
287 {
288 success = true1;
289 }
290 else
291 {
292 printf( "ERROR: expected %s; got %s\n", msg, line->line );
293 }
294 }
295
296 return success;
297}
298
299static
300bool_Bool getLine_realn( FILE *fp, const char *msg, avlLineBuffer *line, double *valn, int nn )
301{
302 //printf( "%s: nn = %d\n", __func__, nn );
303 int n;
304 bool_Bool success = false0;
305 char *ws = " "; // whitespace delimiter
306 char *token;
307 size_t nread = 0;
308
309 size_t readsize = getline( &line->line, &line->linesize, fp );
310 if (readsize > 0)
311 {
312
313 token = strtok( line->line, ws );
314 if (token == NULL((void*)0)) goto error;
315 nread = sscanf( token, "%lf", &(valn[0]) );
316 if (nread == 1)
317 {
318 for (n = 1; n < nn; n++)
319 {
320 token = strtok( NULL((void*)0), ws );
321 if (token == NULL((void*)0)) goto error;
322 nread += sscanf( token, "%lf", &(valn[n]) );
323 }
324 if (nread == nn)
325 {
326 success = true1;
327 }
328 else
329 {
330 printf( "ERROR: expected %s; got %s\n", msg, line->line );
331 }
332 }
333 else
334 {
335 printf( "ERROR: expected %s; got %s\n", msg, line->line );
336 }
337 }
338
339 return success;
340error:
341 printf( "ERROR: expected %s; got %s\n", msg, line->line );
342 return false0;
343}
344
345static
346bool_Bool getLine_string1( FILE *fp, const char *msg, avlLineBuffer *line, char *string1 )
347{
348 bool_Bool success = false0;
349
350 size_t readsize = getline( &line->line, &line->linesize, fp );
351 if (readsize
9.1
'readsize' is > 0
70.1
'readsize' is > 0
9.1
'readsize' is > 0
70.1
'readsize' is > 0
> 0)
10
Taking true branch
71
Taking true branch
352 {
353 size_t nread = sscanf( line->line, "%s", string1 );
354 if (nread == 1)
11
Assuming 'nread' is equal to 1
12
Taking true branch
72
Assuming 'nread' is equal to 1
73
Taking true branch
355 {
356 success = true1;
357 }
358 else
359 {
360 printf( "ERROR: expected %s; got %s\n", msg, line->line );
361 }
362 }
363
364 return success;
13
Returning the value 1 (loaded from 'success'), which participates in a condition later
74
Returning the value 1 (loaded from 'success'), which participates in a condition later
365}
366
367static
368bool_Bool getLine_string2( FILE *fp, const char *msg, avlLineBuffer *line, char *string1, char *string2 )
369{
370 bool_Bool success = false0;
371
372 size_t readsize = getline( &line->line, &line->linesize, fp );
373 if (readsize
20.1
'readsize' is > 0
20.1
'readsize' is > 0
> 0)
21
Taking true branch
374 {
375 size_t nread = sscanf( line->line, "%s %s", string1, string2 );
376 if (nread == 2)
22
Assuming 'nread' is equal to 2
23
Taking true branch
377 {
378 success = true1;
379 }
380 else
381 {
382 printf( "ERROR: expected %s; got %s\n", msg, line->line );
383 }
384 }
385
386 return success;
24
Returning the value 1 (loaded from 'success'), which participates in a condition later
387}
388
389static
390bool_Bool getLine_real1_string1( FILE *fp, const char *msg, avlLineBuffer *line, double *val1, char *string1 )
391{
392 bool_Bool success = false0;
393
394 size_t readsize = getline( &line->line, &line->linesize, fp );
395 if (readsize > 0)
396 {
397 size_t nread = sscanf( line->line, "%lf %s", val1, string1 );
398 if (nread == 2)
399 {
400 success = true1;
401 }
402 else
403 {
404 printf( "ERROR: expected %s; got %s\n", msg, line->line );
405 }
406 }
407
408 return success;
409}
410
411static
412bool_Bool getLine_int1_realn( FILE *fp, const char *msg, avlLineBuffer *line, int *val1, double *valn, int nn )
413{
414 int n;
415 bool_Bool success = false0;
416 char *ws = " "; // whitespace delimiter
417 char *token;
418 size_t nread;
419
420 size_t readsize = getline( &line->line, &line->linesize, fp );
421 if (readsize > 0)
422 {
423 token = strtok( line->line, ws );
424 if (token == NULL((void*)0)) goto error;
425 nread = sscanf( token, "%d", val1 );
426 if (nread == 1)
427 {
428 for (n = 0; n < nn; n++)
429 {
430 token = strtok( NULL((void*)0), ws );
431 if (token == NULL((void*)0)) goto error;
432 nread += sscanf( token, "%lf", &(valn[n]) );
433 }
434 if (nread == nn+1)
435 {
436 success = true1;
437 }
438 else
439 {
440 printf( "ERROR: expected %s; got %s\n", msg, line->line );
441 }
442 }
443 else
444 {
445 printf( "ERROR: expected %s; got %s\n", msg, line->line );
446 }
447 }
448
449 return success;
450error:
451 printf( "ERROR: expected %s; got %s\n", msg, line->line );
452 return false0;
453}