In C, it is undefined to shift an N-bit value by N. This fixes the problem in find_batch() for the case where i == 0.
Found by Coverity. Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763098&defectInstanceId=4304031&mergedDefectId=68209 Signed-off-by: Ben Pfaff <b...@ovn.org> --- tests/test-cmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test-cmap.c b/tests/test-cmap.c index e159a164f315..2c6fa89eb775 100644 --- a/tests/test-cmap.c +++ b/tests/test-cmap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2013, 2014, 2016 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2013, 2014, 2016, 2017 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -412,7 +412,6 @@ find_batch(const struct cmap *cmap, const int value) { size_t i, ret; const size_t end = MIN(n_batch, n_elems - value); - unsigned long map = ~0; uint32_t hashes[N_BATCH_MAX]; const struct cmap_node *nodes[N_BATCH_MAX]; @@ -431,7 +430,7 @@ find_batch(const struct cmap *cmap, const int value) ret = i; - map >>= BITMAP_ULONG_BITS - i; /* Clear excess bits. */ + unsigned long map = i ? ~0UL >> (BITMAP_ULONG_BITS - i) : 0; map = cmap_find_batch(cmap, map, hashes, nodes); ULLONG_FOR_EACH_1(i, map) { -- 2.10.2 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev