New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crush: silence warning from -Woverflow #16329

Merged
merged 1 commit into from Jul 17, 2017

Conversation

Projects
None yet
4 participants
@joscollin
Member

joscollin commented Jul 14, 2017

The following warning appears during build:

ceph/src/crush/CrushWrapper.cc: In member function ‘int32_t CrushWrapper::_alloc_class_id() const’:
ceph/src/crush/CrushWrapper.cc:1322:56: warning: integer overflow in expression [-Woverflow]
   uint32_t upperlimit = numeric_limits<int32_t>::max() + 1;
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~

This can also be fixed by:

   uint32_t upperlimit = numeric_limits<int32_t>::max();
   upperlimit++;

Signed-off-by: Jos Collin jcollin@redhat.com

@joscollin joscollin requested a review from xiexingguo Jul 14, 2017

@xiexingguo

This comment has been minimized.

Member

xiexingguo commented Jul 14, 2017

uint32_t upperlimit = numeric_limits<int32_t>::max(); upperlimit++;

Thanks, but I think the above change is the right fix, as numeric_limits<int32_t>::max() should be a valid (and reachable) value.

crush: silence warning from -Woverflow
The following warning appears during build:
ceph/src/crush/CrushWrapper.cc: In member function ‘int32_t CrushWrapper::_alloc_class_id() const’:
ceph/src/crush/CrushWrapper.cc:1322:56: warning: integer overflow in expression [-Woverflow]
   uint32_t upperlimit = numeric_limits<int32_t>::max() + 1;
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~

Signed-off-by: Jos Collin <jcollin@redhat.com>
@joscollin

This comment has been minimized.

Member

joscollin commented Jul 14, 2017

@xiexingguo Done. Please review. Thanks.

@liewegas liewegas merged commit 0be22af into ceph:master Jul 17, 2017

4 checks passed

Signed-off-by all commits in this PR are signed
Details
Unmodified Submodules submodules for project are unmodified
Details
make check make check succeeded
Details
make check (arm64) make check succeeded
Details

@joscollin joscollin deleted the joscollin:wip-cleanup-crush-warning branch Jul 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment