Commit 24db5cdc authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #7097: cleanup, stripped dead code, removed shadowed-vars

Found with -Wshadow argument to g++
parent 6aceecc3
...@@ -214,10 +214,10 @@ AlsaLayer::stopStream (void) ...@@ -214,10 +214,10 @@ AlsaLayer::stopStream (void)
* return the function return value * return the function return value
*/ */
#define ALSA_CALL(call, error) ({ \ #define ALSA_CALL(call, error) ({ \
int err = call; \ int err_code = call; \
if (err < 0) \ if (err_code < 0) \
_error("ALSA: "error": %s", snd_strerror(err)); \ _error("ALSA: "error": %s", snd_strerror(err_code)); \
err; \ err_code; \
}) })
void AlsaLayer::stopCaptureStream (void) void AlsaLayer::stopCaptureStream (void)
......
...@@ -374,7 +374,7 @@ void YamlEmitter::addMappingItem (int mappingid, std::string key, YamlNode *node ...@@ -374,7 +374,7 @@ void YamlEmitter::addMappingItem (int mappingid, std::string key, YamlNode *node
throw; throw;
} }
} else if (node->getType() == SEQUENCE) { } else if (node->getType() == SEQUENCE) {
SequenceNode *seqnode = (SequenceNode *)node; SequenceNode *seqnode = static_cast<SequenceNode *>(node);
if ( (temp1 = yaml_document_add_scalar (&document, NULL, (yaml_char_t *) key.c_str(), -1, YAML_PLAIN_SCALAR_STYLE)) == 0) if ( (temp1 = yaml_document_add_scalar (&document, NULL, (yaml_char_t *) key.c_str(), -1, YAML_PLAIN_SCALAR_STYLE)) == 0)
throw YamlEmitterException ("Could not add scalar to document"); throw YamlEmitterException ("Could not add scalar to document");
...@@ -387,25 +387,21 @@ void YamlEmitter::addMappingItem (int mappingid, std::string key, YamlNode *node ...@@ -387,25 +387,21 @@ void YamlEmitter::addMappingItem (int mappingid, std::string key, YamlNode *node
Sequence *seq = seqnode->getSequence(); Sequence *seq = seqnode->getSequence();
Sequence::const_iterator it; Sequence::const_iterator it;
for (it = seq->begin(); it != seq->end(); ++it) { for (it = seq->begin(); it != seq->end(); ++it) {
YamlNode *node = *it; YamlNode *yamlNode = *it;
int id; int id;
if ( (id = yaml_document_add_mapping (&document, NULL, YAML_BLOCK_MAPPING_STYLE)) == 0) { if ((id = yaml_document_add_mapping (&document, NULL, YAML_BLOCK_MAPPING_STYLE)) == 0)
throw YamlEmitterException ("Could not add account mapping to document"); throw YamlEmitterException ("Could not add account mapping to document");
}
if (yaml_document_append_sequence_item (&document, temp2, id) == 0) { if (yaml_document_append_sequence_item (&document, temp2, id) == 0)
throw YamlEmitterException ("Could not append account mapping to sequence"); throw YamlEmitterException ("Could not append account mapping to sequence");
}
MappingNode *mapnode = (MappingNode*)node; MappingNode *mapnode = static_cast<MappingNode*>(yamlNode);
Mapping *map = mapnode->getMapping(); Mapping *map = mapnode->getMapping();
Mapping::iterator mapit; Mapping::iterator mapit;
for (mapit = map->begin(); mapit != map->end() ; ++mapit) for (mapit = map->begin(); mapit != map->end() ; ++mapit)
addMappingItem(id, mapit->first, mapit->second); addMappingItem(id, mapit->first, mapit->second);
} }
} else { } else
throw YamlEmitterException ("Unknown node type while adding mapping node"); throw YamlEmitterException ("Unknown node type while adding mapping node");
}
} }
} }
...@@ -131,7 +131,6 @@ class YamlEmitter ...@@ -131,7 +131,6 @@ class YamlEmitter
friend class ConfigurationTest; friend class ConfigurationTest;
}; };
} }
#endif #endif
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#ifndef __SFL_CALLMANAGER_H__ #ifndef __SFL_CALLMANAGER_H__
#define __SFL_CALLMANAGER_H__ #define __SFL_CALLMANAGER_H__
#include "dbus_cpp.h"
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6 #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
/* This warning option only exists for gcc 4.6.0 and greater. */ /* This warning option only exists for gcc 4.6.0 and greater. */
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
...@@ -47,7 +48,6 @@ ...@@ -47,7 +48,6 @@
#pragma GCC diagnostic warning "-Wunused-but-set-variable" #pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif #endif
#include <dbus-c++/dbus.h>
#include <stdexcept> #include <stdexcept>
class CallManagerException: public std::runtime_error class CallManagerException: public std::runtime_error
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
#pragma GCC diagnostic warning "-Wunused-but-set-variable" #pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif #endif
#include <dbus-c++/dbus.h> #include "dbus_cpp.h"
class ConfigurationManager class ConfigurationManager
: public org::sflphone::SFLphone::ConfigurationManager_adaptor, : public org::sflphone::SFLphone::ConfigurationManager_adaptor,
......
...@@ -31,11 +31,8 @@ ...@@ -31,11 +31,8 @@
#ifndef __DBUSMANAGERIMPL_H__ #ifndef __DBUSMANAGERIMPL_H__
#define __DBUSMANAGERIMPL_H__ #define __DBUSMANAGERIMPL_H__
#pragma GCC diagnostic ignored "-Wignored-qualifiers" #include "dbus_cpp.h"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <dbus-c++/dbus.h>
#pragma GCC diagnostic warning "-Wignored-qualifiers"
#pragma GCC diagnostic warning "-Wunused-parameter"
class ConfigurationManager; class ConfigurationManager;
class CallManager; class CallManager;
class NetworkManager; class NetworkManager;
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
* shall include the source code for the parts of OpenSSL used as well * shall include the source code for the parts of OpenSSL used as well
* as that of the covered work. * as that of the covered work.
*/ */
#include <global.h> #include "global.h"
#include <instance.h> #include "instance.h"
#include "../manager.h" #include "../manager.h"
Instance::Instance (DBus::Connection& connection) Instance::Instance (DBus::Connection& connection)
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6 #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif #endif
#include "dbus_cpp.h"
#pragma GCC diagnostic ignored "-Wignored-qualifiers" #pragma GCC diagnostic ignored "-Wignored-qualifiers"
#pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-parameter"
...@@ -44,9 +45,6 @@ ...@@ -44,9 +45,6 @@
#pragma GCC diagnostic warning "-Wunused-but-set-variable" #pragma GCC diagnostic warning "-Wunused-but-set-variable"
#endif #endif
#include <dbus-c++/dbus.h>
class Instance class Instance
: public org::sflphone::SFLphone::Instance_adaptor, : public org::sflphone::SFLphone::Instance_adaptor,
public DBus::IntrospectableAdaptor, public DBus::IntrospectableAdaptor,
......
...@@ -28,10 +28,12 @@ ...@@ -28,10 +28,12 @@
* as that of the covered work. * as that of the covered work.
*/ */
#include <global.h>
#include "networkmanager.h" #include "networkmanager.h"
#include <iostream> #include <iostream>
#include <instance.h>
#include "global.h"
#include "instance.h"
#include "../manager.h" #include "../manager.h"
const std::string NetworkManager::statesString[5] = {"unknown", "asleep", "connecting", "connected", "disconnected"}; const std::string NetworkManager::statesString[5] = {"unknown", "asleep", "connecting", "connected", "disconnected"};
...@@ -55,6 +57,6 @@ void NetworkManager::PropertiesChanged (const std::map< std::string, ::DBus::Var ...@@ -55,6 +57,6 @@ void NetworkManager::PropertiesChanged (const std::map< std::string, ::DBus::Var
Manager::instance().registerAccounts(); Manager::instance().registerAccounts();
} }
NetworkManager::NetworkManager (DBus::Connection& connection, const DBus::Path& path, const char* destination) : DBus::ObjectProxy (connection, path, destination) NetworkManager::NetworkManager (DBus::Connection& connection, const DBus::Path& dbus_path, const char* destination) : DBus::ObjectProxy (connection, dbus_path, destination)
{ {
} }
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
#ifndef __dbusxx__networkmanager_proxy_h__PROXY_MARSHAL_H #ifndef __dbusxx__networkmanager_proxy_h__PROXY_MARSHAL_H
#define __dbusxx__networkmanager_proxy_h__PROXY_MARSHAL_H #define __dbusxx__networkmanager_proxy_h__PROXY_MARSHAL_H
#include <dbus-c++/dbus.h> #include "dbus_cpp.h"
#include <cassert>
namespace org namespace org
{ {
......
...@@ -31,13 +31,13 @@ ...@@ -31,13 +31,13 @@
#include "urlhook.h" #include "urlhook.h"
#include <cstdlib> #include <cstdlib>
void UrlHook::runAction (std::string command, std::string args) int UrlHook::runAction(const std::string &command, const std::string &args)
{ {
if (args.empty()) if (args.empty())
return; return 0;
//FIXME : use fork and execve, so no need to escape shell arguments //FIXME : use fork and execve, so no need to escape shell arguments
std::string cmd = command + "\"" + args + "\" &"; std::string cmd = command + "\"" + args + "\" &";
system(cmd.c_str()); return system(cmd.c_str());
} }
...@@ -33,10 +33,8 @@ ...@@ -33,10 +33,8 @@
#include <string> #include <string>
class UrlHook namespace UrlHook
{ {
public: int runAction(const std::string &command, const std::string &arg);
static void runAction (std::string, std::string); }
};
#endif // URL_HOOK_H #endif // URL_HOOK_H
...@@ -57,16 +57,16 @@ IAXCall::getSupportedFormat (const std::string &accountID) const ...@@ -57,16 +57,16 @@ IAXCall::getSupportedFormat (const std::string &accountID) const
{ {
Account *account = Manager::instance().getAccount (accountID); Account *account = Manager::instance().getAccount (accountID);
int format = 0; int format_mask = 0;
if (account) { if (account) {
CodecOrder map(account->getActiveCodecs()); CodecOrder map(account->getActiveCodecs());
for (CodecOrder::const_iterator iter = map.begin(); iter != map.end(); ++iter) for (CodecOrder::const_iterator iter = map.begin(); iter != map.end(); ++iter)
format |= codecToASTFormat(*iter); format_mask |= codecToASTFormat(*iter);
} }
else else
_error ("No IAx account could be found"); _error ("No IAx account could be found");
return format; return format_mask;
} }
int IAXCall::getFirstMatchingFormat (int needles, const std::string &accountID) const int IAXCall::getFirstMatchingFormat (int needles, const std::string &accountID) const
...@@ -76,10 +76,10 @@ int IAXCall::getFirstMatchingFormat (int needles, const std::string &accountID) ...@@ -76,10 +76,10 @@ int IAXCall::getFirstMatchingFormat (int needles, const std::string &accountID)
if (account != NULL) { if (account != NULL) {
CodecOrder map(account->getActiveCodecs()); CodecOrder map(account->getActiveCodecs());
for (CodecOrder::const_iterator iter = map.begin(); iter != map.end(); ++iter) { for (CodecOrder::const_iterator iter = map.begin(); iter != map.end(); ++iter) {
int format = codecToASTFormat(*iter); int format_mask = codecToASTFormat(*iter);
// Return the first that matches // Return the first that matches
if (format & needles) if (format_mask & needles)
return format; return format_mask;
} }
} else } else
_error ("No IAx account could be found"); _error ("No IAx account could be found");
......
...@@ -86,8 +86,8 @@ IAXVoIPLink::terminate() ...@@ -86,8 +86,8 @@ IAXVoIPLink::terminate()
for (CallMap::iterator iter = _callMap.begin(); iter != _callMap.end(); ++iter) { for (CallMap::iterator iter = _callMap.begin(); iter != _callMap.end(); ++iter) {
IAXCall *call = dynamic_cast<IAXCall*> (iter->second); IAXCall *call = dynamic_cast<IAXCall*> (iter->second);
if (call) { if (call) {
ost::MutexLock m(mutexIAX_); ost::MutexLock lock(mutexIAX_);
iax_hangup (call->session, (char*) "Dumped Call"); iax_hangup (call->session, const_cast<char*>("Dumped Call"));
delete call; delete call;
} }
} }
......
...@@ -93,52 +93,52 @@ class CryptoAttribute ...@@ -93,52 +93,52 @@ class CryptoAttribute
{ {
public: public:
CryptoAttribute (std::string tag, CryptoAttribute (const std::string &tag,
std::string cryptoSuite, const std::string &cryptoSuite,
std::string srtpKeyMethod, const std::string &srtpKeyMethod,
std::string srtpKeyInfo, const std::string &srtpKeyInfo,
std::string lifetime, const std::string &lifetime,
std::string mkiValue, const std::string &mkiValue,
std::string mkiLength) : const std::string &mkiLength) :
tag (tag), tag_(tag),
cryptoSuite (cryptoSuite), cryptoSuite_(cryptoSuite),
srtpKeyMethod (srtpKeyMethod), srtpKeyMethod_(srtpKeyMethod),
srtpKeyInfo (srtpKeyInfo), srtpKeyInfo_(srtpKeyInfo),
lifetime (lifetime), lifetime_(lifetime),
mkiValue (mkiValue), mkiValue_(mkiValue),
mkiLength (mkiLength) {}; mkiLength_(mkiLength) {}
std::string getTag() const { std::string getTag() const {
return tag; return tag_;
}; }
std::string getCryptoSuite() const { std::string getCryptoSuite() const {
return cryptoSuite; return cryptoSuite_;
}; }
std::string getSrtpKeyMethod() const { std::string getSrtpKeyMethod() const {
return srtpKeyMethod; return srtpKeyMethod_;
}; }
std::string getSrtpKeyInfo() const { std::string getSrtpKeyInfo() const {
return srtpKeyInfo; return srtpKeyInfo_;
}; }
std::string getLifetime() const { std::string getLifetime() const {
return lifetime; return lifetime_;
}; }
std::string getMkiValue() const { std::string getMkiValue() const {
return mkiValue; return mkiValue_;
}; }
std::string getMkiLength() const { std::string getMkiLength() const {
return mkiLength; return mkiLength_;
}; }
private: private:
std::string tag; std::string tag_;
std::string cryptoSuite; std::string cryptoSuite_;
std::string srtpKeyMethod; std::string srtpKeyMethod_;
std::string srtpKeyInfo; std::string srtpKeyInfo_;
std::string lifetime; std::string lifetime_;
std::string mkiValue; std::string mkiValue_;
std::string mkiLength; std::string mkiLength_;
}; };
class SdesNegotiator class SdesNegotiator
...@@ -156,7 +156,7 @@ class SdesNegotiator ...@@ -156,7 +156,7 @@ class SdesNegotiator
public: public:
SdesNegotiator (const std::vector<CryptoSuiteDefinition>& localCapabilites, const std::vector<std::string>& remoteAttribute); SdesNegotiator (const std::vector<CryptoSuiteDefinition>& localCapabilites, const std::vector<std::string>& remoteAttribute);
~SdesNegotiator() { }; ~SdesNegotiator() {};
bool negotiate (void); bool negotiate (void);
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
SIPAccount::SIPAccount (const std::string& accountID) SIPAccount::SIPAccount (const std::string& accountID)
: Account (accountID, "SIP") : Account (accountID, "SIP")
, transport (NULL) , transport_(NULL)
, regc_ (NULL) , regc_ (NULL)
, bRegister_ (false) , bRegister_ (false)
, registrationExpire_ (600) , registrationExpire_ (600)
...@@ -298,11 +298,11 @@ void SIPAccount::unserialize (Conf::MappingNode *map) ...@@ -298,11 +298,11 @@ void SIPAccount::unserialize (Conf::MappingNode *map)
cred->getValue(USERNAME, &user); cred->getValue(USERNAME, &user);
cred->getValue(PASSWORD, &pass); cred->getValue(PASSWORD, &pass);
cred->getValue(REALM, &realm); cred->getValue(REALM, &realm);
std::map<std::string, std::string> map; std::map<std::string, std::string> credentialMap;
map[USERNAME] = user; credentialMap[USERNAME] = user;
map[PASSWORD] = pass; credentialMap[PASSWORD] = pass;
map[REALM] = realm; credentialMap[REALM] = realm;
creds.push_back(map); creds.push_back(credentialMap);
} }
} }
if (creds.empty()) { if (creds.empty()) {
...@@ -656,10 +656,10 @@ std::string SIPAccount::getLoginName (void) ...@@ -656,10 +656,10 @@ std::string SIPAccount::getLoginName (void)
std::string SIPAccount::getFromUri (void) const std::string SIPAccount::getFromUri (void) const
{ {
std::string scheme(""); std::string scheme;
std::string transport(""); std::string transport;
std::string username = username_; std::string username(username_);
std::string hostname = hostname_; std::string hostname(hostname_);
// UDP does not require the transport specification // UDP does not require the transport specification
if (transportType_ == PJSIP_TRANSPORT_TLS) { if (transportType_ == PJSIP_TRANSPORT_TLS) {
......
...@@ -408,8 +408,7 @@ class SIPAccount : public Account ...@@ -408,8 +408,7 @@ class SIPAccount : public Account
return zrtpHelloHash_; return zrtpHelloHash_;
} }
pjsip_transport* transport; pjsip_transport* transport_;
private: private:
std::vector< std::map<std::string, std::string > > credentials_; std::vector< std::map<std::string, std::string > > credentials_;
......
...@@ -288,7 +288,7 @@ void SIPVoIPLink::sendRegister (Account *a) ...@@ -288,7 +288,7 @@ void SIPVoIPLink::sendRegister (Account *a)
std::string srvUri(account->getServerUri()); std::string srvUri(account->getServerUri());
std::string address, port; std::string address, port;
findLocalAddressFromUri(srvUri, account->transport, address, port); findLocalAddressFromUri(srvUri, account->transport_, address, port);
std::string from(account->getFromUri()); std::string from(account->getFromUri());
pj_str_t pjFrom = pj_str((char*)from.c_str()); pj_str_t pjFrom = pj_str((char*)from.c_str());
...@@ -320,11 +320,11 @@ void SIPVoIPLink::sendRegister (Account *a) ...@@ -320,11 +320,11 @@ void SIPVoIPLink::sendRegister (Account *a)
if (pjsip_regc_register (regc, PJ_TRUE, &tdata) != PJ_SUCCESS) if (pjsip_regc_register (regc, PJ_TRUE, &tdata) != PJ_SUCCESS)
throw VoipLinkException("Unable to initialize transaction data for account registration"); throw VoipLinkException("Unable to initialize transaction data for account registration");
if (pjsip_regc_set_transport (regc, initTransportSelector (account->transport, _pool)) != PJ_SUCCESS) if (pjsip_regc_set_transport (regc, initTransportSelector (account->transport_, _pool)) != PJ_SUCCESS)
throw VoipLinkException("Unable to set transport"); throw VoipLinkException("Unable to set transport");
// decrease transport's ref count, counter incrementation is managed when acquiring transport // decrease transport's ref count, counter incrementation is managed when acquiring transport
pjsip_transport_dec_ref(account->transport); pjsip_transport_dec_ref(account->transport_);
// pjsip_regc_send increment the transport ref count by one, // pjsip_regc_send increment the transport ref count by one,
if (pjsip_regc_send(regc, tdata) != PJ_SUCCESS) if (pjsip_regc_send(regc, tdata) != PJ_SUCCESS)
...@@ -333,7 +333,7 @@ void SIPVoIPLink::sendRegister (Account *a) ...@@ -333,7 +333,7 @@ void SIPVoIPLink::sendRegister (Account *a)
// Decrease transport's ref count, since coresponding reference counter decrementation // Decrease transport's ref count, since coresponding reference counter decrementation
// is performed in pjsip_regc_destroy. This function is never called in SFLphone as the // is performed in pjsip_regc_destroy. This function is never called in SFLphone as the
// regc data structure is permanently associated to the account at first registration. // regc data structure is permanently associated to the account at first registration.
pjsip_transport_dec_ref (account->transport); pjsip_transport_dec_ref (account->transport_);
account->setRegistrationInfo (regc); account->setRegistrationInfo (regc);
} }
...@@ -753,7 +753,7 @@ SIPVoIPLink::SIPStartCall(SIPCall *call) ...@@ -753,7 +753,7 @@ SIPVoIPLink::SIPStartCall(SIPCall *call)
std::string toUri(call->getPeerNumber()); // expecting a fully well formed sip uri std::string toUri(call->getPeerNumber()); // expecting a fully well formed sip uri
std::string address, port; std::string address, port;
findLocalAddressFromUri(toUri, account->transport, address, port); findLocalAddressFromUri(toUri, account->transport_, address, port);
std::string from(account->getFromUri()); std::string from(account->getFromUri());
pj_str_t pjFrom = pj_str((char*)from.c_str()); pj_str_t pjFrom = pj_str((char*)from.c_str());
...@@ -782,7 +782,7 @@ SIPVoIPLink::SIPStartCall(SIPCall *call) ...@@ -782,7 +782,7 @@ SIPVoIPLink::SIPStartCall(SIPCall *call)
if (pjsip_inv_invite(call->inv, &tdata) != PJ_SUCCESS) if (pjsip_inv_invite(call->inv, &tdata) != PJ_SUCCESS)
return false; return false;
pjsip_tpselector *tp = initTransportSelector(account->transport, call->inv->pool); pjsip_tpselector *tp = initTransportSelector(account->transport_, call->inv->pool);
if (pjsip_dlg_set_transport (dialog, tp) != PJ_SUCCESS) if (pjsip_dlg_set_transport (dialog, tp) != PJ_SUCCESS)