summaryrefslogtreecommitdiffstats
path: root/xlators/performance/open-behind
diff options
context:
space:
mode:
authorShyamsundarR <srangana@redhat.com>2018-12-12 16:45:09 -0500
committerAmar Tumballi <amarts@redhat.com>2018-12-14 04:33:15 +0000
commitbfe2b5e1530efd364af7a175c8a1c89bc4cab0bb (patch)
tree2030f52c92661f8d285c9905481787dced506a91 /xlators/performance/open-behind
parent8293d21280fd6ddfc9bb54068cf87794fc6be207 (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/performance/open-behind')
-rw-r--r--xlators/performance/open-behind/src/open-behind.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c
index a4302a776c5..268c7176f02 100644
--- a/xlators/performance/open-behind/src/open-behind.c
+++ b/xlators/performance/open-behind/src/open-behind.c
@@ -347,12 +347,14 @@ ob_inode_wake(xlator_t *this, struct list_head *ob_fds)
ob_fd_t *ob_fd = NULL, *tmp = NULL;
fd_t *fd = NULL;
- list_for_each_entry_safe(ob_fd, tmp, ob_fds, ob_fds_on_inode)
- {
- ob_fd_wake(this, ob_fd->fd, ob_fd);
- fd = ob_fd->fd;
- ob_fd_free(ob_fd);
- fd_unref(fd);
+ if (!list_empty(ob_fds)) {
+ list_for_each_entry_safe(ob_fd, tmp, ob_fds, ob_fds_on_inode)
+ {
+ ob_fd_wake(this, ob_fd->fd, ob_fd);
+ fd = ob_fd->fd;
+ ob_fd_free(ob_fd);
+ fd_unref(fd);
+ }
}
}
@@ -381,9 +383,7 @@ open_all_pending_fds_and_resume(xlator_t *this, inode_t *inode,
ob_fd_t *ob_fd = NULL, *tmp = NULL;
gf_boolean_t was_open_in_progress = _gf_false;
gf_boolean_t wait_for_open = _gf_false;
- struct list_head ob_fds = {
- 0,
- };
+ struct list_head ob_fds;
ob_inode = ob_inode_get(this, inode);
if (ob_inode == NULL)