[PATCH] check return values of virBufferTrim

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

 



Just to silence Coverity:

Event check_return:
Calling function "virBufferTrim(virBufferPtr, char const *, int)"
without checking return value (as is done elsewhere 5 out of 6 times).
---
 src/node_device/node_device_udev.c | 5 ++---
 src/rpc/virnetsshsession.c         | 3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index bb58415..a37989a 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -370,9 +370,8 @@ udevLogFunction(struct udev *udev ATTRIBUTE_UNUSED,
     const char *format = NULL;
 
     virBufferAdd(&buf, fmt, -1);
-    virBufferTrim(&buf, "\n", -1);
-
-    format = virBufferContentAndReset(&buf);
+    if (virBufferTrim(&buf, "\n", -1) >= 0)
+        format = virBufferContentAndReset(&buf);
 
     virLogVMessage(VIR_LOG_FROM_LIBRARY,
                    virLogPriorityFromSyslog(priority),
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index b6aedc8..2299871 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -362,9 +362,8 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
              * we have to use a *MAGIC* constant. */
             for (i = 0; i < 16; i++)
                     virBufferAsprintf(&buff, "%02hhX:", keyhash[i]);
-            virBufferTrim(&buff, ":", 1);
 
-            if (virBufferError(&buff) != 0) {
+            if (virBufferTrim(&buff, ":", 1) < 0) {
                 virReportOOMError();
                 return -1;
             }
-- 
1.8.1.5

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