[Libvirt-cim] [PATCH 01/19] Coverity: Resolve BAD_COMPARE - ActivateFilter()

John Ferlan jferlan at redhat.com
Thu May 16 14:57:36 UTC 2013


Two examples of:

807             thread->id = _BROKER->xft->newThread(lifecycle_thread_native,
808                                                  thread, 0);
809

(1) Event null_misuse:
    Comparing pointer "thread->id" against NULL using anything besides
    == or != is likely to be incorrect.

810             if (thread->id <= 0) {
811                 CU_DEBUG("Error, failed to create new thread.");
812                 error = true;

Resolve this and subsequent use by changing comparison to:

    if (thread->id == NULL) {
---
 src/Virt_ComputerSystemIndication.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c
index 247143c..e9fa0c2 100644
--- a/src/Virt_ComputerSystemIndication.c
+++ b/src/Virt_ComputerSystemIndication.c
@@ -807,7 +807,7 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI *mi,
         thread->id = _BROKER->xft->newThread(lifecycle_thread_native,
                                              thread, 0);
 
-        if (thread->id <= 0) {
+        if (thread->id == NULL) {
             CU_DEBUG("Error, failed to create new thread.");
             error = true;
         }
@@ -1463,7 +1463,7 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI* mi,
         thread->args = args;
         thread->id = _BROKER->xft->newThread(lifecycle_thread, thread, 0);
 
-        if (thread->id <= 0) {
+        if (thread->id == NULL) {
             CU_DEBUG("Error, failed to create new thread.");
             error = true;
         }
-- 
1.8.1.4




More information about the Libvirt-cim mailing list