btrfs-progs: Fix undefined behavior in radix-tree.c.
authorAdam Buchbinder <abuchbinder@google.com>
Fri, 13 Jun 2014 21:18:50 +0000 (14:18 -0700)
committerDavid Sterba <dsterba@suse.cz>
Fri, 22 Aug 2014 12:39:34 +0000 (14:39 +0200)
commitc9951e2269fb3e3db1546d8627bc34a414ed13bd
tree97508a459884844af1a2095131a8cdf227808e02
parent5351d29eef4c26e9ffabc2bae0433407953fd8e0
btrfs-progs: Fix undefined behavior in radix-tree.c.

When running with UndefinedBehaviorSanitizer, the tests produce the following
error:

  radix-tree.c:836:30: runtime error: shift exponent 18446744073709551613
  is too large for 64-bit type 'unsigned long'

(That's a negative shift exponent represented as an unsigned long.)

Even though the value is discarded in those cases, it's still undefined
behavior; see the C99 standard, section 6.5.7, paragraph three: "If the
value of the right operand is negative [...] the behavior is undefined."

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
radix-tree.c