Skip to content

Commit 145d8f0

Browse files
varun-shanashif
authored andcommitted
tests: subsys: fs : Fix coverity issue
Fix Unchecked return value in func: nffs_test_util_create_file_blocks Coverity-CID: 190955 Fixes: #13860 Signed-off-by: Varun Sharma <[email protected]>
1 parent 7089ec7 commit 145d8f0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

tests/subsys/fs/multi-fs/src/nffs_test_utils.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ void nffs_test_util_create_file_blocks(const char *filename,
219219
int i;
220220

221221
/* We do not have 'truncate' flag in fs_open, so unlink here instead */
222-
fs_unlink(filename);
222+
rc = fs_unlink(filename);
223+
/* Don't fail on -ENOENT or 0, as can't truncate as file doesn't exists
224+
* or 0 on successful, fail on all other error values
225+
*/
226+
zassert_true(((rc == 0) || (rc == -ENOENT)), "unlink/truncate failed");
223227

224228
rc = fs_open(&file, filename);
225229
zassert_equal(rc, 0, NULL);

tests/subsys/fs/nffs_fs_api/common/nffs_test_utils.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,12 @@ void nffs_test_util_create_file_blocks(const char *filename,
234234
int rc;
235235
int i;
236236

237-
/* We do not have 'truncate' flag in fs_open, so unlink here instead */
238-
fs_unlink(filename);
237+
/* We do not have 'truncate' flag in fs_open, so unlink here instead*/
238+
rc = fs_unlink(filename);
239+
/* Don't fail on -ENOENT or 0, as can't truncate as file doesn't exists
240+
* or 0 on successful, fail on all other error values
241+
*/
242+
zassert_true(((rc == 0) || (rc == -ENOENT)), "unlink/truncate failed");
239243

240244
rc = fs_open(&file, filename);
241245
zassert_equal(rc, 0, NULL);

0 commit comments

Comments
 (0)