[riot-notifications] [RIOT-OS/RIOT] gnrc_ipv6_nib/arsm: ensure proper int width in backoff calculation (#10369)

Cenk Gündoğan notifications at github.com
Tue Jan 29 14:57:31 CET 2019


cgundogan commented on this pull request.



> @@ -519,7 +519,7 @@ static inline uint32_t _exp_backoff_retrans_timer(uint8_t ns_sent,
 
     /* backoff according to  https://tools.ietf.org/html/rfc7048 with
      * BACKOFF_MULTIPLE == 2 */
-    tmp = ((1 << ns_sent) * retrans_timer * tmp) / US_PER_MS;
+    tmp = ((((uint32_t) 1) << ns_sent) * retrans_timer * tmp) / US_PER_MS;

IMO there's no need to shift an `uint32_t` if it's casted to 64 bits anyway ..
```c
    uint32_t res = (uint32_t)((((uint64_t) 1) << ns_sent) * retrans_timer * factor) / US_PER_MS);
```
would do quite as good ..

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10369#discussion_r251842517
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190129/e35e1920/attachment.html>


More information about the notifications mailing list