summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-05-24 15:26:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-05-24 16:50:03 +0200
commit5060c5015882b7109c54598c4ea858949beafc43 (patch)
treec8c153d73f6c6ebbe2dae768c1da72d28312efd4 /vcl/unx
parenta86818c15a6b4773ddd012db37d55b5204163c24 (diff)
Use o3tl::make_unsigned in some places
...where a signed and an unsigned value are compared, and the signed value has just been proven to be non-negative here Change-Id: I20600d61a5d59d739bc1bee838c0038e4611aec2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134875 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/window/salframe.cxx5
-rw-r--r--vcl/unx/gtk3/a11y/atktextattributes.cxx3
-rw-r--r--vcl/unx/gtk3/glomenu.cxx22
3 files changed, 17 insertions, 13 deletions
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 943aa3d527f7..98b68c98ecee 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -52,6 +52,7 @@
#include <sal/macros.h>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <com/sun/star/uno/Exception.hpp>
@@ -2128,7 +2129,7 @@ void X11SalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nScreen )
maRestorePosSize = tools::Rectangle( Point( maGeometry.nX, maGeometry.nY ),
Size( maGeometry.nWidth, maGeometry.nHeight ) );
tools::Rectangle aRect;
- if( nScreen < 0 || nScreen >= static_cast<int>(GetDisplay()->GetXineramaScreens().size()) )
+ if( nScreen < 0 || o3tl::make_unsigned(nScreen) >= GetDisplay()->GetXineramaScreens().size() )
aRect = tools::Rectangle( Point(0,0), GetDisplay()->GetScreenSize( m_nXScreen ) );
else
aRect = GetDisplay()->GetXineramaScreens()[nScreen];
@@ -2171,7 +2172,7 @@ void X11SalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nScreen )
}
else
{
- if( nScreen < 0 || nScreen >= static_cast<int>(GetDisplay()->GetXScreenCount()) )
+ if( nScreen < 0 || o3tl::make_unsigned(nScreen) >= GetDisplay()->GetXScreenCount() )
nScreen = m_nXScreen.getXScreen();
if( nScreen != static_cast<int>(m_nXScreen.getXScreen()) )
{
diff --git a/vcl/unx/gtk3/a11y/atktextattributes.cxx b/vcl/unx/gtk3/a11y/atktextattributes.cxx
index c127333caf43..25b43f480ab7 100644
--- a/vcl/unx/gtk3/a11y/atktextattributes.cxx
+++ b/vcl/unx/gtk3/a11y/atktextattributes.cxx
@@ -38,6 +38,7 @@
#include <i18nlangtag/languagetag.hxx>
#include <tools/UnitConversion.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <stdio.h>
@@ -451,7 +452,7 @@ Strikeout2String(const uno::Any& rAny)
{
sal_Int16 n = rAny.get<sal_Int16>();
- if( n >= 0 && n < sal_Int16(SAL_N_ELEMENTS(font_strikethrough)) )
+ if( n >= 0 && o3tl::make_unsigned(n) < SAL_N_ELEMENTS(font_strikethrough) )
return g_strdup( font_strikethrough[n] );
return nullptr;
diff --git a/vcl/unx/gtk3/glomenu.cxx b/vcl/unx/gtk3/glomenu.cxx
index ca6887cb9d95..a391649bbb6d 100644
--- a/vcl/unx/gtk3/glomenu.cxx
+++ b/vcl/unx/gtk3/glomenu.cxx
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <o3tl/safeint.hxx>
+
#include <unx/gtk/glomenu.h>
struct GLOMenu
@@ -109,7 +111,7 @@ gint
g_lo_menu_get_n_items_from_section (GLOMenu *menu,
gint section)
{
- g_return_val_if_fail (0 <= section && section < static_cast<gint>(menu->items->len), 0);
+ g_return_val_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len, 0);
GLOMenu *model = g_lo_menu_get_section (menu, section);
@@ -155,7 +157,7 @@ g_lo_menu_insert_in_section (GLOMenu *menu,
const gchar *label)
{
g_return_if_fail (G_IS_LO_MENU (menu));
- g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len));
+ g_return_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len);
GLOMenu *model = g_lo_menu_get_section (menu, section);
@@ -481,7 +483,7 @@ g_lo_menu_set_link (GLOMenu *menu,
g_return_if_fail (link != nullptr);
g_return_if_fail (valid_attribute_name (link));
- if (position < 0 || position >= static_cast<gint>(menu->items->len))
+ if (position < 0 || o3tl::make_unsigned(position) >= menu->items->len)
position = menu->items->len - 1;
struct item menu_item = g_array_index (menu->items, struct item, position);
@@ -500,7 +502,7 @@ g_lo_menu_insert_section (GLOMenu *menu,
{
g_return_if_fail (G_IS_LO_MENU (menu));
- if (position < 0 || position > static_cast<gint>(menu->items->len))
+ if (position < 0 || o3tl::make_unsigned(position) > menu->items->len)
position = menu->items->len;
struct item menu_item;
@@ -543,13 +545,13 @@ g_lo_menu_new_submenu_in_item_in_section (GLOMenu *menu,
gint position)
{
g_return_if_fail (G_IS_LO_MENU (menu));
- g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len));
+ g_return_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len);
GLOMenu* model = g_lo_menu_get_section (menu, section);
g_return_if_fail (model != nullptr);
- if (0 <= position && position < static_cast<gint>(model->items->len)) {
+ if (0 <= position && o3tl::make_unsigned(position) < model->items->len) {
GMenuModel* submenu = G_MENU_MODEL (g_lo_menu_new());
g_lo_menu_set_link (model, position, G_MENU_LINK_SUBMENU, submenu);
@@ -568,7 +570,7 @@ g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu,
gint position)
{
g_return_val_if_fail (G_IS_LO_MENU (menu), nullptr);
- g_return_val_if_fail (0 <= section && section < static_cast<gint>(menu->items->len), nullptr);
+ g_return_val_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len, nullptr);
GLOMenu *model = g_lo_menu_get_section (menu, section);
@@ -576,7 +578,7 @@ g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu,
GLOMenu *submenu = nullptr;
- if (0 <= position && position < static_cast<gint>(model->items->len))
+ if (0 <= position && o3tl::make_unsigned(position) < model->items->len)
submenu = G_LO_MENU (G_MENU_MODEL_CLASS (g_lo_menu_parent_class)
->get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU));
//submenu = g_menu_model_get_item_link (G_MENU_MODEL (model), position, G_MENU_LINK_SUBMENU);
@@ -627,7 +629,7 @@ g_lo_menu_remove (GLOMenu *menu,
gint position)
{
g_return_if_fail (G_IS_LO_MENU (menu));
- g_return_if_fail (0 <= position && position < static_cast<gint>(menu->items->len));
+ g_return_if_fail (0 <= position && o3tl::make_unsigned(position) < menu->items->len);
g_lo_menu_clear_item (&g_array_index (menu->items, struct item, position));
g_array_remove_index (menu->items, position);
@@ -640,7 +642,7 @@ g_lo_menu_remove_from_section (GLOMenu *menu,
gint position)
{
g_return_if_fail (G_IS_LO_MENU (menu));
- g_return_if_fail (0 <= section && section < static_cast<gint>(menu->items->len));
+ g_return_if_fail (0 <= section && o3tl::make_unsigned(section) < menu->items->len);
GLOMenu *model = g_lo_menu_get_section (menu, section);