From 0d62fc079fe94153b87b7bfdc74c33a2c598e9bc Mon Sep 17 00:00:00 2001
From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Date: Thu, 23 Jul 2009 15:06:40 -0400
Subject: [PATCH] [#1910] Remove warnings compilation in src

---
 sflphone-common/src/account.cpp               |  5 +-
 sflphone-common/src/account.h                 | 12 ++---
 sflphone-common/src/audio/audiostream.cpp     |  2 +
 sflphone-common/src/hooks/urlhook.cpp         |  4 +-
 sflphone-common/src/iaxvoiplink.cpp           |  1 -
 sflphone-common/src/main.cpp                  | 41 +++++++-------
 sflphone-common/src/managerimpl.cpp           | 53 ++++++-------------
 sflphone-common/src/managerimpl.h             |  5 --
 .../src/plug-in/audiorecorder/audiorecord.cpp |  7 +++
 sflphone-common/src/sdp.cpp                   | 15 ++++--
 sflphone-common/src/sdp.h                     |  6 +--
 sflphone-common/src/sipaccount.cpp            |  2 +-
 sflphone-common/src/sipcall.h                 |  8 +--
 sflphone-common/src/sipvoiplink.cpp           | 41 +++++++-------
 sflphone-common/src/sipvoiplink.h             | 18 +++----
 sflphone-common/src/voiplink.cpp              |  1 -
 16 files changed, 110 insertions(+), 111 deletions(-)

diff --git a/sflphone-common/src/account.cpp b/sflphone-common/src/account.cpp
index e22cf874d0..9876b4fd89 100644
--- a/sflphone-common/src/account.cpp
+++ b/sflphone-common/src/account.cpp
@@ -23,7 +23,10 @@
 #include "manager.h"
 
 Account::Account (const AccountID& accountID, std::string type) :
-        _accountID (accountID), _link (NULL), _enabled (false), _type (type)
+			_accountID (accountID)
+		 , _link (NULL)
+		 , _enabled (false)
+		 , _type (type)
 {
     setRegistrationState (Unregistered);
 }
diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h
index fbbaedbd08..72eee8cda7 100644
--- a/sflphone-common/src/account.h
+++ b/sflphone-common/src/account.h
@@ -178,12 +178,6 @@ class Account{
          */
         std::string _alias;
 
-        /*
-         * The account type
-         * IAX2 or SIP
-         */
-        std::string _type;
-
         /**
          * Voice over IP Link contains a listener thread and calls
          */
@@ -196,6 +190,12 @@ class Account{
          */
         bool _enabled;
 
+        /*
+         * The account type
+         * IAX2 or SIP
+         */
+        std::string _type;
+
         /*
          * The registration state of the account
          */
diff --git a/sflphone-common/src/audio/audiostream.cpp b/sflphone-common/src/audio/audiostream.cpp
index 70a7eff154..fe56b85ed5 100644
--- a/sflphone-common/src/audio/audiostream.cpp
+++ b/sflphone-common/src/audio/audiostream.cpp
@@ -88,6 +88,8 @@ AudioStream::drainStream(void) {
         
         pa_threaded_mainloop_unlock(_mainloop);
     }
+
+	return true;
 }
 
 bool
diff --git a/sflphone-common/src/hooks/urlhook.cpp b/sflphone-common/src/hooks/urlhook.cpp
index cdf27b8fa0..b50aa1febb 100644
--- a/sflphone-common/src/hooks/urlhook.cpp
+++ b/sflphone-common/src/hooks/urlhook.cpp
@@ -32,9 +32,7 @@ int UrlHook::addAction (std::string field_value, std::string command)
     /* Execute the command in the background to not block the application */
     command_bg = command + " " + field_value + "&" ;
     /* Execute a system call */
-    RUN_COMMAND (command_bg.c_str());
-
-    return 0;
+    return RUN_COMMAND (command_bg.c_str());
 
 }
 
diff --git a/sflphone-common/src/iaxvoiplink.cpp b/sflphone-common/src/iaxvoiplink.cpp
index a5b29b3850..8afce85a9a 100644
--- a/sflphone-common/src/iaxvoiplink.cpp
+++ b/sflphone-common/src/iaxvoiplink.cpp
@@ -920,7 +920,6 @@ void
 IAXVoIPLink::iaxHandleRegReply (iax_event* event)
 {
 
-    int new_voicemails;
     std::string account_id;
     IAXAccount *account;
 
diff --git a/sflphone-common/src/main.cpp b/sflphone-common/src/main.cpp
index 5eb4ced27b..2ff2739785 100644
--- a/sflphone-common/src/main.cpp
+++ b/sflphone-common/src/main.cpp
@@ -86,24 +86,29 @@ main (int argc, char **argv)
             }
         } else {
             // PID file exists. Check the former process still alive or not. If alive, give user a hint.
-            fgets (cOldPid, 64, fp);
-            fclose (fp);
-
-            if (kill (atoi (cOldPid), 0) == SUCCESS) {
-                fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n");
-                exit (-1);
-            } else {
-                if ( (fp = fopen (homepid,"w")) == NULL) {
-                    fprintf (stderr, "Writing to PID file %s failed. Exited.\n", homepid);
-                    exit (-1);
-                } else {
-                    fputs (cPid , fp);
-                    fclose (fp);
-                }
-
-            }
-        }
-
+			char *res;
+            res = fgets (cOldPid, 64, fp);
+            if (res == NULL)	perror ("Error getting string from stream");
+			
+			else
+			{
+				fclose (fp);
+
+				if (kill (atoi (cOldPid), 0) == SUCCESS) {
+					fprintf (stderr, "There is already a sflphoned daemon running in the system. Starting Failed.\n");
+					exit (-1);
+				} else {
+					if ( (fp = fopen (homepid,"w")) == NULL) {
+						fprintf (stderr, "Writing to PID file %s failed. Exited.\n", homepid);
+						exit (-1);
+					} else {
+						fputs (cPid , fp);
+						fclose (fp);
+					}
+
+				}
+			}
+		}
         int sessionPort = 0;
 
         if (argc == 2) {
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index d7d337d084..654a173d7f 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -286,7 +286,6 @@ ManagerImpl::answerCall (const CallID& id)
 
     AccountID currentaccountid = getAccountFromCall (id);
     Call* currentcall = getAccountLink (currentaccountid)->getCall (getCurrentCallId());
-    _debug ("ManagerImpl::answerCall :: current call->getState %i \n",currentcall->getState());
 
     if (currentcall->getState() == 1)
         isActive = true;
@@ -1050,19 +1049,12 @@ bool ManagerImpl::playATone (Tone::TONEID toneId)
 void ManagerImpl::stopTone (bool stopAudio=true)
 {
     int hasToPlayTone;
-    AudioLayer *audiolayer;
 
     hasToPlayTone = getConfigInt (SIGNALISATION, PLAY_TONES);
 
     if (!hasToPlayTone)
         return;
 
-    // if (stopAudio) {
-    //    audiolayer = getAudioDriver();
-    //    if (audiolayer) audiolayer->stopStream();
-    // }
-
-
     _toneMutex.enterMutex();
 
     if (_telephoneTone != 0) {
@@ -1628,10 +1620,14 @@ ManagerImpl::getAudioOutputDeviceList (void)
 {
     _debug ("Get audio output device list\n");
     AlsaLayer *layer;
+	std::vector <std::string> devices;
 
     layer = dynamic_cast<AlsaLayer*> (getAudioDriver ());
 
-    if (layer)    return layer -> getSoundCardsInfo (SFL_PCM_PLAYBACK);
+    if (layer)
+		devices = layer -> getSoundCardsInfo (SFL_PCM_PLAYBACK);
+
+	return devices;
 }
 
 /**
@@ -1664,12 +1660,15 @@ ManagerImpl::setAudioOutputDevice (const int index)
 std::vector<std::string>
 ManagerImpl::getAudioInputDeviceList (void)
 {
-    _debug ("Get audio input device list\n");
     AlsaLayer *audiolayer;
+	std::vector <std::string> devices;
 
     audiolayer = dynamic_cast<AlsaLayer *> (getAudioDriver());
 
-    if (audiolayer)    return audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE);
+    if (audiolayer)
+		devices = audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE);
+
+	return devices;
 }
 
 /**
@@ -1932,7 +1931,7 @@ ManagerImpl::setPulseAppVolumeControl (void)
 void ManagerImpl::setAudioManager (const int32_t& api)
 {
 
-    int type, samplerate, framesize, numCardIn, numCardOut;
+    int type;
     std::string alsaPlugin;
 
     _debug ("Setting audio manager \n");
@@ -1984,7 +1983,10 @@ ManagerImpl::getAudioDeviceIndex (const std::string name)
 
     alsalayer = dynamic_cast<AlsaLayer *> (getAudioDriver());
 
-    if (alsalayer)   return alsalayer -> soundCardGetIndex (name);
+    if (alsalayer)   
+		return alsalayer -> soundCardGetIndex (name);
+	else
+		return 0;
 }
 
 std::string
@@ -2390,7 +2392,7 @@ ManagerImpl::getAccountList()
 {
     std::vector< std::string > v;
     std::vector< std::string > account_order;
-    int i;
+    unsigned int i;
 
     account_order = loadAccountOrder ();
     AccountMap::iterator iter;
@@ -2476,7 +2478,6 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma
 
     std::string accountType;
     Account *acc;
-    VoIPLink *link;
 
     accountType = (*details.find (CONFIG_ACCOUNT_TYPE)).second;
 
@@ -2681,7 +2682,7 @@ ManagerImpl::loadAccountMap()
     short nbAccount = 0;
     TokenList sections = _config.getSections();
     std::string accountType;
-    Account* tmpAccount;
+	Account *tmpAccount = 0;
     std::vector <std::string> account_order;
 
     TokenList::iterator iter = sections.begin();
@@ -2811,25 +2812,6 @@ ManagerImpl::getAccountIdFromNameAndServer (const std::string& userName, const s
     return AccountNULL;
 }
 
-AccountMap ManagerImpl::getSipAccountMap (void)
-{
-
-    AccountMap::iterator iter;
-    AccountMap sipaccounts;
-    AccountID id;
-    Account *account;
-
-    for (iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) {
-        if (iter->second->getType() == "sip") {
-            //id = iter->first;
-            //account = iter->second;
-            //sipaccounts.insert( std::pair<id, account> );
-        }
-    }
-
-    return sipaccounts;
-}
-
 void ManagerImpl::restartPJSIP (void)
 {
     SIPVoIPLink *siplink;
@@ -3133,7 +3115,6 @@ std::vector< std::string >
 ManagerImpl::getCallList (void)
 {
     std::vector< std::string > v;
-    int i;
 
     CallAccountMap::iterator iter = _callAccountMap.begin ();
 
diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h
index a7d1ed4fb3..eef8c251f6 100644
--- a/sflphone-common/src/managerimpl.h
+++ b/sflphone-common/src/managerimpl.h
@@ -893,11 +893,6 @@ class ManagerImpl {
 
     void registerCurSIPAccounts(VoIPLink *link);
 
-    /**
-     * Returns a map with only the existing SIP accounts
-     */
-    AccountMap getSipAccountMap( void );
-
     /*
      * Initialize audiodriver
      */
diff --git a/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp b/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp
index 44a33bb280..998f91c3b0 100644
--- a/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp
+++ b/sflphone-common/src/plug-in/audiorecorder/audiorecord.cpp
@@ -207,6 +207,9 @@ bool AudioRecord::setRecording()
         recordingEnabled_ = true; // once opend file, start recording
     }
 
+	// WARNING: Unused return value
+	return true;
+
 }
 
 void AudioRecord::stopRecording()
@@ -344,6 +347,8 @@ bool AudioRecord::openExistingRawFile()
         _debug ("AudioRecord::openExistingRawFile() : could not create RAW file!\n");
         return false;
     }
+
+	return true;
 }
 
 
@@ -386,6 +391,8 @@ bool AudioRecord::openExistingWavFile()
     if (fseek (fp, 4 , SEEK_END) != 0)
         _debug ("AudioRecors::OpenExistingWavFile : 2.Couldn't seek at the en of the file \n");
 
+	return true;
+
 }
 
 
diff --git a/sflphone-common/src/sdp.cpp b/sflphone-common/src/sdp.cpp
index 3b5a0a3477..64ef13ad70 100644
--- a/sflphone-common/src/sdp.cpp
+++ b/sflphone-common/src/sdp.cpp
@@ -35,7 +35,14 @@ static const pj_str_t STR_RTPMAP = { (char*) "rtpmap", 6 };
 
 
 Sdp::Sdp (pj_pool_t *pool)
-        : _local_media_cap(), _session_media (0),  _ip_addr (""), _local_offer (NULL), _negociated_offer (NULL), _negociator (NULL), _pool (NULL), _local_extern_audio_port (0)
+		: _local_media_cap()
+		, _session_media (0)
+		, _negociator (NULL)
+		, _ip_addr ("")
+		, _local_offer (NULL)
+		, _negociated_offer (NULL)
+		, _pool (NULL)
+		, _local_extern_audio_port (0)
 {
     _pool = pool;
 }
@@ -206,8 +213,8 @@ int Sdp::receiving_initial_offer (pjmedia_sdp_session* remote)
 
 pj_status_t Sdp::check_sdp_answer(pjsip_inv_session *inv, pjsip_rx_data *rdata) 
 {
-    static const pj_str_t str_application = { "application", 11 };
-    static const pj_str_t str_sdp = { "sdp", 3 };
+    static const pj_str_t str_application = { (char*) "application", 11 };
+    static const pj_str_t str_sdp = { (char*) "sdp", 3 };
     pj_status_t status;
     pjsip_msg * message = NULL;
     pjmedia_sdp_session * remote_sdp = NULL;
@@ -469,7 +476,7 @@ void Sdp::set_local_media_capabilities ()
 {
 
     CodecOrder selected_codecs;
-    int i;
+    unsigned int i;
     sdpMedia *audio;
     CodecsMap codecs_list;
     CodecsMap::iterator iter;
diff --git a/sflphone-common/src/sdp.h b/sflphone-common/src/sdp.h
index fcd28db15e..be88ff0e20 100644
--- a/sflphone-common/src/sdp.h
+++ b/sflphone-common/src/sdp.h
@@ -220,15 +220,15 @@ class Sdp {
         // negociation, with the compatible media from each part 
         pjmedia_sdp_session *_negociated_offer;
 
+        // The pool to allocate memory
+        pj_pool_t *_pool;
+
         /** Local audio port */
         int _local_extern_audio_port;
 
         /** Remote's audio port */
         unsigned int _remote_audio_port;
 
-        // The pool to allocate memory
-        pj_pool_t *_pool;
-
         Sdp(const Sdp&); //No Copy Constructor
         Sdp& operator=(const Sdp&); //No Assignment Operator
 
diff --git a/sflphone-common/src/sipaccount.cpp b/sflphone-common/src/sipaccount.cpp
index 8d926c439f..7618e16b33 100644
--- a/sflphone-common/src/sipaccount.cpp
+++ b/sflphone-common/src/sipaccount.cpp
@@ -25,10 +25,10 @@
 SIPAccount::SIPAccount (const AccountID& accountID)
         : Account (accountID, "sip")
         , _cred (NULL)
+        , _regc()
         , _bRegister (false)
         , _contact ("")
         , _resolveOnce (false)
-        , _regc()
 {
     /* SIPVoIPlink is used as a singleton, because we want to have only one link for all the SIP accounts created */
     /* So instead of creating a new instance, we just fetch the static instance, or create one if it is not yet */
diff --git a/sflphone-common/src/sipcall.h b/sflphone-common/src/sipcall.h
index fd0c01bea6..b9db165779 100644
--- a/sflphone-common/src/sipcall.h
+++ b/sflphone-common/src/sipcall.h
@@ -97,8 +97,6 @@ class SIPCall : public Call
 
   private:
 
-    Sdp *_local_sdp;
-
     int _cid;
     int _did;
     int _tid;
@@ -111,7 +109,11 @@ class SIPCall : public Call
     
     
     pjsip_evsub *_xferSub;
-    pjsip_inv_session *_invSession;
+    
+	pjsip_inv_session *_invSession;
+    
+	Sdp *_local_sdp;
+
 };
 
 #endif
diff --git a/sflphone-common/src/sipvoiplink.cpp b/sflphone-common/src/sipvoiplink.cpp
index 0e4a4cb0b6..b3e32c2382 100644
--- a/sflphone-common/src/sipvoiplink.cpp
+++ b/sflphone-common/src/sipvoiplink.cpp
@@ -33,25 +33,25 @@
 #define CAN_REINVITE        1
 
 static char * invitationStateMap[] = { 
-"PJSIP_INV_STATE_NULL", 
-"PJSIP_INV_STATE_CALLING", 
-"PJSIP_INV_STATE_INCOMING", 
-"PJSIP_INV_STATE_EARLY", 
-"PJSIP_INV_STATE_CONNECTING", 
-"PJSIP_INV_STATE_CONFIRMED", 
-"PJSIP_INV_STATE_DISCONNECTED" 
+(char*) "PJSIP_INV_STATE_NULL", 
+(char*) "PJSIP_INV_STATE_CALLING", 
+(char*) "PJSIP_INV_STATE_INCOMING", 
+(char*) "PJSIP_INV_STATE_EARLY", 
+(char*) "PJSIP_INV_STATE_CONNECTING", 
+(char*) "PJSIP_INV_STATE_CONFIRMED", 
+(char*) "PJSIP_INV_STATE_DISCONNECTED" 
 };
                                        
 static char * transactionStateMap[] = {
-"PJSIP_TSX_STATE_NULL" ,	
-"PJSIP_TSX_STATE_CALLING", 	
-"PJSIP_TSX_STATE_TRYING", 	
-"PJSIP_TSX_STATE_PROCEEDING", 	
-"PJSIP_TSX_STATE_COMPLETED", 	
-"PJSIP_TSX_STATE_CONFIRMED", 	
-"PJSIP_TSX_STATE_TERMINATED", 	
-"PJSIP_TSX_STATE_DESTROYED", 	
-"PJSIP_TSX_STATE_MAX" 
+(char*) "PJSIP_TSX_STATE_NULL" ,	
+(char*) "PJSIP_TSX_STATE_CALLING", 	
+(char*) "PJSIP_TSX_STATE_TRYING", 	
+(char*) "PJSIP_TSX_STATE_PROCEEDING", 	
+(char*) "PJSIP_TSX_STATE_COMPLETED", 	
+(char*) "PJSIP_TSX_STATE_CONFIRMED", 	
+(char*) "PJSIP_TSX_STATE_TERMINATED", 	
+(char*) "PJSIP_TSX_STATE_DESTROYED", 	
+(char*) "PJSIP_TSX_STATE_MAX" 
 };
 
 struct result
@@ -1882,6 +1882,7 @@ bool SIPVoIPLink::pjsip_shutdown (void)
     pj_shutdown();
 
     /* Done. */
+	return true;
 }
 
 int getModId()
@@ -1902,7 +1903,7 @@ static void dns_cb(pj_status_t status, void *token, const struct pjsip_server_ad
 void set_voicemail_info (AccountID account, pjsip_msg_body *body)
 {
 
-    int voicemail, pos_begin, pos_end;
+    int voicemail = 0, pos_begin, pos_end;
     std::string voice_str = "Voice-Message: ";
     std::string delimiter = "/";
     std::string msg_body, voicemail_str;
@@ -2655,7 +2656,7 @@ void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata)
         return;
     }
 
-    SIPCall* newCall;
+    SIPCall* newCall = 0;
 
     SIPVoIPLink *link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (accId));
 
@@ -2791,7 +2792,7 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event)
         if (event->body.rx_msg.rdata->msg_info.msg_buf != NULL) {
             request = event->body.rx_msg.rdata->msg_info.msg_buf;
 
-            if (request.find (noresource) != -1) {
+            if ((int) request.find (noresource) != -1) {
                 _debug ("UserAgent: NORESOURCE for transfer!\n");
                 link->transferStep2();
                 pjsip_evsub_terminate (sub, PJ_TRUE);
@@ -2800,7 +2801,7 @@ void xfer_func_cb (pjsip_evsub *sub, pjsip_event *event)
                 return;
             }
 
-            if (request.find (ringing) != -1) {
+            if ((int) request.find (ringing) != -1) {
                 _debug ("UserAgent: transfered call RINGING!\n");
                 link->transferStep2();
                 pjsip_evsub_terminate (sub, PJ_TRUE);
diff --git a/sflphone-common/src/sipvoiplink.h b/sflphone-common/src/sipvoiplink.h
index 3a0387c36e..8dde01c291 100644
--- a/sflphone-common/src/sipvoiplink.h
+++ b/sflphone-common/src/sipvoiplink.h
@@ -351,9 +351,6 @@ class SIPVoIPLink : public VoIPLink
          */
         bool pjsip_shutdown(void);
 
-        /** Do we use stun? */
-        bool _useStun;
-
         pj_status_t stunServerResolve();
 
         /** Create SIP UDP Listener */
@@ -363,12 +360,6 @@ class SIPVoIPLink : public VoIPLink
 
         std::string getLocalIP() {return _localExternAddress;}
 
-        /** Starting sound */
-        AudioRtp* _audiortp;
-        
-        /** For registration use only */
-        int _regPort;
-
         /* Flag to check if the STUN server is valid or not */
         bool validStunServer;
 
@@ -381,6 +372,15 @@ class SIPVoIPLink : public VoIPLink
         /** Local Extern Port is the port seen by peers for SIP listener */
         unsigned int _localExternPort;
 
+        /** Starting sound */
+        AudioRtp* _audiortp;
+        
+        /** For registration use only */
+        int _regPort;
+
+        /** Do we use stun? */
+        bool _useStun;
+
         /** Threading object */
         EventThread* _evThread;
         ost::Mutex _mutexSIP;
diff --git a/sflphone-common/src/voiplink.cpp b/sflphone-common/src/voiplink.cpp
index 52a28cd88f..9bf46226d3 100644
--- a/sflphone-common/src/voiplink.cpp
+++ b/sflphone-common/src/voiplink.cpp
@@ -87,7 +87,6 @@ bool VoIPLink::clearCallMap()
 
 Account* VoIPLink::getAccountPtr (void)
 {
-    Account* account;
     AccountID id;
 
     id = getAccountID();
-- 
GitLab