{
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 */
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));
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;
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