Skip to content

Commit 5810f14

Browse files
JuergenReppSITAndreasFuchsTPM
authored andcommitted
scan-build: Add workarounds for scan-build false positives.
Scan build did complain about resource leaks which can't occur. Signed-off-by: Juergen Repp <juergen_repp@web.de>
1 parent d339f2f commit 5810f14

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/files.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,14 @@ bool files_save_bytes_to_file(const char *path, UINT8 *buf, UINT16 size) {
214214
if (fp != stdout) {
215215
fclose(fp);
216216
}
217-
217+
#ifdef __clang_analyzer__
218+
/* Workaround for scan-build false positive */
219+
else {
220+
if (fp) {
221+
fclose(fp);
222+
}
223+
}
224+
#endif
218225
return result;
219226
}
220227

tools/fapi/tss2_gettpm2object.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,29 @@ static int tss2_tool_onrun (FAPI_CONTEXT *fctx) {
158158
if (stream && stream != stdout) {
159159
fclose(stream);
160160
}
161+
#ifdef __clang_analyzer__
162+
/* Workaround for scan-build false positive */
163+
else {
164+
if (stream) {
165+
fclose(stream);
166+
}
167+
}
168+
#endif
161169

162170
return 0;
163171

164172
error:
165173
if (stream && stream != stdout) {
166174
fclose(stream);
167175
}
176+
#ifdef __clang_analyzer__
177+
/* Workaround for scan-build false positive */
178+
else {
179+
if (stream) {
180+
fclose(stream);
181+
}
182+
}
183+
#endif
168184
Fapi_Free (esys_blob);
169185
if (esys_handle != ESYS_TR_NONE) {
170186
Esys_FlushContext(esys_ctx, esys_handle);

0 commit comments

Comments
 (0)