]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Remove unnecessary indexing at some pointers
authorpcarana <pc.moreno2099@gmail.com>
Thu, 21 Mar 2019 15:09:44 +0000 (09:09 -0600)
committerpcarana <pc.moreno2099@gmail.com>
Thu, 21 Mar 2019 15:09:44 +0000 (09:09 -0600)
src/notify.c
src/rtr/pdu_sender.c
src/vrps.c

index bfebd3cb04941a6061cc142d780223a7af51b2c2..25456feb8b748ba75c8ac7444e0661df738dc1aa 100644 (file)
@@ -24,11 +24,10 @@ notify_clients(void)
 {
        struct client *clients, *ptr;
        size_t clients_len;
-       int i, error;
+       int error;
 
        clients_len = client_list(&clients);
-       ptr = clients;
-       for (i = 0; i < clients_len; i++, ptr++) {
+       for (ptr = clients; (ptr - clients) < clients_len; ptr++) {
                /* Send Serial Notify PDU */
                error = send_notify(ptr->fd, ptr->rtr_version);
                /* Error? Log it */
index c60769bcbd17573df2f79fd3390294103abca67d..3cf291ea22d1de35e2e1d473df9ab920f0676e93 100644 (file)
@@ -202,8 +202,8 @@ send_ipv6_prefix_pdu(struct sender_common *common, struct vrp *vrp)
 int
 send_payload_pdus(struct sender_common *common)
 {
-       struct vrp *vrps;
-       unsigned int len, i;
+       struct vrp *vrps, *ptr;
+       unsigned int len;
        int error;
 
        vrps = malloc(sizeof(struct vrp));
@@ -211,15 +211,11 @@ send_payload_pdus(struct sender_common *common)
        if (len == 0)
                goto end;
 
-       for (i = 0; i < len; i++) {
-               /*
-                * TODO (review) Why are you indexing `vrps`? You did not
-                * allocate an array.
-                */
-               if (vrps[i].in_addr_len == INET_ADDRSTRLEN)
-                       error = send_ipv4_prefix_pdu(common, &vrps[i]);
-               else if (vrps[i].in_addr_len == INET6_ADDRSTRLEN)
-                       error = send_ipv6_prefix_pdu(common, &vrps[i]);
+       for (ptr = vrps; (ptr - vrps) < len; ptr++) {
+               if (ptr->in_addr_len == INET_ADDRSTRLEN)
+                       error = send_ipv4_prefix_pdu(common, ptr);
+               else if (ptr->in_addr_len == INET6_ADDRSTRLEN)
+                       error = send_ipv6_prefix_pdu(common, ptr);
                else
                        error = -EINVAL;
 
index ebcbd4d91b0433047dfa59897e28bd95e368867b..8a0ad10995ed14a80f75ca8e123e7bb30c6d4a0a 100644 (file)
@@ -326,10 +326,10 @@ deltas_db_status(u_int32_t *serial)
 static void
 add_vrps_filtered(struct vrps *dst, struct vrps *src)
 {
-       int i;
-       for (i = 0; i < src->len; i++)
-               if (vrp_is_new(dst, &src->array[i]))
-                       vrps_add(dst, &src->array[i]);
+       struct vrp *ptr;
+       for (ptr = src->array; (ptr - src->array) < src->len; ptr++)
+               if (vrp_is_new(dst, ptr))
+                       vrps_add(dst, ptr);
 }
 
 static void