[1/2] batctl: Fix bisecting of OGMs with 32bit seqno

Message ID 1290462354-17246-1-git-send-email-linus.luessing@ascom.ch (mailing list archive)
State Superseded, archived
Headers

Commit Message

Linus Lüssing Nov. 22, 2010, 9:45 p.m. UTC
  This patch increases the size of the seqno variable for bisect and now
uses UINT32_MAX for format checking. To be consistent, also "255"s got
substituted by UINT8_MAX

Signed-off-by: Linus Lüssing <linus.luessing@ascom.ch>
---
 bisect.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
  

Comments

Marek Lindner Nov. 22, 2010, 11:44 p.m. UTC | #1
On Monday 22 November 2010 22:45:53 Linus Lüssing wrote:
> -static int seqno_event_new(char *iface_addr, char *orig, char
> *prev_sender, char *neigh, int seqno, int tq, int ttl) +static int
> seqno_event_new(char *iface_addr, char *orig, char *prev_sender, char
> *neigh, int64_t seqno, int tq, int ttl)

Didn't you forget to adjust the seqno size in the seqno_event and seqno_trace 
struct ? Simply declaring it 64bit in the function header won't do much good 
...

Regards,
Marek
  
Linus Lüssing Nov. 23, 2010, 9:50 a.m. UTC | #2
On Tue, Nov 23, 2010 at 12:44:57AM +0100, Marek Lindner wrote:
> On Monday 22 November 2010 22:45:53 Linus Lüssing wrote:
> > -static int seqno_event_new(char *iface_addr, char *orig, char
> > *prev_sender, char *neigh, int seqno, int tq, int ttl) +static int
> > seqno_event_new(char *iface_addr, char *orig, char *prev_sender, char
> > *neigh, int64_t seqno, int tq, int ttl)
> 
> Didn't you forget to adjust the seqno size in the seqno_event and seqno_trace 
> struct ? Simply declaring it 64bit in the function header won't do much good 
> ...
> 
> Regards,
> Marek
>
Urgh, just noticed, that there seem to be even more places that
need to be modified. E.g. all those seqno_min and seqno_max
occurences or strtol probably needs to be stroll for the seqno,
too. Using int64_t for any seqno(_min/max) occurence probably
won't be sufficient either, as then printf()s for int64_t (even
with %lld) won't be so nice, I guess.

Do you think using long long instead of ints for the seqnos is ok
(without any int64_t usage), hoping that on every architecture a
long long will be at least 8 Bytes large?

Cheers, Linus
  
Linus Lüssing Nov. 23, 2010, 12:13 p.m. UTC | #3
Ok, this is the second version, let me know what you think it about it.

Cheers, Linus
  
Marek Lindner Nov. 28, 2010, 4:15 p.m. UTC | #4
On Tuesday 23 November 2010 13:13:17 Linus Lüssing wrote:
> Ok, this is the second version, let me know what you think it about it.

Applied in revision 1881-1883.

Thanks,
Marek
  

Patch

diff --git a/bisect.c b/bisect.c
index b7d8969..ee9e2f1 100644
--- a/bisect.c
+++ b/bisect.c
@@ -385,7 +385,7 @@  err:
 	return 0;
 }
 
-static int seqno_event_new(char *iface_addr, char *orig, char *prev_sender, char *neigh, int seqno, int tq, int ttl)
+static int seqno_event_new(char *iface_addr, char *orig, char *prev_sender, char *neigh, int64_t seqno, int tq, int ttl)
 {
 	struct bat_node *orig_node, *neigh_node, *prev_sender_node;
 	struct orig_event *orig_event;
@@ -406,17 +406,17 @@  static int seqno_event_new(char *iface_addr, char *orig, char *prev_sender, char
 		goto err;
 	}
 
-	if ((seqno < 0) || (seqno > 65535)) {
-		fprintf(stderr, "Invalid sequence number found (%i) - skipping", seqno);
+	if ((seqno < 0) || (seqno > UINT32_MAX)) {
+		fprintf(stderr, "Invalid sequence number found (%lli) - skipping", seqno);
 		goto err;
 	}
 
-	if ((tq < 0) || (tq > 255)) {
+	if ((tq < 0) || (tq > UINT8_MAX)) {
 		fprintf(stderr, "Invalid tq value found (%i) - skipping", tq);
 		goto err;
 	}
 
-	if ((ttl < 0) || (ttl > 255)) {
+	if ((ttl < 0) || (ttl > UINT8_MAX)) {
 		fprintf(stderr, "Invalid ttl value found (%i) - skipping", ttl);
 		goto err;
 	}