[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] nwfilter: Fix return value of virNWFilterHashTablePut



In libvirt it is common to return value <0 on error not vice versa.
---
 src/conf/nwfilter_params.c             |   16 ++++++++--------
 src/nwfilter/nwfilter_gentech_driver.c |    4 ++--
 src/nwfilter/nwfilter_learnipaddr.c    |    2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index 12c6524..ba41972 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -490,7 +490,7 @@ hashDataFree(void *payload, const void *name ATTRIBUTE_UNUSED)
  * @val: The value associated with the key
  * @freeName: Whether the name must be freed on table destruction
  *
- * Returns 0 on success, 1 on failure.
+ * Returns 0 on success, -1 on failure.
  *
  * Put an entry into the hashmap replacing and freeing an existing entry
  * if one existed.
@@ -505,11 +505,11 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table,
         if (copyName) {
             name = strdup(name);
             if (!name)
-                return 1;
+                return -1;
 
             if (VIR_REALLOC_N(table->names, table->nNames + 1) < 0) {
                 VIR_FREE(name);
-                return 1;
+                return -1;
             }
             table->names[table->nNames++] = (char *)name;
         }
@@ -519,11 +519,11 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table,
                 VIR_FREE(name);
                 table->nNames--;
             }
-            return 1;
+            return -1;
         }
     } else {
         if (virHashUpdateEntry(table->hashTable, name, val) != 0) {
-            return 1;
+            return -1;
         }
     }
     return 0;
@@ -614,7 +614,7 @@ addToTable(void *payload, const void *name, void *data)
         return;
     }
 
-    if (virNWFilterHashTablePut(atts->target, (const char *)name, val, 1) != 0) {
+    if (virNWFilterHashTablePut(atts->target, (const char *)name, val, 1) < 0) {
         virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Could not put variable '%s' into hashmap"),
                                (const char *)name);
@@ -640,7 +640,7 @@ virNWFilterHashTablePutAll(virNWFilterHashTablePtr src,
     return 0;
 
 err_exit:
-    return 1;
+    return -1;
 }
 
 
@@ -700,7 +700,7 @@ virNWFilterParseParamAttributes(xmlNodePtr cur)
                         value = virNWFilterParseVarValue(val);
                         if (!value)
                             goto skip_entry;
-                        if (virNWFilterHashTablePut(table, nam, value, 1))
+                        if (virNWFilterHashTablePut(table, nam, value, 1) < 0)
                             goto err_exit;
                     }
                     value = NULL;
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 84a959b..946ed14 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -343,10 +343,10 @@ virNWFilterCreateVarsFrom(virNWFilterHashTablePtr vars1,
         return NULL;
     }
 
-    if (virNWFilterHashTablePutAll(vars1, res))
+    if (virNWFilterHashTablePutAll(vars1, res) < 0)
         goto err_exit;
 
-    if (virNWFilterHashTablePutAll(vars2, res))
+    if (virNWFilterHashTablePutAll(vars2, res) < 0)
         goto err_exit;
 
     return res;
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 2e373a6..425e8a2 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -800,7 +800,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
         goto err_free_req;
     }
 
-    if (virNWFilterHashTablePutAll(filterparams, ht))
+    if (virNWFilterHashTablePutAll(filterparams, ht) < 0)
         goto err_free_ht;
 
     req->filtername = strdup(filtername);
-- 
1.7.3.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]