]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virHashAddEntry: Report error on duplicate key
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 17 Aug 2015 19:01:07 +0000 (21:01 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 17 Aug 2015 21:34:08 +0000 (23:34 +0200)
If this function 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@redhat.com>
src/util/virhash.c

index 77196c927c98aaca530e3bb532a7f463d524278a..bc90c449cd7d10ce7f68cfcb8c22811a34958176 100644 (file)
@@ -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;
             }
         }