[PATCH 30/33] util: json: Report non-OOM error on yajl failure

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

 



The yajl library returns a wide range of error codes so reporting OOM on
any failure is wrong. In case the error was really based by memory issue
the error reporting will probably cause an abort anyways. Change the
error message so that we know that it happened in JSON at least.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virjson.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/util/virjson.c b/src/util/virjson.c
index e74b9fca4f..f2a6024db6 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -1943,12 +1943,14 @@ virJSONValueToBuffer(virJSONValuePtr object,
     yajl_gen_config(g, yajl_gen_validate_utf8, 1);

     if (virJSONValueToStringOne(object, g) < 0) {
-        virReportOOMError();
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("failed to convert virJSONValue to yajl data"));
         goto cleanup;
     }

     if (yajl_gen_get_buf(g, &str, &len) != yajl_gen_status_ok) {
-        virReportOOMError();
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                      _("failed to format JSON"));
         goto cleanup;
     }

-- 
2.29.2




[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]

  Powered by Linux