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

Martin Kletzander mkletzan at redhat.com
Mon Aug 17 21:27:12 UTC 2015


On Mon, Aug 17, 2015 at 11:16:28PM +0200, Michal Privoznik wrote:
>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).

The sentence could be reworded.

>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 at redhat.com>
>---
> 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 at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150817/c5338732/attachment-0001.sig>


More information about the libvir-list mailing list