Fix some of issues found by coverity
authorunc0rr
Wed, 28 May 2014 09:05:36 +0400
changeset 10248 7b9b44a051f8
parent 10247 7c6b265b89d1
child 10249 b47ac2c19de3
Fix some of issues found by coverity
QTfrontend/game.cpp
QTfrontend/net/hwmap.cpp
QTfrontend/net/newnetclient.cpp
QTfrontend/net/proto.cpp
QTfrontend/net/recorder.cpp
QTfrontend/net/tcpBase.cpp
QTfrontend/team.h
QTfrontend/ui/mouseoverfilter.cpp
QTfrontend/ui/mouseoverfilter.h
QTfrontend/ui/page/pagecampaign.cpp
QTfrontend/ui/page/pagevideos.cpp
QTfrontend/ui/widget/chatwidget.cpp
QTfrontend/ui/widget/gamecfgwidget.h
QTfrontend/ui/widget/hedgehogerWidget.h
QTfrontend/ui/widget/teamselect.cpp
QTfrontend/ui/widget/teamselhelper.h
QTfrontend/util/DataManager.cpp
QTfrontend/util/SDLInteraction.cpp
--- a/QTfrontend/game.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/game.cpp	Wed May 28 09:05:36 2014 +0400
@@ -60,6 +60,9 @@
     lastGameCfg = gamecfg;
     lastGameAmmo = ammo;
     lastGameTeamSel = pTeamSelWidget;
+
+    gameState = gsNotStarted;
+    gameType = gtNone;
 }
 
 HWGame::~HWGame()
--- a/QTfrontend/net/hwmap.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/net/hwmap.cpp	Wed May 28 09:05:36 2014 +0400
@@ -27,6 +27,9 @@
 HWMap::HWMap(QObject * parent) :
     TCPBase(false, parent)
 {
+    templateFilter = 0;
+    m_mapgen = MAPGEN_REGULAR;
+    m_maze_size = 0;
 }
 
 HWMap::~HWMap()
--- a/QTfrontend/net/newnetclient.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/net/newnetclient.cpp	Wed May 28 09:05:36 2014 +0400
@@ -39,6 +39,9 @@
     m_game_connected(false),
     netClientState(Disconnected)
 {
+    m_private_game = false;
+    m_nick_registered = false;
+
     m_roomsListModel = new RoomsListModel(this);
 
     m_playersModel = new PlayersListModel(this);
--- a/QTfrontend/net/proto.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/net/proto.cpp	Wed May 28 09:05:36 2014 +0400
@@ -58,5 +58,5 @@
     if(string.left(4) == "/me ")
         return string.mid(4);
     else
-        return NULL;
+        return QString();
 }
--- a/QTfrontend/net/recorder.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/net/recorder.cpp	Wed May 28 09:05:36 2014 +0400
@@ -37,6 +37,7 @@
 {
     this->config = config;
     this->prefix = prefix;
+    item = 0;
     finished = false;
     name = prefix + "." + LibavInteraction::instance().getExtension(config->AVFormat());
 }
--- a/QTfrontend/net/tcpBase.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/net/tcpBase.cpp	Wed May 28 09:05:36 2014 +0400
@@ -111,6 +111,8 @@
     m_connected(false),
     IPCSocket(0)
 {
+    process = 0;
+
     if(!IPCServer)
     {
         IPCServer = new QTcpServer(0);
--- a/QTfrontend/team.h	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/team.h	Wed May 28 09:05:36 2014 +0400
@@ -39,6 +39,8 @@
     QString Name;
     QString Hat;
     int Rounds, Kills, Deaths, Suicides;
+
+    HWHog() : Rounds(0), Kills(0), Deaths(0), Suicides(0){}
 };
 
 // class representing a team
--- a/QTfrontend/ui/mouseoverfilter.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/mouseoverfilter.cpp	Wed May 28 09:05:36 2014 +0400
@@ -22,6 +22,8 @@
 
 bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event )
 {
+    AbstractPage* abstractpage;
+
     if (event->type() == QEvent::Enter)
     {
         QWidget * widget = dynamic_cast<QWidget*>(dist);
--- a/QTfrontend/ui/mouseoverfilter.h	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/mouseoverfilter.h	Wed May 28 09:05:36 2014 +0400
@@ -20,7 +20,6 @@
 
     private:
         Ui_HWForm *ui;
-        AbstractPage* abstractpage;
 
 };
 
--- a/QTfrontend/ui/page/pagecampaign.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/page/pagecampaign.cpp	Wed May 28 09:05:36 2014 +0400
@@ -45,7 +45,7 @@
     btnPreview = formattedButton(":/res/campaign/A_Classic_Fairytale/first_blood.png", true);
     infoLayout->setAlignment(btnPreview, Qt::AlignHCenter | Qt::AlignVCenter);
 
-    lbldescription = new QLabel();
+    lbldescription = new QLabel(this);
     lbldescription->setAlignment(Qt::AlignHCenter| Qt::AlignTop);
     lbldescription->setWordWrap(true);
 
--- a/QTfrontend/ui/page/pagevideos.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/page/pagevideos.cpp	Wed May 28 09:05:36 2014 +0400
@@ -99,6 +99,7 @@
     pUploading = NULL;
     lastSizeUpdate = 0;
     progress = 0;
+    seen = false;
 }
 
 VideoItem::~VideoItem()
--- a/QTfrontend/ui/widget/chatwidget.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Wed May 28 09:05:36 2014 +0400
@@ -182,6 +182,9 @@
     m_isAdmin = false;
     m_autoKickEnabled = false;
 
+    m_scrollToBottom = false;
+    m_scrollBarPos = 0;
+
     QStringList vpList =
          QStringList() << "Classic" << "Default" << "Mobster" << "Russian";
 
--- a/QTfrontend/ui/widget/gamecfgwidget.h	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/widget/gamecfgwidget.h	Wed May 28 09:05:36 2014 +0400
@@ -48,7 +48,6 @@
         QComboBox * GameSchemes;
         QComboBox * WeaponsName;
         HWMapContainer* pMapContainer;
-        QTableView * tv;
         QVariant schemeData(int column) const;
         bool isMaster();
 
--- a/QTfrontend/ui/widget/hedgehogerWidget.h	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/widget/hedgehogerWidget.h	Wed May 28 09:05:36 2014 +0400
@@ -46,7 +46,6 @@
 
     private:
         CHedgehogerWidget();
-        FrameTeams* pOurFrameTeams;
 };
 
 #endif // _HEDGEHOGER_WIDGET
--- a/QTfrontend/ui/widget/teamselect.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/widget/teamselect.cpp	Wed May 28 09:05:36 2014 +0400
@@ -121,26 +121,22 @@
 void TeamSelWidget::removeNetTeam(const HWTeam& team)
 {
     //qDebug() << QString("removeNetTeam: removing team '%1'").arg(team.TeamName);
-    for(;;)
+    QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
+    if(itPlay==curPlayingTeams.end())
     {
-        QList<HWTeam>::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team);
-        if(itPlay==curPlayingTeams.end())
-        {
-            qWarning() << QString("removeNetTeam: team '%1' not found").arg(team.name());
-            break;
-        }
-        if(itPlay->isNetTeam())
-        {
-            QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam)));
-            framePlaying->removeTeam(team);
-            curPlayingTeams.erase(itPlay);
-            break;
-        }
-        else
-        {
-            qWarning() << QString("removeNetTeam: team '%1' was actually a local team!").arg(team.name());
-            break;
-        }
+        qWarning() << QString("removeNetTeam: team '%1' not found").arg(team.name());
+        return;
+    }
+
+    if(itPlay->isNetTeam())
+    {
+        QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam)));
+        framePlaying->removeTeam(team);
+        curPlayingTeams.erase(itPlay);
+    }
+    else
+    {
+        qWarning() << QString("removeNetTeam: team '%1' was actually a local team!").arg(team.name());
     }
     emit setEnabledGameStart(curPlayingTeams.size()>1);
 }
--- a/QTfrontend/ui/widget/teamselhelper.h	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/ui/widget/teamselhelper.h	Wed May 28 09:05:36 2014 +0400
@@ -75,7 +75,7 @@
         FrameTeams * m_parentFrameTeams;
 
     signals:
-        void teamStatusChanged(HWTeam team);
+        void teamStatusChanged(const HWTeam &);
         void hhNmChanged(const HWTeam&);
         void teamColorChanged(const HWTeam&);
 };
--- a/QTfrontend/util/DataManager.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/util/DataManager.cpp	Wed May 28 09:05:36 2014 +0400
@@ -47,6 +47,7 @@
     m_themeModel = NULL;
     m_colorsModel = NULL;
     m_bindsModel = NULL;
+    m_gameStyleModel = NULL;
 }
 
 
--- a/QTfrontend/util/SDLInteraction.cpp	Fri May 23 13:37:34 2014 +0400
+++ b/QTfrontend/util/SDLInteraction.cpp	Wed May 28 09:05:36 2014 +0400
@@ -54,6 +54,7 @@
     m_music = NULL;
     m_musicTrack = "";
     m_isPlayingMusic = false;
+    lastchannel = 0;
     if(SDL_NumJoysticks())
         addGameControllerKeys();
     SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
@@ -175,6 +176,9 @@
         SDL_JoystickClose(joy);
     }
 
+    if(i >= 1024)
+        i = 1023;
+
     // Terminate the list
     sdlkeys[i][0][0] = '\0';
     sdlkeys[i][1][0] = '\0';