]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virSystemdActivationInitFromNames: Replace virStringSplit by g_strsplit
authorPeter Krempa <pkrempa@redhat.com>
Thu, 1 Apr 2021 13:35:39 +0000 (15:35 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Apr 2021 13:55:10 +0000 (15:55 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virsystemd.c

index cf22edaa0abc38f0425ca23e4e2d3cb5824593b9..718d24dfc54d9c1f91a7893b4ef0fc310406d7d5 100644 (file)
@@ -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;
     }