lkml.org 
[lkml]   [2018]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH][next] afs: fix integer overflow when shifting 1 more than 32 places
Date
Colin King <colin.king@canonical.com> wrote:

> Shifting 1 (a 32 bit signed int) more than 32 places will overflow
> the int, so explicitly use 1ULL to avoid this overflow.
> ...
> - mask = (1 << nr_slots) - 1;
> + mask = (1ULL << nr_slots) - 1;

nr_slots cannot be larger than 9, so what I wrote is actually fine and is more
efficient on a 32-bit machine.

David

\
 
 \ /
  Last update: 2018-04-11 15:40    [W:0.062 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site