[PATCH v2 2/3] virHashAddEntry: Report error on duplicate key

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

 



This function, when fails the error message is reported only in
some cases (e.g. OOM) but in some it's not (e.g. duplicate key).
This fact is painful and we should either not report error at all
or report the error in all possible cases. I vote for the latter.
Unfortunately, since the key may be an arbitrary value (not
necessarily a string) we can't report it in the error message.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/util/virhash.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/virhash.c b/src/util/virhash.c
index 77196c9..bc90c44 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -353,6 +353,8 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const void *name,
                 entry->payload = userdata;
                 return 0;
             } else {
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("Duplicate key"));
                 return -1;
             }
         }
-- 
2.4.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]