From bd2e7480b17a8fa8bc8ed5ec60eb4f02d75a0f1e Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 2 May 2013 16:38:25 +0200 Subject: [PATCH] A first batch of potential bugs spotted by llvm/clang There are more warnings left, but these are the easiest to fix. And some of them are real bugs (assignments with == instead of =). --- src/TextClass.h | 2 +- src/frontends/qt4/GuiDocument.h | 2 -- src/frontends/qt4/GuiFontLoader.cpp | 2 ++ src/frontends/qt4/GuiWorkArea.cpp | 2 +- src/frontends/qt4/GuiWorkArea.h | 2 -- src/frontends/qt4/TocWidget.cpp | 3 ++- src/insets/InsetCommandParams.h | 2 ++ src/insets/InsetTabular.h | 2 +- src/mathed/InsetMathFont.cpp | 10 +++++----- src/support/FileName.h | 6 +++--- src/support/Messages.cpp | 2 +- src/support/Messages.h | 2 -- 12 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/TextClass.h b/src/TextClass.h index bc900fa7a5..9475b621e5 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -385,7 +385,7 @@ public: /// \return true if there is a Layout with latexname lay bool hasLaTeXLayout(std::string const & lay) const; /// A DocumentClass nevers count as loaded, since it is dynamic - virtual bool loaded() { return false; } + virtual bool loaded() const { return false; } /// \return the layout object of an inset given by name. If the name /// is not found as such, the part after the ':' is stripped off, and /// searched again. In this way, an error fallback can be provided: diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h index 413e2e29e9..cfd58823fe 100644 --- a/src/frontends/qt4/GuiDocument.h +++ b/src/frontends/qt4/GuiDocument.h @@ -183,8 +183,6 @@ private: GuiIdListModel modules_av_model_; /// selected modules GuiIdListModel modules_sel_model_; - /// current buffer - BufferId current_id_; /// return false if validate_listings_params returns error bool isValid(); diff --git a/src/frontends/qt4/GuiFontLoader.cpp b/src/frontends/qt4/GuiFontLoader.cpp index 7302ff2c3b..b2448bebee 100644 --- a/src/frontends/qt4/GuiFontLoader.cpp +++ b/src/frontends/qt4/GuiFontLoader.cpp @@ -131,10 +131,12 @@ QString symbolFamily(FontFamily family) } +#if 0 bool isSymbolFamily(FontFamily family) { return family >= SYMBOL_FAMILY && family <= ESINT_FAMILY; } +#endif static bool isChosenFont(QFont & font, QString const & family) diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index ac632f9e05..adfaf4a1cc 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -968,7 +968,7 @@ void GuiWorkArea::generateSyntheticMouseEvent() d->buffer_view_->scroll(up ? -step : step); d->buffer_view_->updateMetrics(); } else { - d->buffer_view_->scrollDocView(value + up ? -step : step, false); + d->buffer_view_->scrollDocView(value + (up ? -step : step), false); } // In which paragraph do we have to set the cursor ? diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index a33e158a54..f9727f9507 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -257,8 +257,6 @@ protected: private: /// QPoint dragStartPos_; - /// - int dragCurrentIndex_; Q_SIGNALS: /// diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 247addbcc9..4bb5345f27 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -262,6 +262,7 @@ void TocWidget::on_persistentCB_stateChanged(int state) } +#if 0 /* FIXME (Ugras 17/11/06): I have implemented a indexDepth function to get the model indices. In my opinion, somebody should derive a new qvariant class for tocModelItem @@ -274,7 +275,7 @@ static int indexDepth(QModelIndex const & index, int depth = -1) return index.parent() == QModelIndex() ? depth : indexDepth(index.parent(), depth); } - +#endif void TocWidget::on_depthSL_valueChanged(int depth) { diff --git a/src/insets/InsetCommandParams.h b/src/insets/InsetCommandParams.h index 7dc59fa5ee..219d79b27e 100644 --- a/src/insets/InsetCommandParams.h +++ b/src/insets/InsetCommandParams.h @@ -31,6 +31,8 @@ class Lexer; class ParamInfo { public: + /// + ParamInfo() {} /// Types of parameters enum ParamType { LATEX_OPTIONAL, /// normal optional argument diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 178060e86a..1fed9bea17 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -57,7 +57,7 @@ public: /// InsetCode lyxCode() const { return CELL_CODE; } /// - Inset * clone() { return new InsetTableCell(*this); } + Inset * clone() const { return new InsetTableCell(*this); } /// bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const; diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp index 26789e71e8..b2e7c1dccc 100644 --- a/src/mathed/InsetMathFont.cpp +++ b/src/mathed/InsetMathFont.cpp @@ -101,7 +101,7 @@ void InsetMathFont::validate(LaTeXFeatures & features) const || (key_->name.length() == 6 && key_->name.substr(0, 4) == "text")) features.require("amstext"); if (key_->name == "mathscr") - features.require("mathrsfs"); + features.require("mathrsfs"); if (key_->name == "textipa") features.require("tipa"); if (key_->name == "ce" || key_->name == "cf") @@ -139,7 +139,7 @@ void InsetMathFont::htmlize(HtmlStream & os) const || tag == "textbf") variant = "bold"; else if (tag == "mathcal") - variant == "script"; + variant = "script"; else if (tag == "mathit" || tag == "textsl" || tag == "emph" || tag == "textit") variant = "italic"; @@ -149,7 +149,7 @@ void InsetMathFont::htmlize(HtmlStream & os) const variant = "monospace"; else if (tag == "textipa" || tag == "textsc" || tag == "noun") variant = "noun"; - + docstring const beg = (tag.size() < 4) ? from_ascii("") : tag.substr(0, 4); if (!variant.empty()) { os << MTag("span", "class='" + variant + "'") @@ -179,7 +179,7 @@ void InsetMathFont::mathmlize(MathStream & os) const || tag == "textbf") variant = "bold"; else if (tag == "mathcal") - variant == "script"; + variant = "script"; else if (tag == "mathit" || tag == "textsl" || tag == "emph" || tag == "textit") variant = "italic"; @@ -188,7 +188,7 @@ void InsetMathFont::mathmlize(MathStream & os) const else if (tag == "mathtt" || tag == "texttt") variant = "monospace"; // no support at present for textipa, textsc, noun - + if (!variant.empty()) { os << MTag("mstyle", "mathvariant='" + variant + "'") << cell(0) diff --git a/src/support/FileName.h b/src/support/FileName.h index 83d9e946f2..fe15163889 100644 --- a/src/support/FileName.h +++ b/src/support/FileName.h @@ -55,8 +55,8 @@ public: * \param filename the file in question. Must have an absolute path. * Encoding is always UTF-8. */ - virtual void set(std::string const & filename); - virtual void set(FileName const & fn, std::string const & suffix); + void set(std::string const & filename); + void set(FileName const & fn, std::string const & suffix); virtual void erase(); /// Is this filename empty? bool empty() const; @@ -253,7 +253,7 @@ public: * \param buffer_path if \c filename has a relative path, generate * the absolute path using this. */ - virtual void set(std::string const & filename, std::string const & buffer_path); + void set(std::string const & filename, std::string const & buffer_path); /// void erase(); /// diff --git a/src/support/Messages.cpp b/src/support/Messages.cpp index 69273c41b8..4e58a873fd 100644 --- a/src/support/Messages.cpp +++ b/src/support/Messages.cpp @@ -69,7 +69,7 @@ namespace lyx { // This version use the traditional gettext. Messages::Messages(string const & l) - : lang_(l), warned_(false) + : lang_(l) { // strip off any encoding suffix, i.e., assume 8-bit po files size_t i = lang_.find("."); diff --git a/src/support/Messages.h b/src/support/Messages.h index 4ba2737cef..655577c0c7 100644 --- a/src/support/Messages.h +++ b/src/support/Messages.h @@ -36,8 +36,6 @@ public: private: /// std::string lang_; - /// Did we warn about unavailable locale already? - mutable bool warned_; /// typedef std::map TranslationCache; /// Internal cache for gettext translated strings. -- 2.39.2