]> xenbits.xensource.com Git - libvirt.git/commitdiff
virNetDevParseMcast: Avoid magic constant
authorMichal Privoznik <mprivozn@redhat.com>
Sat, 1 Aug 2015 05:43:58 +0000 (07:43 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 11 Aug 2015 14:10:32 +0000 (16:10 +0200)
There is no guarantee that an enum start it mapped onto a value
of zero. However, we are guaranteed that enum items are
consecutive integers. Moreover, it's a pity to define an enum to
avoid using magical constants but then using them anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdev.c

index 1e20789b7bf16cc36ed4934667b4f5490e686637..13d0f235ae690a498c23f9a2deed1828dfca77e2 100644 (file)
@@ -2708,7 +2708,7 @@ static int virNetDevParseMcast(char *buf, virNetDevMcastEntryPtr mcast)
     char *saveptr;
     char *endptr;
 
-    for (ifindex = 0, next = buf; ifindex < VIR_MCAST_TYPE_LAST; ifindex++,
+    for (ifindex = VIR_MCAST_TYPE_INDEX_TOKEN, next = buf; ifindex < VIR_MCAST_TYPE_LAST; ifindex++,
          next = NULL) {
         token = strtok_r(next, VIR_MCAST_TOKEN_DELIMS, &saveptr);