diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-05-31 20:47:59 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-05-31 22:03:22 +0200 |
commit | 4c60697daaecc8be0a00e900ba1b4b62713e43df (patch) | |
tree | c872c47f5d7f8e7941e5a8c378115c404be63523 | |
parent | a77b8b75f015fba74e2553c3cff58fcba298b9ed (diff) |
The return value of std::count_if is guaranteed to be non-negative
...so use o3tl::make_unsigned when comparing it against an expression of
unsigned integer type, instead of casting that expression to a signed type
Change-Id: I487fd04eafbf8c56b8b6bfce579b477d8f34a052
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135206
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
5 files changed, 20 insertions, 15 deletions
diff --git a/slideshow/source/engine/animationnodes/basecontainernode.cxx b/slideshow/source/engine/animationnodes/basecontainernode.cxx index cde434f3d7bd..709f5392ac8a 100644 --- a/slideshow/source/engine/animationnodes/basecontainernode.cxx +++ b/slideshow/source/engine/animationnodes/basecontainernode.cxx @@ -24,6 +24,7 @@ #include <eventqueue.hxx> #include "nodetools.hxx" #include <delayevent.hxx> +#include <o3tl/safeint.hxx> #include <sal/log.hxx> #include <functional> @@ -80,10 +81,10 @@ bool BaseContainerNode::init_children() mnFinishedChildren = 0; // initialize all children - return (std::count_if( + return (o3tl::make_unsigned(std::count_if( maChildren.begin(), maChildren.end(), - std::mem_fn(&AnimationNode::init) ) == - static_cast<VectorOfNodes::difference_type>(maChildren.size())); + std::mem_fn(&AnimationNode::init) )) == + maChildren.size()); } void BaseContainerNode::deactivate_st( NodeState eDestState ) diff --git a/slideshow/source/engine/shapes/appletshape.cxx b/slideshow/source/engine/shapes/appletshape.cxx index 102dc6aaf3f4..ba7c6243b30b 100644 --- a/slideshow/source/engine/shapes/appletshape.cxx +++ b/slideshow/source/engine/shapes/appletshape.cxx @@ -23,6 +23,7 @@ #include "viewappletshape.hxx" #include <tools.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <algorithm> @@ -210,12 +211,12 @@ namespace slideshow::internal bool AppletShape::implRender( const ::basegfx::B2DRange& rCurrBounds ) const { // redraw all view shapes, by calling their update() method - if( ::std::count_if( maViewAppletShapes.begin(), + if( o3tl::make_unsigned(::std::count_if( maViewAppletShapes.begin(), maViewAppletShapes.end(), [&rCurrBounds] ( const ViewAppletShapeSharedPtr& pShape ) - { return pShape->render( rCurrBounds ); } ) - != static_cast<ViewAppletShapeVector::difference_type>(maViewAppletShapes.size()) ) + { return pShape->render( rCurrBounds ); } )) + != maViewAppletShapes.size() ) { // at least one of the ViewShape::update() calls did return // false - update failed on at least one ViewLayer diff --git a/slideshow/source/engine/shapes/backgroundshape.cxx b/slideshow/source/engine/shapes/backgroundshape.cxx index b107fe4af038..d304b9f901e6 100644 --- a/slideshow/source/engine/shapes/backgroundshape.cxx +++ b/slideshow/source/engine/shapes/backgroundshape.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <sal/log.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <algorithm> @@ -258,11 +259,11 @@ namespace slideshow::internal } // redraw all view shapes, by calling their render() method - if( ::std::count_if( maViewShapes.begin(), + if( o3tl::make_unsigned(::std::count_if( maViewShapes.begin(), maViewShapes.end(), [this]( const ViewBackgroundShapeSharedPtr& pBgShape ) - { return pBgShape->render( this->mpMtf ); } ) - != static_cast<ViewBackgroundShapeVector::difference_type>(maViewShapes.size()) ) + { return pBgShape->render( this->mpMtf ); } )) + != maViewShapes.size() ) { // at least one of the ViewBackgroundShape::render() calls did return // false - update failed on at least one ViewLayer diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index f8e03ebff36f..22b65bf28e21 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -21,6 +21,7 @@ #include <sal/log.hxx> #include <com/sun/star/beans/XPropertySet.hpp> +#include <o3tl/safeint.hxx> #include <vcl/metaact.hxx> #include <vcl/gdimtf.hxx> @@ -146,15 +147,15 @@ namespace slideshow::internal // redraw all view shapes, by calling their update() method ViewShape::RenderArgs renderArgs( getViewRenderArgs() ); bool bVisible = isVisible(); - if( ::std::count_if( maViewShapes.begin(), + if( o3tl::make_unsigned(::std::count_if( maViewShapes.begin(), maViewShapes.end(), [this, &bVisible, &renderArgs, &nUpdateFlags] ( const ViewShapeSharedPtr& pShape ) { return pShape->update( this->mpCurrMtf, renderArgs, nUpdateFlags, - bVisible ); } ) - != static_cast<ViewShapeVector::difference_type>(maViewShapes.size()) ) + bVisible ); } )) + != maViewShapes.size() ) { // at least one of the ViewShape::update() calls did return // false - update failed on at least one ViewLayer diff --git a/slideshow/source/engine/shapes/mediashape.cxx b/slideshow/source/engine/shapes/mediashape.cxx index 64dfd2d0548d..28d3cee86821 100644 --- a/slideshow/source/engine/shapes/mediashape.cxx +++ b/slideshow/source/engine/shapes/mediashape.cxx @@ -19,6 +19,7 @@ #include <com/sun/star/drawing/XShape.hpp> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include "mediashape.hxx" @@ -175,12 +176,12 @@ namespace slideshow::internal bool MediaShape::implRender( const ::basegfx::B2DRange& rCurrBounds ) const { // redraw all view shapes, by calling their update() method - if( ::std::count_if( maViewMediaShapes.begin(), + if( o3tl::make_unsigned(::std::count_if( maViewMediaShapes.begin(), maViewMediaShapes.end(), [&rCurrBounds] ( const ViewMediaShapeSharedPtr& pShape ) - { return pShape->render( rCurrBounds ); } ) - != static_cast<ViewMediaShapeVector::difference_type>(maViewMediaShapes.size()) ) + { return pShape->render( rCurrBounds ); } )) + != maViewMediaShapes.size() ) { // at least one of the ViewShape::update() calls did return // false - update failed on at least one ViewLayer |