Fix some Coverity warnings
Stefan Metzmacher
metze at samba.org
Tue Jul 31 07:52:12 UTC 2018
Hi,
please review and push the attached patches.
Thanks!
metze
-------------- next part --------------
From d36024039eea0bc63046c9415fe9376b0d94187e Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Tue, 31 Jul 2018 09:40:20 +0200
Subject: [PATCH 1/3] pthreadpool: ignore the return value of poll(NULL, 0UL,
1)
Otherwise Coverity reports this:
CID 1438160: (CHECKED_RETURN)
Calling "poll(NULL, 0UL, 1)" without checking return value. This
library function may fail and return an error code.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
lib/pthreadpool/pthreadpool_tevent.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/pthreadpool/pthreadpool_tevent.c b/lib/pthreadpool/pthreadpool_tevent.c
index b4a9786f231a..7088202d97ca 100644
--- a/lib/pthreadpool/pthreadpool_tevent.c
+++ b/lib/pthreadpool/pthreadpool_tevent.c
@@ -873,7 +873,7 @@ static void pthreadpool_tevent_job_orphan(struct pthreadpool_tevent_job *job)
*/
PTHREAD_TEVENT_JOB_THREAD_FENCE(job);
while (job->needs_fence.wrapper) {
- poll(NULL, 0, 1);
+ (void)poll(NULL, 0, 1);
PTHREAD_TEVENT_JOB_THREAD_FENCE(job);
}
job->wrapper = NULL;
@@ -903,7 +903,7 @@ static void pthreadpool_tevent_job_orphan(struct pthreadpool_tevent_job *job)
if (job->needs_fence.signaled) {
break;
}
- poll(NULL, 0, 1);
+ (void)poll(NULL, 0, 1);
PTHREAD_TEVENT_JOB_THREAD_FENCE(job);
}
--
2.17.1
From e0ad099b81eec3a3b29b972899745e2f62527028 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Tue, 31 Jul 2018 09:42:40 +0200
Subject: [PATCH 2/3] pthreadpool: reset monitor_fd after calling
tevent_fd_set_auto_close()
This tries to convince Coverity that we don't have a resource leak:
CID 1438157: (RESOURCE_LEAK)
Handle variable "monitor_fd" going out of scope leaks the handle.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
lib/pthreadpool/pthreadpool_tevent.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/pthreadpool/pthreadpool_tevent.c b/lib/pthreadpool/pthreadpool_tevent.c
index 7088202d97ca..12148f18123b 100644
--- a/lib/pthreadpool/pthreadpool_tevent.c
+++ b/lib/pthreadpool/pthreadpool_tevent.c
@@ -719,6 +719,7 @@ static int pthreadpool_tevent_register_ev(
return ENOMEM;
}
tevent_fd_set_auto_close(glue->fde);
+ monitor_fd = -1;
}
/*
--
2.17.1
From 6c620ebb2a864de594d0513f5b095581e23624d8 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze at samba.org>
Date: Tue, 31 Jul 2018 09:45:00 +0200
Subject: [PATCH 3/3] smb2_query_directory: make 'return true' explicit in
smb2_query_directory_next_entry()
'return req' should do the same as 'return true' for a bool function,
it's implicitly expanded as 'return (req!=NULL)?true:false.
There's no point in that as 'req' is always a valid pointer.
This was most likely just a copy and paste bug.
So we make this explicit now and avoid that Coverity reports this:
CID 1438158: Null pointer dereferences (REVERSE_INULL)
Null-checking "req" suggests that it may be null, but it has already
been dereferenced on all paths leading to the check.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
source3/smbd/smb2_query_directory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c
index 905277908178..f3b61737da79 100644
--- a/source3/smbd/smb2_query_directory.c
+++ b/source3/smbd/smb2_query_directory.c
@@ -718,7 +718,7 @@ last_entry_done:
tevent_req_set_callback(subreq,
smb2_query_directory_waited,
req);
- return req;
+ return true;
}
tevent_req_done(req);
--
2.17.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180731/25b6f4b8/signature.sig>
More information about the samba-technical
mailing list