All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] samples/bpf: silence shift wrapping warning
@ 2017-01-21  4:51 ` Dan Carpenter
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2017-01-21  4:51 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Thomas Graf
  Cc: Alexei Starovoitov, Joe Stringer, David S. Miller, linux-kernel,
	kernel-janitors

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>

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);
 	}
 

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-01-25 11:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-21  4:51 [patch] samples/bpf: silence shift wrapping warning Dan Carpenter
2017-01-21  4:51 ` Dan Carpenter
2017-01-22 22:51 ` Alexei Starovoitov
2017-01-22 22:51   ` Alexei Starovoitov
2017-01-23 13:27   ` Arnaldo Carvalho de Melo
2017-01-23 13:27     ` Arnaldo Carvalho de Melo
2017-01-25 11:08   ` David Laight
2017-01-24  6:44 ` Alexei Starovoitov
2017-01-24  6:44   ` Alexei Starovoitov
2017-01-24  8:46   ` Dan Carpenter
2017-01-24  8:46     ` Dan Carpenter
2017-01-24 16:02   ` Arnaldo Carvalho de Melo
2017-01-24 16:02     ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.