By using memset instead of a small for loop the code becomes
a lot more compact without altering its behaviour. I think this is a good
thing :)

Index: heartbeat-ipv6addr/resources/OCF/IPv6addr.c
===================================================================
--- heartbeat-ipv6addr.orig/resources/OCF/IPv6addr.c    2007-04-13 
15:45:43.000000000 +0900
+++ heartbeat-ipv6addr/resources/OCF/IPv6addr.c 2007-04-13 15:45:43.000000000 
+0900
@@ -476,17 +476,13 @@
                inet_pton(AF_INET6, addr6, &addr);
 
                /* Make the mask based on prefix length */
-               for (i = 0; i < 16; i++) {
-                       mask.s6_addr[i] = 0xff;
-               }
-               if (plen < 128) {
-                       n = plen / 8;
-                       for (i = 15; i>n; i--) {
-                               mask.s6_addr[i] = 0x0;
-                       }
-                       s = 8 - plen % 8;
-                       mask.s6_addr[n] <<= s;
-               }
+               memset(mask.s6_addr, 0xff, 16);
+               if (plen < 128) {
+                       n = plen / 8;
+                       memset(mask.s6_addr + n + 1, 0, 15 - n);
+                       s = 8 - plen % 8;
+                       mask.s6_addr[n] = 0xff << s;
+               }
 
                /* compare addr and addr_target */
                same = TRUE;

--

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/

_______________________________________________________
Linux-HA-Dev: [EMAIL PROTECTED]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to