diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-11-14 11:47:08 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-11-14 19:53:53 +0100 |
commit | 1205a4b77401eeb2270fe25193286066bb59d173 (patch) | |
tree | ad15770fb976a95552605aff55ce25b56058bb5f /libreofficekit | |
parent | e0f06e60c6e8958bc508d24585189043888e0eb9 (diff) |
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 7e09d08807b5ba2fd8b9831557752a415bdad562 "Fix useless
assert(true) (which would never fire)" and
122a0be8ae480473bd1d7f35e197a2529f4621e3 "Fix useless assert(true) (which would
never fire)", plus 5f0d6df7f57ae281fe161e61c7f25d67453fddd2 "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>
Diffstat (limited to 'libreofficekit')
7 files changed, 49 insertions, 49 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx index 7692b0b4a162..a527ad88f9a1 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx @@ -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); diff --git a/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx index 68c3e881caa4..7e6e14d0a9d9 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx @@ -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 diff --git a/libreofficekit/qa/gtktiledviewer/gtv-comments-sidebar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-comments-sidebar.cxx index 7c5bd31813e8..dc099bcb4e87 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-comments-sidebar.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-comments-sidebar.cxx @@ -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); diff --git a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx index 63f232b6021f..097bacb62062 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx @@ -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; diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx index 4a9df33d6ba2..e16491203139 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx @@ -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: */ diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx index 708d4d440453..288d56d1b2b3 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx @@ -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: */ diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index b4fe85f2c939..bec07e862538 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -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; |