lkml.org 
[lkml]   [2017]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [patch] samples/bpf: silence shift wrapping warning
Date
From: Alexei Starovoitov
> Sent: 22 January 2017 22:51
> On Sat, Jan 21, 2017 at 07:51:43AM +0300, Dan Carpenter wrote:
> > max_key is a value in the 0-63 range, so on 32 bit systems the shift
> > could wrap.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> Looks fine. I think 'net-next' is ok.
>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
>
> > diff --git a/samples/bpf/lwt_len_hist_user.c b/samples/bpf/lwt_len_hist_user.c
> > index ec8f3bb..bd06eef 100644
> > --- a/samples/bpf/lwt_len_hist_user.c
> > +++ b/samples/bpf/lwt_len_hist_user.c
> > @@ -68,7 +68,7 @@ int main(int argc, char **argv)
> > for (i = 1; i <= max_key + 1; i++) {
> > stars(starstr, data[i - 1], max_value, MAX_STARS);
> > printf("%8ld -> %-8ld : %-8ld |%-*s|\n",
> > - (1l << i) >> 1, (1l << i) - 1, data[i - 1],
> > + (1ULL << i) >> 1, (1ULL << i) - 1, data[i - 1],
> > MAX_STARS, starstr);
> > }

The format effectors are wrong on 32bit systems.

David

\
 
 \ /
  Last update: 2017-01-25 12:09    [W:0.133 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site