All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Cc: Marek Lindner <lindner_marek@yahoo.de>
Subject: Re: [B.A.T.M.A.N.] [RFC 2/5] batman-adv: ELP - creating neighbor structures, updating LQs
Date: Fri, 23 Mar 2012 21:52:12 +0100	[thread overview]
Message-ID: <20120323205212.GF5662@lunn.ch> (raw)
In-Reply-To: <1332453075-27999-2-git-send-email-lindner_marek@yahoo.de>

> +/* extract my own tq to neighbor from the elp packet */
> +static uint8_t bat_v_elp_fetch_tq(uint8_t *my_iface_addr,
> +				  struct batman_elp_packet *elp_packet,
> +				  int elp_packet_len)
> +{
> +	struct elp_neigh_entry *elp_neigh_entry;
> +	uint8_t tq = 0;
> +	int i;
> +
> +	elp_neigh_entry = (struct elp_neigh_entry *)(elp_packet + 1);
> +	elp_packet_len -= BATMAN_ELP_HLEN;
> +
> +	for (i = 0; i < elp_packet->num_neighbors; i++) {
> +		if (!compare_eth(my_iface_addr, elp_neigh_entry->addr))
> +			goto next;
> +
> +		tq = elp_neigh_entry->rq;
> +		break;
> +
> +	next:
> +		elp_packet_len -= sizeof(struct elp_neigh_entry);
> +		if (elp_packet_len < 0)
> +			break;
> +
> +		elp_neigh_entry++;
> +	}

Hi Marek

I'm personally not a fan of using goto like this. Reminds me of BASIC.

Could this be changed? Maybe first validate elp_packet->num_neighbors
matches the packet length, and then skip elp_packet_len check in each
iteration of the loop. A normal if then else should then be possible.

  Thanks
	Andrew	  

  reply	other threads:[~2012-03-23 20:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22 21:50 [B.A.T.M.A.N.] [RFC] ELP Marek Lindner
2012-03-22 21:51 ` [B.A.T.M.A.N.] [RFC 1/5] batman-adv: ELP - adding basic infrastructure Marek Lindner
2012-03-22 21:51   ` [B.A.T.M.A.N.] [RFC 2/5] batman-adv: ELP - creating neighbor structures, updating LQs Marek Lindner
2012-03-23 20:52     ` Andrew Lunn [this message]
2012-04-05 19:59       ` Marek Lindner
2012-03-23 21:22     ` Andrew Lunn
2012-03-24  8:14       ` Antonio Quartulli
2012-03-24 20:21         ` Andrew Lunn
2012-04-05 20:11           ` Marek Lindner
2012-04-06  7:17             ` Andrew Lunn
2012-04-06  8:18               ` Marek Lindner
2012-04-05 20:08       ` Marek Lindner
2012-03-22 21:51   ` [B.A.T.M.A.N.] [RFC 3/5] batman-adv: ELP - exporting neighbor list via debugfs Marek Lindner
2012-03-22 21:51   ` [B.A.T.M.A.N.] [RFC 4/5] batman-adv: ELP - adding sysfs parameter for elp interval Marek Lindner
2012-03-22 21:51   ` [B.A.T.M.A.N.] [RFC 5/5] batman-adv: ELP - add configurable minimum ELP packet length (def: 300B) Marek Lindner
2012-03-24 20:39     ` Andrew Lunn
2012-04-05 20:19       ` Marek Lindner
2012-03-23  6:41   ` [B.A.T.M.A.N.] [RFC 1/5] batman-adv: ELP - adding basic infrastructure Andrew Lunn
2012-03-23  6:50   ` Andrew Lunn
2012-04-05 20:21     ` Marek Lindner
2012-03-23  6:32 ` [B.A.T.M.A.N.] [RFC] ELP Andrew Lunn
2012-03-23  7:50   ` Antonio Quartulli
2012-04-05 20:30   ` Marek Lindner
2012-04-06  9:13     ` Andrew Lunn
2012-04-06 16:57       ` dan
2012-04-06 17:19         ` Andrew Lunn
2012-04-06 18:04           ` dan
2012-03-23  6:34 ` Andrew Lunn
2012-03-23  7:51   ` Antonio Quartulli
2012-04-05 20:30   ` Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120323205212.GF5662@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=lindner_marek@yahoo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.