[dasher: 114/217] Linux: fix most warnings when compiling with clang.



commit a531ab9b80104c20abe0d70322b24ad3763beab1
Author: lbaudoin <lbaudoin google com>
Date:   Sun Nov 8 09:10:01 2015 -0800

    Linux: fix most warnings when compiling with clang.

 Src/DasherCore/ExpansionPolicy.h |   17 +++++++++-----
 Src/DasherCore/UserLog.cpp       |    2 +-
 Src/DasherCore/UserLogTrial.cpp  |    2 +-
 Src/DasherCore/XMLUtil.cpp       |   16 ++++++------
 Src/Gtk2/DasherAppSettings.cpp   |    5 ++-
 Src/Gtk2/DasherControl.h         |   45 ++++++++++++++++++-------------------
 Src/Gtk2/GtkDasherControl.h      |    3 +-
 Src/Gtk2/custom_marshal.cpp      |   12 +++++-----
 Src/Gtk2/dasher_editor.cpp       |    4 +++
 Src/Gtk2/dasher_editor.h         |    6 ++--
 Src/Gtk2/dasher_main.cpp         |    2 -
 11 files changed, 61 insertions(+), 53 deletions(-)
---
diff --git a/Src/DasherCore/ExpansionPolicy.h b/Src/DasherCore/ExpansionPolicy.h
index 8ab2cbb..c0e2ce8 100644
--- a/Src/DasherCore/ExpansionPolicy.h
+++ b/Src/DasherCore/ExpansionPolicy.h
@@ -23,6 +23,7 @@ namespace Dasher {
 class CExpansionPolicy
 {
 public:
+  virtual ~CExpansionPolicy() = default;
   ///dMaxCost should be the value returned by pushNode from the call for the node most closely enclosing 
pNode (that was pushed!)
   ///for the first (outermost) node, i.e. when no enclosing node has been passed, (+ive) INFINITY should be 
passed in.
        virtual double pushNode(CDasherNode *pNode, int iDasherMinY, int iDasherMaxY, bool bExpand, double 
dMaxCost)=0;
@@ -41,8 +42,10 @@ private:
 class NoExpansions : public CExpansionPolicy
 {
 public:
-       double pushNode(CDasherNode *pNode, int iMin, int iMax, bool bExpand, double dMaxCost) {return 
dMaxCost;}
-  bool apply() {return false;}
+  NoExpansions() = default;
+  ~NoExpansions() override = default;
+       double pushNode(CDasherNode *pNode, int iMin, int iMax, bool bExpand, double dMaxCost) override 
{return dMaxCost;}
+  bool apply() override {return false;}
 };
 
 ///A policy that expands/collapses nodes to maintain a given node budget.
@@ -51,11 +54,12 @@ class BudgettingPolicy : public CExpansionPolicy
 {
 public:
   BudgettingPolicy(CDasherModel *pModel, unsigned int iNodeBudget);
+  ~BudgettingPolicy() override = default;
   ///sets cost according to getCost(pNode,iMin,iMax);
   ///then assures node is cheaper (less important) than its parent;
   ///then adds to relevant queue
-  double pushNode(CDasherNode *pNode, int iMin, int iMax, bool bExpand, double dParentCost);
-  bool apply();
+  double pushNode(CDasherNode *pNode, int iMin, int iMax, bool bExpand, double dParentCost) override;
+  bool apply() override;
 protected:
   virtual double getCost(CDasherNode *pNode, int iDasherMinY, int iDasherMaxY);
   ///return the intersection of the ranges (y1-y2) and (iMin-iMax)
@@ -71,8 +75,9 @@ class AmortizedPolicy : public BudgettingPolicy
 public:
   AmortizedPolicy(CDasherModel *pModel, unsigned int iNodeBudget);
        AmortizedPolicy(CDasherModel *pModel, unsigned int iNodeBudget, unsigned int iMaxExpands);
-  bool apply();
-  double pushNode(CDasherNode *pNode, int iMin, int iMax, bool bExpand, double dParentCost);
+  ~AmortizedPolicy() override = default;
+  bool apply() override;
+  double pushNode(CDasherNode *pNode, int iMin, int iMax, bool bExpand, double dParentCost) override;
 private:
        unsigned int m_iMaxExpands;
   void trim();
diff --git a/Src/DasherCore/UserLog.cpp b/Src/DasherCore/UserLog.cpp
index 82d3b99..fd47071 100644
--- a/Src/DasherCore/UserLog.cpp
+++ b/Src/DasherCore/UserLog.cpp
@@ -882,7 +882,7 @@ string CUserLog::GetStartStopCycleStats()
   //
   // tsbdxym stands for: time symbols bits deletes x y maxbitrate
   sprintf(m_szTempBuffer, 
-          "tsbdxym:\t%0.3f\t%d\t%0.6f\t%d\t%0.3f\t%0.3f%s", 
+          "tsbdxym:\t%0.3f\t%zu\t%0.6f\t%d\t%0.3f\t%0.3f%s",
           m_pCycleTimer->GetElapsed(), 
           m_vCycleHistory.size(), 
           GetCycleBits(), 
diff --git a/Src/DasherCore/UserLogTrial.cpp b/Src/DasherCore/UserLogTrial.cpp
index 9cefb64..b1540e3 100644
--- a/Src/DasherCore/UserLogTrial.cpp
+++ b/Src/DasherCore/UserLogTrial.cpp
@@ -604,7 +604,7 @@ string CUserLogTrial::GetLocationXML(NavLocation* pLocation, const string& strPr
   {
     strResult += strPrefix;
     strResult += "\t<NumAdded>";
-    sprintf(m_szTempBuffer, "%d", pLocation->pVectorAdded->size());
+    sprintf(m_szTempBuffer, "%zu", pLocation->pVectorAdded->size());
     strResult += m_szTempBuffer;
     strResult += "</NumAdded>\n";
 
diff --git a/Src/DasherCore/XMLUtil.cpp b/Src/DasherCore/XMLUtil.cpp
index 169fe29..f7a7f73 100644
--- a/Src/DasherCore/XMLUtil.cpp
+++ b/Src/DasherCore/XMLUtil.cpp
@@ -251,8 +251,8 @@ VECTOR_STRING XMLUtil::GetElementStrings(const string& strTag, const string& str
   strEnd += strTag;
   strEnd += ">";
 
-  unsigned int iPosStart        = strXML.find(strStart);
-  unsigned int iPosEnd          = strXML.find(strEnd);
+  size_t iPosStart        = strXML.find(strStart);
+  size_t iPosEnd          = strXML.find(strEnd);
 
   while ((iPosStart != string::npos) && (iPosEnd != string::npos))
   {
@@ -261,8 +261,8 @@ VECTOR_STRING XMLUtil::GetElementStrings(const string& strTag, const string& str
     // we'll count any other instances of the start tag.  If we find some
     // then we require that we continue until we get that number more of
     // close tags.
-    unsigned int iCurrentStart    = iPosStart + strStart.length();
-    unsigned int iEmbedCount      = 0;
+    size_t iCurrentStart    = iPosStart + strStart.length();
+    size_t iEmbedCount      = 0;
     while ((iCurrentStart != string::npos) && (iCurrentStart < iPosEnd))
     {
       iCurrentStart = strXML.find(strStart, iCurrentStart);
@@ -273,7 +273,7 @@ VECTOR_STRING XMLUtil::GetElementStrings(const string& strTag, const string& str
       }
     }
     // Now look for end tag to balance the start tags
-    for (unsigned int i = 0; i < iEmbedCount; i++)
+    for (size_t i = 0; i < iEmbedCount; i++)
     {
       iPosEnd = strXML.find(strEnd, iPosEnd  + strEnd.length());
 
@@ -307,7 +307,7 @@ VECTOR_NAME_VALUE_PAIR XMLUtil::GetNameValuePairs(const string& strXML, bool bSt
   string  strName     = "";
   string  strValue    = "";
 
-  unsigned int i = 0;
+  size_t i = 0;
   while (i < strXML.length())
   {
     if ((!bInStartTag) && (strXML[i] == '<'))
@@ -326,10 +326,10 @@ VECTOR_NAME_VALUE_PAIR XMLUtil::GetNameValuePairs(const string& strXML, bool bSt
         strFind += strName;
         strFind += ">";
 
-        int iPos = -1;
+        size_t iPos = string::npos;
         iPos = strXML.find(strFind, i);
 
-        if (iPos != -1)
+        if (iPos != string::npos)
         {
           strValue = strXML.substr(i + 1, iPos - i - 1);
 
diff --git a/Src/Gtk2/DasherAppSettings.cpp b/Src/Gtk2/DasherAppSettings.cpp
index 0f34de9..7dac789 100644
--- a/Src/Gtk2/DasherAppSettings.cpp
+++ b/Src/Gtk2/DasherAppSettings.cpp
@@ -500,8 +500,8 @@ bool dasher_app_settings_have_advanced(DasherAppSettings *pSelf) {
 void dasher_app_settings_launch_advanced(DasherAppSettings *pSelf) {
   gchar *szArgs[3];
 
-  szArgs[0] = "gconf-editor";
-  szArgs[1] = "/apps/dasher4";
+  szArgs[0] = g_strdup("gconf-editor");
+  szArgs[1] = g_strdup("/apps/dasher4");
   szArgs[2] = NULL;
 
   GError *pError;
@@ -509,6 +509,7 @@ void dasher_app_settings_launch_advanced(DasherAppSettings *pSelf) {
   if(!g_spawn_async(NULL, szArgs, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &pError)) {
     g_warning("Could not launch gconf-editor: %s", pError->message);
   }
+  g_strfreev(szArgs);
 }
 
 void dasher_app_settings_set_widget(DasherAppSettings *pSelf, GtkDasherControl *pWidget) {
diff --git a/Src/Gtk2/DasherControl.h b/Src/Gtk2/DasherControl.h
index 6967b57..7eb9b67 100644
--- a/Src/Gtk2/DasherControl.h
+++ b/Src/Gtk2/DasherControl.h
@@ -131,46 +131,45 @@ public:
   gboolean ExposeEvent();
 
   ///Override to broadcast dasher_stop signal...
-  virtual void Done();
+  void Done() override;
+  void WriteTrainFile(const std::string &filename, const std::string &strNewText) override;
+  int GetFileSize(const std::string &strFileName) override;
 
-  virtual void WriteTrainFile(const std::string &filename, const std::string &strNewText);
-  virtual int GetFileSize(const std::string &strFileName);
-
-  virtual void ClearAllContext();
-  virtual std::string GetAllContext();
-  virtual int GetAllContextLenght();
+  void ClearAllContext() override ;
+  std::string GetAllContext() override;
+  int GetAllContextLenght() override;
   std::string GetTextAroundCursor(CControlManager::EditDistance dist) override;
-  std::string GetContext(unsigned int iStart, unsigned int iLength);
+  std::string GetContext(unsigned int iStart, unsigned int iLength) override;
 
-  virtual bool SupportsClipboard();
-  virtual void CopyToClipboard(const std::string &strText);
+  bool SupportsClipboard() override;
+  void CopyToClipboard(const std::string &strText) override;
 
-  unsigned int ctrlMove(bool bForwards, CControlManager::EditDistance dist);
-  unsigned int ctrlDelete(bool bForwards, CControlManager::EditDistance dist);
+  unsigned int ctrlMove(bool bForwards, CControlManager::EditDistance dist) override;
+  unsigned int ctrlDelete(bool bForwards, CControlManager::EditDistance dist) override;
 #ifdef WITH_SPEECH
   ///override default non-implementation if compiling with speech...
-  virtual bool SupportsSpeech();
-  virtual void Speak(const std::string &strText, bool bInterrupt);
+  bool SupportsSpeech() override;
+  void Speak(const std::string &strText, bool bInterrupt) override;
 #endif
 
   ///
   /// Pass events coming from the core to the appropriate handler.
   ///
-  virtual void HandleEvent(int iParameter);
+  void HandleEvent(int iParameter) override;
 
   ///Override to emit Gtk2 signal
-  virtual void editOutput(const std::string &strText, CDasherNode *pNode);
-  virtual void editDelete(const std::string &strText, CDasherNode *pNode);
-  virtual void editConvert(CDasherNode *pNode);
-  virtual void editProtect(CDasherNode *pNode);
+  void editOutput(const std::string &strText, CDasherNode *pNode) override;
+  void editDelete(const std::string &strText, CDasherNode *pNode) override;
+  void editConvert(CDasherNode *pNode) override;
+  void editProtect(CDasherNode *pNode) override;
 
   ///Override to emit Gtk2 signal
-  virtual void SetLockStatus(const string &strText, int iPercent);
+  void SetLockStatus(const string &strText, int iPercent) override;
 
-  CGameModule *CreateGameModule();
+  CGameModule *CreateGameModule() override;
 private:
-  virtual void ScanFiles(AbstractParser *parser, const std::string &strPattern);
-  virtual void CreateModules();
+  virtual void ScanFiles(AbstractParser *parser, const std::string &strPattern) override;
+  virtual void CreateModules() override;
 
   GtkWidget *m_pVBox;
   GtkWidget *m_pCanvas;
diff --git a/Src/Gtk2/GtkDasherControl.h b/Src/Gtk2/GtkDasherControl.h
index 0c7fdf5..73b4c43 100644
--- a/Src/Gtk2/GtkDasherControl.h
+++ b/Src/Gtk2/GtkDasherControl.h
@@ -57,6 +57,8 @@ struct _GtkDasherControlClass {
 GtkWidget *gtk_dasher_control_new();
 GType gtk_dasher_control_get_type();
 
+G_END_DECLS
+
 gboolean gtk_dasher_control_default_key_press_handler(GtkDasherControl *pDasherControl, GdkEventKey *pEvent, 
gpointer data);
 gboolean gtk_dasher_control_default_key_release_handler(GtkDasherControl *pDasherControl, GdkEventKey 
*pEvent, gpointer data);
 
@@ -92,5 +94,4 @@ void gtk_dasher_user_log_new_trial(GtkDasherControl * pControl);
 void gtk_dasher_control_set_focus(GtkDasherControl * pControl);
 const gchar* gtk_dasher_control_cl_set(GtkDasherControl *pControl, const gchar *szKey, const gchar *szValue);
 
-G_END_DECLS
 #endif
diff --git a/Src/Gtk2/custom_marshal.cpp b/Src/Gtk2/custom_marshal.cpp
index 2934dc9..51fd2ed 100644
--- a/Src/Gtk2/custom_marshal.cpp
+++ b/Src/Gtk2/custom_marshal.cpp
@@ -60,9 +60,9 @@ g_cclosure_user_marshal_VOID__INT_INT (GClosure     *closure,
                                               gint         arg_1,
                                               gint         arg_2,
                                               gpointer     data2);
-  register GMarshalFunc_VOID__INT_INT callback;
-  register GCClosure *cc = (GCClosure*) closure;
-  register gpointer data1, data2;
+  GMarshalFunc_VOID__INT_INT callback;
+  GCClosure *cc = (GCClosure*) closure;
+  gpointer data1, data2;
 
   g_return_if_fail (n_param_values == 3);
 
@@ -97,9 +97,9 @@ g_cclosure_user_marshal_VOID__STRING_INT (GClosure     *closure,
                                                  gpointer     arg_1,
                                                  gint         arg_2,
                                                  gpointer     data2);
-  register GMarshalFunc_VOID__STRING_INT callback;
-  register GCClosure *cc = (GCClosure*) closure;
-  register gpointer data1, data2;
+  GMarshalFunc_VOID__STRING_INT callback;
+  GCClosure *cc = (GCClosure*) closure;
+  gpointer data1, data2;
 
   g_return_if_fail (n_param_values == 3);
 
diff --git a/Src/Gtk2/dasher_editor.cpp b/Src/Gtk2/dasher_editor.cpp
index 6f27ab8..78aa0ce 100644
--- a/Src/Gtk2/dasher_editor.cpp
+++ b/Src/Gtk2/dasher_editor.cpp
@@ -1189,6 +1189,8 @@ static void edit_find(bool bForwards, Dasher::CControlManager::EditDistance iDis
     case Dasher::CControlManager::EDIT_FILE:
       gtk_text_iter_forward_to_end(pPos);
       break;
+    case Dasher::CControlManager::EDIT_SELECTION:
+      break;
     }
   }
   else {
@@ -1213,6 +1215,8 @@ static void edit_find(bool bForwards, Dasher::CControlManager::EditDistance iDis
     case Dasher::CControlManager::EDIT_FILE:
       gtk_text_buffer_get_start_iter(pPrivate->pBuffer, pPos);
       break;
+    case Dasher::CControlManager::EDIT_SELECTION:
+      break;
     }
   }
 }
diff --git a/Src/Gtk2/dasher_editor.h b/Src/Gtk2/dasher_editor.h
index 444493d..a9768b9 100644
--- a/Src/Gtk2/dasher_editor.h
+++ b/Src/Gtk2/dasher_editor.h
@@ -7,6 +7,8 @@
 
 #include "../DasherCore/ControlManager.h"
 
+G_BEGIN_DECLS
+
 /* Forward declaration */
 typedef struct _DasherAppSettings DasherAppSettings;
 struct _DasherAppSettings;
@@ -22,7 +24,6 @@ typedef enum {
   CLIPBOARD_CLEAR
 } clipboard_action;
 
-G_BEGIN_DECLS
 #define DASHER_TYPE_EDITOR            (dasher_editor_get_type())
 #define DASHER_EDITOR(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), DASHER_TYPE_EDITOR, DasherEditor))
 #define DASHER_EDITOR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), DASHER_TYPE_EDITOR, DasherEditor))
@@ -48,6 +49,7 @@ struct _DasherEditorClass {
 DasherEditor *dasher_editor_new();
 
 GType dasher_editor_get_type();
+G_END_DECLS
 
 /* Functions for initialisation and takedown */
 void dasher_editor_initialise(DasherEditor *pSelf,
@@ -88,6 +90,4 @@ void dasher_editor_grab_focus(DasherEditor *pSelf);
 gboolean dasher_editor_file_changed(DasherEditor *pSelf);
 const gchar *dasher_editor_get_filename(DasherEditor *pSelf);
 
-G_END_DECLS
-
 #endif
diff --git a/Src/Gtk2/dasher_main.cpp b/Src/Gtk2/dasher_main.cpp
index ff56524..fac09de 100644
--- a/Src/Gtk2/dasher_main.cpp
+++ b/Src/Gtk2/dasher_main.cpp
@@ -503,8 +503,6 @@ dasher_main_create_preferences(DasherMain *pSelf) {
  * Start game mode: prompt user for the text to play with, put this in SP_GAME_TEXT_FILE;
  * clear out any text in the dasher editor; call CDasherControl::EnterGameMode().
  *
-
-/**
  * Event handler which displays a standard GTK file dialog. The dialog allows the user
  * to specify a text file to play game mode with.
  *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]