[PATCH 1/9] virNetDevParseMcast: Avoid magic constant

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

 



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@xxxxxxxxxx>
---
 src/util/virnetdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 1e20789..13d0f23 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -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);
 
-- 
2.4.6

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