[PATCH 5/5] Shift the for loop over matched vars by one

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

 



Instead of adding one to the iterator on every use.
---
 src/util/vircommand.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 7d13828..a21a88b 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -2845,10 +2845,10 @@ virCommandRunRegex(virCommandPtr cmd,
             if (regexec(&reg[i], p, nvars[i]+1, vars, 0) != 0)
                 break;
 
-            for (j = 0; j < nvars[i]; j++) {
-                /* NB vars[0] is the full pattern, so we offset j by 1 */
-                if (VIR_STRNDUP(groups[ngroup++], p + vars[j+1].rm_so,
-                                vars[j+1].rm_eo - vars[j+1].rm_so) < 0)
+            /* NB vars[0] is the full pattern, so we offset j by 1 */
+            for (j = 1; j <= nvars[i]; j++) {
+                if (VIR_STRNDUP(groups[ngroup++], p + vars[j].rm_so,
+                                vars[j].rm_eo - vars[j].rm_so) < 0)
                     goto cleanup;
             }
 
-- 
1.8.3.2

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