[ovs-discuss] Assignment is done from int->short

Ben Pfaff blp at nicira.com
Tue Sep 15 20:35:02 UTC 2015


On Wed, Sep 16, 2015 at 01:38:36AM +0530, neeraj mehta wrote:
> I was looking a the code in multipath.c file. In function algorithm_hrw( )
> assignment is done from int->short (best_link = link). It might lead to
> bit truncation. Following is the code snippet for your reference.
> 
> uint32_t best_weight;
>     uint16_t best_link;
>     unsigned int link;
> 
>     best_link = 0;
>     best_weight = hash_2words(hash, 0);
>     for (link = 1; link < n_links; link++) {
>         uint32_t weight = hash_2words(hash, link);
>         if (weight > best_weight) {
>             best_link = link;
>             best_weight = weight;

n_links is always less than or equal to 64, so it's not a problem.



More information about the discuss mailing list