diff options
author | ShyamsundarR <srangana@redhat.com> | 2018-12-12 16:45:09 -0500 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-12-14 04:33:15 +0000 |
commit | bfe2b5e1530efd364af7a175c8a1c89bc4cab0bb (patch) | |
tree | 2030f52c92661f8d285c9905481787dced506a91 /xlators/protocol | |
parent | 8293d21280fd6ddfc9bb54068cf87794fc6be207 (diff) |
clang: Fix various missing checks for empty list
When using list_for_each_entry(_safe) functions, care needs
to be taken that the list passed in are not empty, as these
functions are not empty list safe.
clag scan reported various points where this this pattern
could be caught, and this patch fixes the same.
Additionally the following changes are present in this patch,
- Added an explicit op_ret setting in error case in the
macro MAKE_INODE_HANDLE to address another clang issue reported
- Minor refactoring of some functions in quota code, to address
possible allocation failures in certain functions (which in turn
cause possible empty lists to be passed around)
Change-Id: I1e761a8d218708f714effb56fa643df2a3ea2cc7
Updates: bz#1622665
Signed-off-by: ShyamsundarR <srangana@redhat.com>
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/client/src/client-lk.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/xlators/protocol/client/src/client-lk.c b/xlators/protocol/client/src/client-lk.c index 01613b7ab66..679e1982f49 100644 --- a/xlators/protocol/client/src/client-lk.c +++ b/xlators/protocol/client/src/client-lk.c @@ -360,10 +360,12 @@ delete_granted_locks_owner(fd_t *fd, gf_lkowner_t *owner) pthread_spin_unlock(&conf->fd_lock); - list_for_each_entry_safe(lock, tmp, &delete_list, list) - { - list_del_init(&lock->list); - destroy_client_lock(lock); + if (!list_empty(&delete_list)) { + list_for_each_entry_safe(lock, tmp, &delete_list, list) + { + list_del_init(&lock->list); + destroy_client_lock(lock); + } } /* FIXME: Need to actually print the locks instead of count */ |