From: Michal Privoznik Date: Mon, 17 Aug 2015 19:01:07 +0000 (+0200) Subject: virHashAddEntry: Report error on duplicate key X-Git-Tag: v1.2.19-rc1~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dc2587224cb773a0727d9e893ce64c283a8d30e;p=thirdparty%2Flibvirt.git virHashAddEntry: Report error on duplicate key 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 --- diff --git a/src/util/virhash.c b/src/util/virhash.c index 77196c927c..bc90c449cd 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; } }