aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Peskine <Gilles.Peskine@arm.com>2020-08-25 22:50:18 +0200
committerGilles Peskine <Gilles.Peskine@arm.com>2020-08-25 22:50:18 +0200
commita09713c7956b300382e5ce4b7cea3b08cf5553e4 (patch)
tree6305542da50a9b2f7d1a6ca9d2129c057bb838bb
parent169ca7f06d99d3e8e4db06c56474f90a8c357be1 (diff)
downloadmbed-tls-a09713c7956b300382e5ce4b7cea3b08cf5553e4.tar.gz
test cleanup: Annotate file removal after a failed creation
Let static analyzers know that it's ok if remove() fails here. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
-rw-r--r--tests/suites/test_suite_psa_its.function13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/suites/test_suite_psa_its.function b/tests/suites/test_suite_psa_its.function
index b6cc488a6..a7ce7b1d4 100644
--- a/tests/suites/test_suite_psa_its.function
+++ b/tests/suites/test_suite_psa_its.function
@@ -40,16 +40,23 @@ static psa_storage_uid_t uid_max = 0;
static void cleanup( void )
{
+ /* Call remove() on all the files that a test might have created.
+ * We ignore the error if the file exists but remove() fails because
+ * it can't be checked portably (except by attempting to open the file
+ * first, which is needlessly slow and complicated here). A failure of
+ * remove() on an existing file is very unlikely anyway and would not
+ * have significant consequences other than perhaps failing the next
+ * test case. */
char filename[PSA_ITS_STORAGE_FILENAME_LENGTH];
psa_storage_uid_t uid;
for( uid = 0; uid < uid_max; uid++ )
{
psa_its_fill_filename( uid, filename );
- remove( filename );
+ (void) remove( filename );
}
psa_its_fill_filename( (psa_storage_uid_t)( -1 ), filename );
- remove( filename );
- remove( PSA_ITS_STORAGE_TEMP );
+ (void) remove( filename );
+ (void) remove( PSA_ITS_STORAGE_TEMP );
uid_max = 0;
}