main - cov: test for fixture being NULL pointer
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9721f3e0ff6fd841b62b6bcccceee2ebb914e96b Commit: 9721f3e0ff6fd841b62b6bcccceee2ebb914e96b Parent: 3f946bfce72952bc9e775ec41278dd33afbc9eb1 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Sep 20 10:28:07 2021 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Sep 20 14:26:09 2021 +0200
cov: test for fixture being NULL pointer
Explicit check for teoretical NULL pointer passed as fixture.
--- test/unit/bcache_t.c | 8 +++++--- test/unit/bcache_utils_t.c | 12 +++++++----- test/unit/bitset_t.c | 3 ++- test/unit/io_engine_t.c | 16 +++++++++------- test/unit/radix_tree_t.c | 3 ++- 5 files changed, 25 insertions(+), 17 deletions(-)
test/unit/bcache_t.c +5 -3
@@ -349,10 +349,12 @@ static struct fixture *_fixture_init(sector_t block_size, unsigned nr_cache_blocstatic void _fixture_exit (struct fixture *f) { -_expect (f->me,E_DESTROY ); -bcache_destroy (f->cache); +if (f) { +_expect (f->me,E_DESTROY ); +bcache_destroy (f->cache); -free (f); +free (f); + } }static void *_small_fixture_init (void )
test/unit/bcache_utils_t.c +7 -5
@@ -109,11 +109,13 @@ static void _fix_exit(void *fixture) {struct fixture *f = fixture; -bcache_destroy (f->cache); -close (f->fd); -bcache_clear_fd (f->di); -unlink (f->fname); -free (f); +if (f) { +bcache_destroy (f->cache); + (void )close (f->fd); +bcache_clear_fd (f->di); + (void )unlink (f->fname); +free (f); + } }//----------------------------------------------------------------
test/unit/bitset_t.c +2 -1
@@ -31,7 +31,8 @@ static void *_mem_init(void) {static void _mem_exit (void *mem) { -dm_pool_destroy (mem); +if (mem) +dm_pool_destroy (mem); }static void test_get_next (void *fixture)
test/unit/io_engine_t.c +9 -7
@@ -104,13 +104,15 @@ static void _fix_exit(void *fixture) {struct fixture *f = fixture; -close (f->fd); -bcache_clear_fd (f->di); -unlink (f->fname); -free (f->data); -if (f->e) - f->e->destroy (f->e); -free (f); +if (f) { + (void )close (f->fd); +bcache_clear_fd (f->di); + (void )unlink (f->fname); +free (f->data); +if (f->e) + f->e->destroy (f->e); +free (f); + } }static void _test_create (void *fixture)
test/unit/radix_tree_t.c +2 -1
@@ -28,7 +28,8 @@ static void *rt_init(void)static void rt_exit (void *fixture) { -radix_tree_destroy (fixture); +if (fixture) +radix_tree_destroy (fixture); }static void test_create_destroy (void *fixture)