]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common/strtol.cc: fix the coverity warnings 7967/head
authorKefu Chai <kchai@redhat.com>
Tue, 8 Mar 2016 05:01:13 +0000 (13:01 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 8 Mar 2016 12:57:45 +0000 (20:57 +0800)
commit92628f5699890bfc6db25084ba01be96e0222a5d
tree0ac173ef9efc2530c81d704e495e4d29758af3b0
parent6018ccd6c4405c6014c65dd92660898adbc29c03
common/strtol.cc: fix the coverity warnings

* promote the compared types properly to address the signed/unsigned
  comparison warnings. this also fixes the potential problems of
  slicing a compared type down to a "smaller" type before the
  comparison.
* check for the width of resulting type and shift bits caused by SI
  prefix to avoid the -Wshift-count-overflow warnings. this again
  is a potential issue, as shifting n bits of an integer of m bits
  width, where n >= m, leads to undefined behaviour.
* add a test for the 2nd fixed issue.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/strtol.cc
src/test/strtol.cc