[PATCH 36/39] virSystemdActivationInitFromNames: Replace virStringSplit by g_strsplit

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

 



While the code invokes the string list length calculation twice, it
happens only on error path, which by itself should never happen.

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

diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index cf22edaa0a..718d24dfc5 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -754,19 +754,18 @@ virSystemdActivationInitFromNames(virSystemdActivationPtr act,
 {
     g_auto(GStrv) fdnamelistptr = NULL;
     char **fdnamelist;
-    size_t nfdnames;
     size_t i;
     int nextfd = STDERR_FILENO + 1;

     VIR_DEBUG("FD names %s", fdnames);

-    if (!(fdnamelistptr = virStringSplitCount(fdnames, ":", 0, &nfdnames)))
+    if (!(fdnamelistptr = g_strsplit(fdnames, ":", 0)))
         goto error;

-    if (nfdnames != nfds) {
+    if (g_strv_length(fdnamelistptr) != nfds) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Expecting %d FD names but got %zu"),
-                       nfds, nfdnames);
+                       _("Expecting %d FD names but got %u"),
+                       nfds, g_strv_length(fdnamelistptr));
         goto error;
     }

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