Skip to contentSkip to conversation

batman-adv: Avoid rounding issues for local hna timeout

PATCH Applied Linus Lüssing 2 participants 2 messages Jun 19, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman-adv: Avoid rounding issues for local hna timeout

With the current default values, this patch is not critical, as LOCAL_HNA_TIMEOUT is a multiple of 1000 anyway. However, if someone would like to change this #define, the person could have some unexpected rounding issues. Therefore doing the multiplication before the division now.

---
 translation-table.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
translation-table.c +1 -1
index 619a9a8..cf37cc4 100644
@@ -259,7 +259,7 @@ static void hna_local_purge(struct work_struct *work)
 		hna_local_entry = hashit.bucket->data;
 
 		timeout = hna_local_entry->last_seen +
-			((LOCAL_HNA_TIMEOUT / 1000) * HZ);
+			((LOCAL_HNA_TIMEOUT * HZ) / 1000);
 		if ((!hna_local_entry->never_purge) &&
 		    time_after(jiffies, timeout))
 			hna_local_del(hna_local_entry, "address timed out");
Signature · 1 line
1.7.1
#1 lore raw

Hey Linus,

thanks, applied in r1710.

Cheers,
Simon

Quoted 28 lines · Linus Lüssing

With the current default values, this patch is not critical, as LOCAL_HNA_TIMEOUT is a multiple of 1000 anyway. However, if someone would like to change this #define, the person could have some unexpected rounding issues. Therefore doing the multiplication before the division now.

---
 translation-table.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
translation-table.c +1 -1
index 619a9a8..cf37cc4 100644
@@ -259,7 +259,7 @@ static void hna_local_purge(struct work_struct *work)
 		hna_local_entry = hashit.bucket->data;
 
 		timeout = hna_local_entry->last_seen +
-			((LOCAL_HNA_TIMEOUT / 1000) * HZ);
+			((LOCAL_HNA_TIMEOUT * HZ) / 1000);
 		if ((!hna_local_entry->never_purge) &&
 		    time_after(jiffies, timeout))
 			hna_local_del(hna_local_entry, "address timed out");
Signature · 1 line
1.7.1