Message ID | 1792155.rcBUdH4UUQ@bentobox |
---|---|
State | RFC, archived |
Commit | 789b846af6a9471982b181687a1cba8dc996b269 |
Headers | show |
On Mon, Feb 15, 2016 at 01:35:31PM +0100, Sven Eckelmann wrote: > It is easy to see that > > batadv_ogm_packet::tq (u8 255) * > tq_own (u8 255) * > tq_asym_penalty (int 134) * > tq_iface_penalty (int 255) > > is outside the range of an signed integer (32 bit). The maximum seen > here is 255 for each entry. So should tq_iface_penalty + > tq_iface_penalty, inv_asym_penalty be changed to unsigned int? Given that all these values are in the TQ domain I'd say that they should all be positive all the time, therefore there is no gain in using a signed variable here. Marek, what do you think ? Cheers,
--- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -1147,9 +1147,10 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node, u8 total_count; u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own; unsigned int neigh_rq_inv_cube, neigh_rq_max_cube; - int tq_asym_penalty, inv_asym_penalty, if_num, ret = 0; + int if_num, ret = 0; + unsigned int tq_asym_penalty, inv_asym_penalty; unsigned int combined_tq; - int tq_iface_penalty; + unsigned int tq_iface_penalty; /* find corresponding one hop neighbor */ rcu_read_lock();