New loplugin:consttobool

...to: "Find implicit conversions from non-'bool' constants (e.g., 'sal_False')
to 'bool'".

Due to how FALSE is defined as just

  #define FALSE (0)

(i.e., a literal of type 'int') but TRUE is defined as

  #define TRUE (!FALSE)

(i.e., an implicit conversion from 'int' to 'bool') in GLib (see the comment in
ConstToBool::VisitImplicitCastExpr), we get more warnings about uses of 'TRUE'
than of 'FALSE'.  For example, in libreofficekit/source/gtk/lokdocview.cxx there
is a warning about the 'TRUE' in

  g_main_context_iteration(nullptr, TRUE);

but not about the 'FALSE' in

  g_main_context_iteration(nullptr, FALSE);

(where the parameter of 'g_main_context_iteration' is of type 'gboolean').  Lets
live with that asymmetry for now...

(Besides the issues addressed directly in this commit, it also found the two
bogus asserts at 7e09d08807 "Fix useless
assert(true) (which would never fire)" and
122a0be8ae "Fix useless assert(true) (which would
never fire)", plus 5f0d6df7f5 "Use two-argument
form of static_assert".)

Change-Id: Id77322de9f94b85a7b65608a03e0e9865d14467b
Reviewed-on: https://gerrit.libreoffice.org/82667
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2019-11-14 19:53:53 +01:00
parent e0f06e60c6
commit 1205a4b774
25 changed files with 409 additions and 94 deletions
+2 -2
View File
@@ -369,7 +369,7 @@ static gboolean pipeline_bus_callback( GstBus *, GstMessage *message, gpointer d
pPlayer->processMessage( message );
return TRUE;
return true;
}
@@ -428,7 +428,7 @@ static bool lcl_is_wayland_display_handle_need_context_message(GstMessage* msg)
static GstContext* lcl_wayland_display_handle_context_new(void* display)
{
GstContext *context = gst_context_new(LCL_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE, TRUE);
GstContext *context = gst_context_new(LCL_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE, true);
gst_structure_set (gst_context_writable_structure (context),
"handle", G_TYPE_POINTER, display, nullptr);
return context;
+265
View File
@@ -0,0 +1,265 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef LO_CLANG_SHARED_PLUGINS
#include <cassert>
#include <limits>
#include <stack>
#include "check.hxx"
#include "plugin.hxx"
// Find implicit conversions from non-'bool' constants (e.g., 'sal_False') to 'bool'.
namespace
{
class ConstToBool final : public loplugin::FilteringPlugin<ConstToBool>
{
public:
explicit ConstToBool(loplugin::InstantiationData const& data)
: FilteringPlugin(data)
{
}
bool PreTraverseLinkageSpecDecl(LinkageSpecDecl*)
{
assert(externCContexts_ != std::numeric_limits<unsigned int>::max()); //TODO
++externCContexts_;
return true;
}
bool PostTraverseLinkageSpecDecl(LinkageSpecDecl*, bool)
{
assert(externCContexts_ != 0);
--externCContexts_;
return true;
}
bool TraverseLinkageSpecDecl(LinkageSpecDecl* decl)
{
bool ret = true;
if (PreTraverseLinkageSpecDecl(decl))
{
ret = FilteringPlugin::TraverseLinkageSpecDecl(decl);
PostTraverseLinkageSpecDecl(decl, ret);
}
return ret;
}
bool PreTraverseUnaryLNot(UnaryOperator* expr)
{
ignoredInAssert_.push(expr->getSubExpr());
return true;
}
bool PostTraverseUnaryLNot(UnaryOperator*, bool)
{
assert(!ignoredInAssert_.empty());
ignoredInAssert_.pop();
return true;
}
bool TraverseUnaryLNot(UnaryOperator* expr)
{
bool ret = true;
if (PreTraverseUnaryLNot(expr))
{
ret = FilteringPlugin::TraverseUnaryLNot(expr);
PostTraverseUnaryLNot(expr, ret);
}
return ret;
}
bool PreTraverseBinLAnd(BinaryOperator* expr)
{
ignoredInAssert_.push(expr->getRHS());
return true;
}
bool PostTraverseBinLAnd(BinaryOperator*, bool)
{
assert(!ignoredInAssert_.empty());
ignoredInAssert_.pop();
return true;
}
bool TraverseBinLAnd(BinaryOperator* expr)
{
bool ret = true;
if (PreTraverseBinLAnd(expr))
{
ret = FilteringPlugin::TraverseBinLAnd(expr);
PostTraverseBinLAnd(expr, ret);
}
return ret;
}
bool VisitImplicitCastExpr(ImplicitCastExpr const* expr)
{
if (ignoreLocation(expr))
{
return true;
}
if (!expr->getType()->isBooleanType())
{
return true;
}
auto const sub = expr->getSubExpr();
auto const t = sub->getType();
if (t->isBooleanType())
{
return true;
}
if (sub->isValueDependent())
{
return true;
}
APValue res;
if (!sub->isCXX11ConstantExpr(compiler.getASTContext(), &res))
{
return true;
}
auto const l = expr->getExprLoc();
if (!ignoredInAssert_.empty() && expr == ignoredInAssert_.top())
{
if (auto const e = dyn_cast<clang::StringLiteral>(sub->IgnoreParenImpCasts()))
{
if (e->isAscii()) // somewhat randomly restrict to plain literals
{
if (compiler.getSourceManager().isMacroArgExpansion(l)
&& Lexer::getImmediateMacroName(l, compiler.getSourceManager(),
compiler.getLangOpts())
== "assert")
{
//TODO: only ignore outermost '!"..."' or '... && "..."'
return true;
}
}
}
}
auto l1 = l;
if (compiler.getSourceManager().isMacroBodyExpansion(l1))
{
auto const n = Lexer::getImmediateMacroName(l1, compiler.getSourceManager(),
compiler.getLangOpts());
if (n == "FALSE" || n == "TRUE" || n == "sal_False" || n == "sal_True")
{
l1 = compiler.getSourceManager().getImmediateMacroCallerLoc(l1);
}
// For exmaple, /usr/include/glib-2.0/glib/gmacros.h from
// glib2-devel-2.62.1-1.fc31.x86_64 has
//
// #define TRUE (!FALSE)
//
// so handle that wrapped macro body expansion, too:
if (compiler.getSourceManager().isMacroBodyExpansion(l1)
&& Lexer::getImmediateMacroName(l1, compiler.getSourceManager(),
compiler.getLangOpts())
== "TRUE")
{
l1 = compiler.getSourceManager().getImmediateMacroCallerLoc(l1);
}
}
if (isSharedCAndCppCode(l1))
{
// Cover just enough cases to handle things like `while (0)` or the use of `sal_True` in
//
// #define OSL_FAIL(m) SAL_DETAIL_WARN_IF_FORMAT(sal_True, "legacy.osl", "%s", m)
//
// in include/osl/diagnose.h:
if (auto const t1 = t->getAs<BuiltinType>())
{
if (t1->getKind() == BuiltinType::Int)
{
auto const& v = res.getInt();
if (v == 0 || v == 1)
{
return true;
}
}
}
if (loplugin::TypeCheck(t).Typedef("sal_Bool").GlobalNamespace())
{
return true;
}
}
bool suggestion;
bool replacement;
if (res.isInt())
{
suggestion = true;
replacement = res.getInt() != 0;
}
else if (res.isFloat())
{
suggestion = true;
replacement = !res.getFloat().isZero();
}
else if (res.isNullPointer())
{
suggestion = true;
replacement = false;
}
else
{
suggestion = false;
}
report(DiagnosticsEngine::Warning,
"implicit conversion of constant %0 of type %1 to 'bool'%select{|; use "
"'%select{false|true}3' instead}2",
l)
<< res.getAsString(compiler.getASTContext(), t) << t << suggestion << replacement
<< expr->getSourceRange();
return true;
}
bool preRun() override { return compiler.getLangOpts().CPlusPlus; }
private:
std::stack<Expr const*> ignoredInAssert_;
unsigned int externCContexts_ = 0;
void run() override
{
if (preRun())
{
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
}
}
bool isFromCIncludeFile(SourceLocation spellingLocation) const
{
return !compiler.getSourceManager().isInMainFile(spellingLocation)
&& (StringRef(
compiler.getSourceManager().getPresumedLoc(spellingLocation).getFilename())
.endswith(".h"));
}
bool isSharedCAndCppCode(SourceLocation location) const
{
while (compiler.getSourceManager().isMacroArgExpansion(location))
{
location = compiler.getSourceManager().getImmediateMacroCallerLoc(location);
}
// Assume that code is intended to be shared between C and C++ if it comes from an include
// file ending in .h, and is either in an extern "C" context or the body of a macro
// definition:
return isFromCIncludeFile(compiler.getSourceManager().getSpellingLoc(location))
&& (externCContexts_ != 0
|| compiler.getSourceManager().isMacroBodyExpansion(location));
}
};
loplugin::Plugin::Registration<ConstToBool> consttobool("consttobool");
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
@@ -0,0 +1,49 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sal/config.h>
#include <sal/types.h>
#pragma clang diagnostic ignored "-Wnull-conversion"
enum E
{
E0,
E1,
E2
};
int const c1 = 1;
constexpr int c2 = 2;
int main()
{
bool b;
// expected-error@+1 {{implicit conversion of constant 0 of type 'int' to 'bool'; use 'false' instead [loplugin:consttobool]}}
b = 0;
// expected-error@+1 {{implicit conversion of constant 1 of type 'sal_Bool' (aka 'unsigned char') to 'bool'; use 'true' instead [loplugin:consttobool]}}
b = sal_True;
// expected-error-re@+1 {{implicit conversion of constant {{nullptr|0}} of type 'nullptr_t' to 'bool'; use 'false' instead [loplugin:consttobool]}}
b = nullptr;
// expected-error@+1 {{implicit conversion of constant 1.000000e+00 of type 'double' to 'bool'; use 'true' instead [loplugin:consttobool]}}
b = 1.0;
// expected-error@+1 {{implicit conversion of constant 2 of type 'E' to 'bool'; use 'true' instead [loplugin:consttobool]}}
b = E2;
// expected-error@+1 {{implicit conversion of constant 97 of type 'char' to 'bool'; use 'true' instead [loplugin:consttobool]}}
b = 'a';
// expected-error@+1 {{implicit conversion of constant 1 of type 'int' to 'bool'; use 'true' instead [loplugin:consttobool]}}
b = c1;
// expected-error@+1 {{implicit conversion of constant 2 of type 'int' to 'bool'; use 'true' instead [loplugin:consttobool]}}
b = c2;
// expected-error@+1 {{implicit conversion of constant 3 of type 'int' to 'bool'; use 'true' instead [loplugin:consttobool]}}
b = (c1 | c2);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
@@ -415,7 +415,7 @@ public:
ESource *pSource = e_source_registry_ref_source(get_e_source_registry(), id);
EBookClient *pBook = pSource ? createClient (pSource) : nullptr;
if (pBook && !e_client_open_sync (pBook, TRUE, nullptr, nullptr))
if (pBook && !e_client_open_sync (pBook, true, nullptr, nullptr))
{
g_object_unref (G_OBJECT (pBook));
pBook = nullptr;
@@ -541,7 +541,7 @@ public:
{
ESource *pSource = findSource (abname);
EBook *pBook = pSource ? e_book_new (pSource, nullptr) : nullptr;
if (pBook && !e_book_open (pBook, TRUE, nullptr))
if (pBook && !e_book_open (pBook, true, nullptr))
{
g_object_unref (G_OBJECT (pBook));
pBook = nullptr;
@@ -268,9 +268,9 @@ EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree )
pArgs[1] = whereAnalysis( parseTree->getChild( 2 ) );
if( SQL_ISTOKEN( parseTree->getChild( 1 ), OR ) )
pResult = e_book_query_or( 2, pArgs, TRUE );
pResult = e_book_query_or( 2, pArgs, true );
else
pResult = e_book_query_and( 2, pArgs, TRUE );
pResult = e_book_query_and( 2, pArgs, true );
}
// SQL =, !=
else if( SQL_ISRULE( parseTree, comparison_predicate ) )
@@ -328,7 +328,7 @@ EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree )
pResult = createTest( aColumnName, E_BOOK_QUERY_IS, aMatchString );
if ( pResult && ( pPrec->getNodeType() == SQLNodeType::NotEqual ) )
pResult = e_book_query_not( pResult, TRUE );
pResult = e_book_query_not( pResult, true );
}
// SQL like
else if( SQL_ISRULE( parseTree, like_predicate ) )
@@ -372,7 +372,7 @@ EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree )
SAL_INFO( "connectivity.evoab2", "Plain contains '" << aMatchString << "'" );
pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString );
if( pResult && bNotLike )
pResult = e_book_query_not( pResult, TRUE );
pResult = e_book_query_not( pResult, true );
}
else if( bNotLike )
{
@@ -314,8 +314,8 @@ static void setupDocView(GtvApplicationWindow* window)
{
GtvApplicationWindowPrivate* priv = getPrivate(window);
g_object_set(G_OBJECT(window->lokdocview),
"doc-password", TRUE,
"doc-password-to-modify", TRUE,
"doc-password", true,
"doc-password-to-modify", true,
"tiled-annotations", priv->m_pRenderingArgs->m_bEnableTiledAnnotations,
nullptr);
@@ -161,7 +161,7 @@ static bool gtv_calc_header_bar_draw_impl(GtkWidget* pWidget, cairo_t* pCairo)
cairo_stroke(pCairo);
}
return FALSE;
return false;
}
static gboolean
@@ -82,7 +82,7 @@ static void
gtv_comments_sidebar_init(GtvCommentsSidebar* sidebar)
{
sidebar->scrolledwindow = gtk_scrolled_window_new(nullptr, nullptr);
gtk_widget_set_vexpand(sidebar->scrolledwindow, TRUE);
gtk_widget_set_vexpand(sidebar->scrolledwindow, true);
sidebar->commentsgrid = gtk_grid_new();
g_object_set(sidebar->commentsgrid, "orientation", GTK_ORIENTATION_VERTICAL, nullptr);
@@ -133,7 +133,7 @@ GtkWidget* GtvHelpers::createCommentBox(const boost::property_tree::ptree& aComm
gtk_container_add(GTK_CONTAINER(pCommentVBox), pControlsHBox);
gtk_container_add(GTK_CONTAINER(pCommentVBox), pCommentSeparator);
gtk_label_set_line_wrap(GTK_LABEL(pCommentText), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(pCommentText), true);
gtk_label_set_max_width_chars(GTK_LABEL(pCommentText), 35);
return pCommentVBox;
@@ -220,11 +220,11 @@ void LOKDocViewSigHandlers::passwordRequired(LOKDocView* pDocView, char* pUrl, g
GtkWidget* pPasswordEntry = gtk_entry_new ();
gtk_entry_set_visibility (GTK_ENTRY(pPasswordEntry), FALSE);
gtk_entry_set_invisible_char (GTK_ENTRY(pPasswordEntry), '*');
gtk_box_pack_end(GTK_BOX(pDialogMessageArea), pPasswordEntry, TRUE, TRUE, 2);
gtk_box_pack_end(GTK_BOX(pDialogMessageArea), pPasswordEntry, true, true, 2);
if (bModify)
{
GtkWidget* pSecondaryLabel = gtk_label_new ("Document requires password to edit");
gtk_box_pack_end(GTK_BOX(pDialogMessageArea), pSecondaryLabel, TRUE, TRUE, 2);
gtk_box_pack_end(GTK_BOX(pDialogMessageArea), pSecondaryLabel, true, true, 2);
gtk_dialog_add_button (GTK_DIALOG (pPasswordDialog), "Open as read-only", GTK_RESPONSE_ACCEPT);
}
gtk_widget_show_all(pPasswordDialog);
@@ -444,7 +444,7 @@ gboolean LOKDocViewSigHandlers::configureEvent(GtkWidget* pWidget, GdkEventConfi
gtv_calc_header_bar_configure(GTV_CALC_HEADER_BAR(window->cornerarea), nullptr);
}
return TRUE;
return true;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -155,23 +155,23 @@ static void addMoreUnoParam(GtkWidget* /*pWidget*/, gpointer userdata)
GtkWidget* pUnoParamAreaBox = GTK_WIDGET(userdata);
GtkWidget* pParamContainer = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start(GTK_BOX(pUnoParamAreaBox), pParamContainer, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pUnoParamAreaBox), pParamContainer, true, true, 2);
GtkWidget* pTypeEntry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(pParamContainer), pTypeEntry, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pParamContainer), pTypeEntry, true, true, 2);
gtk_entry_set_placeholder_text(GTK_ENTRY(pTypeEntry), "Param type (Eg. boolean, string etc.)");
GtkWidget* pNameEntry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(pParamContainer), pNameEntry, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pParamContainer), pNameEntry, true, true, 2);
gtk_entry_set_placeholder_text(GTK_ENTRY(pNameEntry), "Param name");
GtkWidget* pValueEntry = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(pParamContainer), pValueEntry, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pParamContainer), pValueEntry, true, true, 2);
gtk_entry_set_placeholder_text(GTK_ENTRY(pValueEntry), "Param value");
GtkWidget* pRemoveButton = gtk_button_new_from_icon_name("list-remove-symbolic", GTK_ICON_SIZE_BUTTON);
g_signal_connect(pRemoveButton, "clicked", G_CALLBACK(removeUnoParam), pUnoParamAreaBox);
gtk_box_pack_start(GTK_BOX(pParamContainer), pRemoveButton, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pParamContainer), pRemoveButton, true, true, 2);
gtk_widget_show_all(pUnoParamAreaBox);
}
@@ -238,19 +238,19 @@ void unoCommandDebugger(GtkWidget* pButton, gpointer /* pItem */)
g_object_set(G_OBJECT(pUnoCmdDialog), "resizable", FALSE, nullptr);
GtkWidget* pDialogMessageArea = gtk_dialog_get_content_area (GTK_DIALOG (pUnoCmdDialog));
GtkWidget* pUnoCmdAreaBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start(GTK_BOX(pDialogMessageArea), pUnoCmdAreaBox, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pDialogMessageArea), pUnoCmdAreaBox, true, true, 2);
GtkWidget* pUnoCmdLabel = gtk_label_new("Enter UNO command");
gtk_box_pack_start(GTK_BOX(pUnoCmdAreaBox), pUnoCmdLabel, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pUnoCmdAreaBox), pUnoCmdLabel, true, true, 2);
GtkWidget* pUnoCmdEntry = gtk_entry_new ();
gtk_box_pack_start(GTK_BOX(pUnoCmdAreaBox), pUnoCmdEntry, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pUnoCmdAreaBox), pUnoCmdEntry, true, true, 2);
gtk_entry_set_placeholder_text(GTK_ENTRY(pUnoCmdEntry), "UNO command (Eg. Bold, Italic etc.)");
GtkWidget* pUnoParamAreaBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_box_pack_start(GTK_BOX(pDialogMessageArea), pUnoParamAreaBox, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pDialogMessageArea), pUnoParamAreaBox, true, true, 2);
GtkWidget* pAddMoreButton = gtk_button_new_with_label("Add UNO parameter");
gtk_box_pack_start(GTK_BOX(pDialogMessageArea), pAddMoreButton, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pDialogMessageArea), pAddMoreButton, true, true, 2);
g_signal_connect(G_OBJECT(pAddMoreButton), "clicked", G_CALLBACK(addMoreUnoParam), pUnoParamAreaBox);
gtk_widget_show_all(pUnoCmdDialog);
@@ -425,7 +425,7 @@ void documentRedline(GtkWidget* pButton, gpointer /*pItem*/)
gtk_tree_view_append_column(GTK_TREE_VIEW(pTreeView), pColumn);
}
gtk_container_add(GTK_CONTAINER(pScrolledWindow), pTreeView);
gtk_box_pack_start(GTK_BOX(pContentArea), pScrolledWindow, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pContentArea), pScrolledWindow, true, true, 2);
// Show the dialog.
gtk_widget_show_all(pDialog);
@@ -532,7 +532,7 @@ void documentRepair(GtkWidget* pButton, gpointer /*pItem*/)
gtk_tree_view_append_column(GTK_TREE_VIEW(pTreeView), pColumn);
}
gtk_container_add(GTK_CONTAINER(pScrolledWindow), pTreeView);
gtk_box_pack_start(GTK_BOX(pContentArea), pScrolledWindow, TRUE, TRUE, 2);
gtk_box_pack_start(GTK_BOX(pContentArea), pScrolledWindow, true, true, 2);
// Show the dialog.
gtk_widget_show_all(pDialog);
@@ -616,13 +616,13 @@ gboolean signalFindbar(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer /*pData
{
// Search forward.
signalSearchNext(pWidget, nullptr);
return TRUE;
return true;
}
case GDK_KEY_Escape:
{
// Hide the findbar.
gtk_widget_hide(GTK_WIDGET(window->findtoolbar));
return TRUE;
return true;
}
}
return FALSE;
@@ -738,14 +738,14 @@ gboolean signalAddressbar(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer /*pD
lok_doc_view_post_command(LOK_DOC_VIEW(window->lokdocview), ".uno:GoToCell", aArguments.c_str(), false);
gtk_widget_grab_focus(window->lokdocview);
return TRUE;
return true;
}
case GDK_KEY_Escape:
{
std::string aArguments;
lok_doc_view_post_command(LOK_DOC_VIEW(window->lokdocview), ".uno:Cancel", aArguments.c_str(), false);
gtk_widget_grab_focus(window->lokdocview);
return TRUE;
return true;
}
}
return FALSE;
@@ -756,7 +756,7 @@ gboolean signalFormulabar(GtkWidget* /*pWidget*/, GdkEventKey* /*pEvent*/, gpoin
{
// for now it just displays the callback
// TODO - submit the edited formula
return TRUE;
return true;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+24 -24
View File
@@ -435,22 +435,22 @@ handleTextSelectionOnButtonPress(GdkRectangle& aClick, LOKDocView* pDocView) {
{
g_info("LOKDocView_Impl::signalButton: start of drag start handle");
priv->m_bInDragStartHandle = true;
return TRUE;
return true;
}
else if (gdk_rectangle_intersect(&aClick, &priv->m_aHandleMiddleRect, nullptr))
{
g_info("LOKDocView_Impl::signalButton: start of drag middle handle");
priv->m_bInDragMiddleHandle = true;
return TRUE;
return true;
}
else if (gdk_rectangle_intersect(&aClick, &priv->m_aHandleEndRect, nullptr))
{
g_info("LOKDocView_Impl::signalButton: start of drag end handle");
priv->m_bInDragEndHandle = true;
return TRUE;
return true;
}
return FALSE;
return false;
}
/// if handled, returns TRUE else FALSE
@@ -481,11 +481,11 @@ handleGraphicSelectionOnButtonPress(GdkRectangle& aClick, LOKDocView* pDocView)
}
g_object_unref(task);
return TRUE;
return true;
}
}
return FALSE;
return false;
}
/// if handled, returns TRUE else FALSE
@@ -497,22 +497,22 @@ handleTextSelectionOnButtonRelease(LOKDocView* pDocView) {
{
g_info("LOKDocView_Impl::signalButton: end of drag start handle");
priv->m_bInDragStartHandle = false;
return TRUE;
return true;
}
else if (priv->m_bInDragMiddleHandle)
{
g_info("LOKDocView_Impl::signalButton: end of drag middle handle");
priv->m_bInDragMiddleHandle = false;
return TRUE;
return true;
}
else if (priv->m_bInDragEndHandle)
{
g_info("LOKDocView_Impl::signalButton: end of drag end handle");
priv->m_bInDragEndHandle = false;
return TRUE;
return true;
}
return FALSE;
return false;
}
/// if handled, returns TRUE else FALSE
@@ -543,7 +543,7 @@ handleGraphicSelectionOnButtonRelease(LOKDocView* pDocView, GdkEventButton* pEve
}
g_object_unref(task);
return TRUE;
return true;
}
}
@@ -567,10 +567,10 @@ handleGraphicSelectionOnButtonRelease(LOKDocView* pDocView, GdkEventButton* pEve
}
g_object_unref(task);
return TRUE;
return true;
}
return FALSE;
return false;
}
static void
@@ -887,12 +887,12 @@ static gboolean postDocumentLoad(gpointer pData)
refreshSize(pLOKDocView);
gtk_widget_set_can_focus(GTK_WIDGET(pLOKDocView), TRUE);
gtk_widget_set_can_focus(GTK_WIDGET(pLOKDocView), true);
gtk_widget_grab_focus(GTK_WIDGET(pLOKDocView));
lok_doc_view_set_zoom(pLOKDocView, 1.0);
// we are completely loaded
priv->m_bInit = TRUE;
priv->m_bInit = true;
return G_SOURCE_REMOVE;
}
@@ -1612,7 +1612,7 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
}
}
return FALSE;
return false;
}
static const GdkRGBA& getDarkColor(int nViewId, LOKDocViewPrivate& priv)
@@ -1891,7 +1891,7 @@ renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
cairo_stroke(pCairo);
}
return FALSE;
return false;
}
static gboolean
@@ -2677,7 +2677,7 @@ static int lok_poll_callback(void*, int timeoutUs)
if (timeoutUs)
{
guint timeout = g_timeout_add(timeoutUs / 1000, timeout_wakeup, nullptr);
g_main_context_iteration(nullptr, TRUE);
g_main_context_iteration(nullptr, true);
g_source_remove(timeout);
}
else
@@ -2706,7 +2706,7 @@ static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* /
LOKDocViewPrivate& priv = getPrivate(pDocView);
if (priv->m_pOffice != nullptr)
return TRUE;
return true;
if (priv->m_bUnipoll)
g_setenv("SAL_LOK_OPTIONS", "unipoll", FALSE);
@@ -2728,7 +2728,7 @@ static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* /
if (priv->m_bUnipoll)
g_idle_add(spin_lok_loop, pDocView);
return TRUE;
return true;
}
static void lok_doc_view_initable_iface_init (GInitableIface *iface)
@@ -2939,7 +2939,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
g_param_spec_boolean("can-zoom-in",
"Can Zoom In",
"Whether the view can be zoomed in further",
TRUE,
true,
static_cast<GParamFlags>(G_PARAM_READABLE
| G_PARAM_STATIC_STRINGS));
@@ -2952,7 +2952,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
g_param_spec_boolean("can-zoom-out",
"Can Zoom Out",
"Whether the view can be zoomed out further",
TRUE,
true,
static_cast<GParamFlags>(G_PARAM_READABLE
| G_PARAM_STATIC_STRINGS));
@@ -2993,7 +2993,7 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
g_param_spec_boolean("tiled-annotations",
"Render comments in tiles",
"Whether the client wants in tile comment rendering",
TRUE,
true,
static_cast<GParamFlags>(G_PARAM_READWRITE
| G_PARAM_STATIC_STRINGS));
@@ -3780,7 +3780,7 @@ lok_doc_view_paste (LOKDocView* pDocView,
{
LOKDocViewPrivate& priv = getPrivate(pDocView);
LibreOfficeKitDocument* pDocument = priv->m_pDocument;
bool ret = 0;
bool ret = false;
if (!pDocument)
return false;
@@ -1189,7 +1189,7 @@ void SAL_CALL BluetoothServer::run()
while (true)
{
aDBusFD.revents = 0;
g_main_context_iteration( mpImpl->mpContext, TRUE );
g_main_context_iteration( mpImpl->mpContext, true );
if( aDBusFD.revents )
{
dbus_connection_read_write( pConnection, 0 );
@@ -1233,7 +1233,7 @@ void SAL_CALL BluetoothServer::run()
{
aDBusFD.revents = 0;
aSocketFD.revents = 0;
g_main_context_iteration( mpImpl->mpContext, TRUE );
g_main_context_iteration( mpImpl->mpContext, true );
SAL_INFO( "sdremote.bluetooth", "main-loop spin "
<< aDBusFD.revents << " " << aSocketFD.revents );
@@ -22,6 +22,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
$(if $(filter-out WNT,$(OS)),compilerplugins/clang/test/constfields) \
compilerplugins/clang/test/constparams \
compilerplugins/clang/test/constmethod \
compilerplugins/clang/test/consttobool \
compilerplugins/clang/test/constvars \
compilerplugins/clang/test/convertlong \
compilerplugins/clang/test/cppunitassertequals \
+1 -1
View File
@@ -1014,7 +1014,7 @@ void SvxFontPrevWindow::SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBack
rCTLFont.SetFillColor( rColor );
}
else
bTransparent = TRUE;
bTransparent = true;
rFont.SetTransparent( bTransparent );
rCJKFont.SetTransparent( bTransparent );
+1 -1
View File
@@ -82,7 +82,7 @@ component_wrapper_grab_focus (AtkComponent *component)
if( pComponent.is() )
{
pComponent->grabFocus();
return TRUE;
return true;
}
}
catch( const uno::Exception & )
+1 -1
View File
@@ -81,7 +81,7 @@ extern "C" {
SolarMutexGuard aGuard;
// This is an equivalent to a state change to DEFUNC(T).
atk_object_notify_state_change( atk_obj, ATK_STATE_DEFUNCT, TRUE );
atk_object_notify_state_change( atk_obj, ATK_STATE_DEFUNCT, true );
if( atk_get_focus_object() == atk_obj )
{
SAL_WNODEPRECATED_DECLARATIONS_PUSH
+4 -4
View File
@@ -53,7 +53,7 @@ selection_add_selection( AtkSelection *selection,
if( pSelection.is() )
{
pSelection->selectAccessibleChild( i );
return TRUE;
return true;
}
}
catch(const uno::Exception&) {
@@ -72,7 +72,7 @@ selection_clear_selection( AtkSelection *selection )
if( pSelection.is() )
{
pSelection->clearAccessibleSelection();
return TRUE;
return true;
}
}
catch(const uno::Exception&) {
@@ -142,7 +142,7 @@ selection_remove_selection( AtkSelection *selection,
if( pSelection.is() )
{
pSelection->deselectAccessibleChild( i );
return TRUE;
return true;
}
}
catch(const uno::Exception&) {
@@ -161,7 +161,7 @@ selection_select_all_selection( AtkSelection *selection)
if( pSelection.is() )
{
pSelection->selectAllAccessibleChildren();
return TRUE;
return true;
}
}
catch(const uno::Exception&) {
+1 -1
View File
@@ -101,7 +101,7 @@ atk_wrapper_focus_idle_handler (gpointer data)
if ( caretPos != -1 )
{
atk_object_notify_state_change( atk_obj, ATK_STATE_FOCUSED, TRUE );
atk_object_notify_state_change( atk_obj, ATK_STATE_FOCUSED, true );
g_signal_emit_by_name( atk_obj, "text_caret_moved", caretPos );
}
}
+1 -1
View File
@@ -182,7 +182,7 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
g_object_unref (pListStores[i]); // owned by the widget.
GtkCellRenderer *pCell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start(
GTK_CELL_LAYOUT(m_pLists[i]), pCell, TRUE);
GTK_CELL_LAYOUT(m_pLists[i]), pCell, true);
gtk_cell_layout_set_attributes(
GTK_CELL_LAYOUT (m_pLists[i]), pCell, "text", 0, nullptr);
+4 -4
View File
@@ -61,7 +61,7 @@ g_lo_action_init (GLOAction *action)
{
action->item_id = -1;
action->submenu = FALSE;
action->enabled = TRUE;
action->enabled = true;
action->parameter_type = nullptr;
action->state_type = nullptr;
action->state_hint = nullptr;
@@ -179,7 +179,7 @@ g_lo_action_group_query_action (GActionGroup *group,
if (state)
*state = (action->state) ? g_variant_ref (action->state) : nullptr;
return TRUE;
return true;
}
static void
@@ -217,14 +217,14 @@ g_lo_action_group_change_state (GActionGroup *group,
g_lo_action_group_perform_submenu_action (lo_group, action_name, value);
else
{
bool is_new = FALSE;
bool is_new = false;
/* If action already exists but has no state, it should be removed and added again. */
if (action->state_type == nullptr)
{
g_action_group_action_removed (G_ACTION_GROUP (group), action_name);
action->state_type = g_variant_type_copy (g_variant_get_type(value));
is_new = TRUE;
is_new = true;
}
if (g_variant_is_of_type (value, action->state_type))
+7 -7
View File
@@ -58,26 +58,26 @@ valid_attribute_name (const gchar *name)
gint i;
if (!g_ascii_islower (name[0]))
return FALSE;
return false;
for (i = 1; name[i]; i++)
{
if (name[i] != '-' &&
!g_ascii_islower (name[i]) &&
!g_ascii_isdigit (name[i]))
return FALSE;
return false;
if (name[i] == '-' && name[i + 1] == '-')
return FALSE;
return false;
}
if (name[i - 1] == '-')
return FALSE;
return false;
if (i > 1024)
return FALSE;
return false;
return TRUE;
return true;
}
/*
@@ -88,7 +88,7 @@ static gboolean
g_lo_menu_is_mutable (GMenuModel*)
{
// Menu is always mutable.
return TRUE;
return true;
}
static gint
+10 -10
View File
@@ -279,7 +279,7 @@ int GtkSalDisplay::CaptureMouse( SalFrame* pSFrame )
if( !pFrame )
{
if( m_pCapture )
static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( FALSE );
static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false );
m_pCapture = nullptr;
return 0;
}
@@ -288,11 +288,11 @@ int GtkSalDisplay::CaptureMouse( SalFrame* pSFrame )
{
if( pFrame == m_pCapture )
return 1;
static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( FALSE );
static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false );
}
m_pCapture = pFrame;
pFrame->grabPointer( TRUE );
pFrame->grabPointer( true );
return 1;
}
@@ -375,7 +375,7 @@ bool GtkSalData::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( bDispatchThread )
{
int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1;
bool wasOneEvent = TRUE;
bool wasOneEvent = true;
while( nMaxEvents-- && wasOneEvent )
{
wasOneEvent = g_main_context_iteration( nullptr, bWait && !bWasEvent );
@@ -557,7 +557,7 @@ extern "C" {
if( nDeltaSec < 0 || ( nDeltaSec == 0 && nDeltaUSec < 0) )
{
*nTimeoutMS = 0;
return TRUE;
return true;
}
if( nDeltaUSec < 0 )
{
@@ -568,7 +568,7 @@ extern "C" {
if( static_cast<unsigned long>(nDeltaSec) > 1 + ( pTSource->pInstance->m_nTimeoutMS / 1000 ) )
{
sal_gtk_timeout_defer( pTSource );
return TRUE;
return true;
}
*nTimeoutMS = MIN( G_MAXINT, ( nDeltaSec * 1000 + (nDeltaUSec + 999) / 1000 ) );
@@ -635,7 +635,7 @@ create_sal_gtk_timeout( GtkSalTimer *pTimer )
// #i36226# timers should be executed with lower priority
// than XEvents like in generic plugin
g_source_set_priority( pSource, G_PRIORITY_LOW );
g_source_set_can_recurse( pSource, TRUE );
g_source_set_can_recurse( pSource, true );
g_source_set_callback( pSource,
/* unused dummy */ g_idle_remove_by_data,
nullptr, nullptr );
@@ -705,7 +705,7 @@ extern "C" {
assert(static_cast<const SalGenericDisplay *>(pThisDisplay) == pDisplay);
pThisDisplay->DispatchInternalEvent();
}
return TRUE;
return true;
}
}
@@ -720,7 +720,7 @@ void GtkSalData::TriggerUserEventProcessing()
// events, which is G_PRIORITY_HIGH_IDLE + 20, so presentations
// queue-redraw has a chance to be fulfilled
g_source_set_priority (m_pUserEvent, G_PRIORITY_HIGH_IDLE + 30);
g_source_set_can_recurse (m_pUserEvent, TRUE);
g_source_set_can_recurse (m_pUserEvent, true);
g_source_set_callback (m_pUserEvent, call_userEventFn,
static_cast<gpointer>(this), nullptr);
g_source_attach (m_pUserEvent, g_main_context_default ());
@@ -760,7 +760,7 @@ void GtkSalDisplay::deregisterFrame( SalFrame* pFrame )
{
if( m_pCapture == pFrame )
{
static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( FALSE );
static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false );
m_pCapture = nullptr;
}
SalGenericDisplay::deregisterFrame( pFrame );
+3 -3
View File
@@ -502,7 +502,7 @@ static bool ensure_dbus_setup( gpointer data )
pSessionBus = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, nullptr);
if( !pSessionBus )
{
return FALSE;
return false;
}
// Create menu model and action group attached to this frame.
@@ -551,7 +551,7 @@ static bool ensure_dbus_setup( gpointer data )
g_free( aDBusMenubarPath );
}
return FALSE;
return false;
}
void on_registrar_available( GDBusConnection * /*connection*/,
@@ -1773,7 +1773,7 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, SetType eType, tools::Rect
{
// temporarily re-sizeable
if( !(m_nStyle & SalFrameStyleFlags::SIZEABLE) )
gtk_window_set_resizable( GTK_WINDOW(m_pWindow), TRUE );
gtk_window_set_resizable( GTK_WINDOW(m_pWindow), true );
window_resize(nWidth, nHeight);
}
+2 -2
View File
@@ -697,8 +697,8 @@ GtkPrintDialog::impl_initPrintContent(uno::Sequence<sal_Bool> const& i_rDisabled
// sw/source/core/view/printdata.cxx)
if (m_xWrapper->supportsPrintSelection() && !i_rDisabled[2])
{
m_xWrapper->print_unix_dialog_set_support_selection(pDialog, TRUE);
m_xWrapper->print_unix_dialog_set_has_selection(pDialog, TRUE);
m_xWrapper->print_unix_dialog_set_support_selection(pDialog, true);
m_xWrapper->print_unix_dialog_set_has_selection(pDialog, true);
}
beans::PropertyValue* const pPrintContent(