Merge pull request #1372 from PhenomRetroShare/Fix_Warnings

Fix warnings
This commit is contained in:
G10h4ck 2018-10-24 01:53:52 +02:00 committed by GitHub
commit 966cd27cd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 159 additions and 142 deletions

View File

@ -168,6 +168,8 @@ class MessageInfo_v2
struct MessageInfo : RsSerializable
{
MessageInfo(): msgflags(0), size(0), count(0), ts(0) {}
virtual ~MessageInfo() = default;
std::string msgId;
RsPeerId rspeerid_srcId;
@ -230,10 +232,10 @@ struct MessageInfo : RsSerializable
}
};
struct MsgInfoSummary : RsSerializable
{
MsgInfoSummary() : msgflags(0), count(0), ts(0) {}
virtual ~MsgInfoSummary() = default;
std::string msgId;
RsPeerId srcId;
@ -260,6 +262,8 @@ struct MsgInfoSummary : RsSerializable
struct MsgTagInfo : RsSerializable
{
virtual ~MsgTagInfo() = default;
std::string msgId;
std::list<uint32_t> tagIds;
@ -272,6 +276,7 @@ struct MsgTagInfo : RsSerializable
struct MsgTagType : RsSerializable
{
virtual ~MsgTagType() = default;
/* map containing tagId -> pair (text, rgb color) */
std::map<uint32_t, std::pair<std::string, uint32_t> > types;
@ -327,6 +332,8 @@ class ChatId : RsSerializable
{
public:
ChatId();
virtual ~ChatId() = default;
explicit ChatId(RsPeerId id);
explicit ChatId(ChatLobbyId id);
explicit ChatId(DistantChatPeerId id);
@ -398,6 +405,8 @@ public:
class ChatLobbyInvite : RsSerializable
{
public:
virtual ~ChatLobbyInvite() = default;
ChatLobbyId lobby_id ;
RsPeerId peer_id ;
std::string lobby_name ;
@ -419,6 +428,7 @@ class VisibleChatLobbyRecord : RsSerializable
{
public:
VisibleChatLobbyRecord(): lobby_id(0), total_number_of_peers(0), last_report_time(0){}
virtual ~VisibleChatLobbyRecord() = default;
ChatLobbyId lobby_id ; // unique id of the lobby
std::string lobby_name ; // name to use for this lobby
@ -443,10 +453,11 @@ public:
}
};
class ChatLobbyInfo : RsSerializable
{
public:
virtual ~ChatLobbyInfo() = default;
ChatLobbyId lobby_id ; // unique id of the lobby
std::string lobby_name ; // name to use for this lobby
std::string lobby_topic ; // topic to use for this lobby
@ -486,7 +497,7 @@ class RsMsgs
public:
RsMsgs() {}
virtual ~RsMsgs() {}
virtual ~RsMsgs() = default;
/****************************************/
/* Message Items */
@ -896,6 +907,5 @@ virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid)=0;
};
#endif

View File

@ -31,7 +31,7 @@ bool RsLoginHandler::checkAndStoreSSLPasswdIntoGPGFile(
FILE *sslPassphraseFile = RsDirUtil::rs_fopen(
getSSLPasswdFileName(ssl_id).c_str(), "r");
if(sslPassphraseFile != NULL) // already have it.
if(sslPassphraseFile) // already have it.
{
fclose(sslPassphraseFile);
return true ;
@ -52,7 +52,7 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const RsPeerId& ssl_id,std::string&
FILE *sslPassphraseFile = RsDirUtil::rs_fopen(
getSSLPasswdFileName(ssl_id).c_str(), "r");
if (sslPassphraseFile == NULL)
if (!sslPassphraseFile)
{
std::cerr << "No password provided, and no sslPassphraseFile : "
<< getSSLPasswdFileName(ssl_id).c_str() << std::endl;
@ -117,8 +117,9 @@ const SecretSchema *libsecret_get_schema(void)
"org.Retroshare.Password", SECRET_SCHEMA_NONE,
{
{ "RetroShare SSL Id", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ "NULL", (SecretSchemaAttributeType)0 },
}
{ "NULL", static_cast<SecretSchemaAttributeType>(0) },
},
0,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr
};
return &the_schema;
}
@ -240,18 +241,18 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd
std::cerr << "Using attribute: " << ssl_id << std::endl;
#endif
GError *error = NULL;
gchar *password = secret_password_lookup_sync (libsecret_get_schema(), NULL, &error,
GError *error = nullptr;
gchar *password = secret_password_lookup_sync (libsecret_get_schema(), nullptr, &error,
"RetroShare SSL Id", ssl_id.toStdString().c_str(),
NULL);
if (error != NULL) {
if (error) {
g_error_free (error);
#ifdef DEBUG_RSLOGINHANDLER
std::cerr << "Could not get passwd using libsecret: error" << std::endl;
#endif
return false;
} else if (password == NULL) {
} else if (!password) {
/* password will be null, if no matching password found */
#ifdef DEBUG_RSLOGINHANDLER
std::cerr << "Could not get passwd using libsecret: not found" << std::endl;
@ -267,7 +268,7 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd
#ifdef DEBUG_RSLOGINHANDLER
std::cerr << "Could not get passwd from gnome keyring: unknown" << std::endl;
#endif
return false;
//return false; //Never used returned before
#else
/******************** OSX KeyChain stuff *****************************/
#ifdef __APPLE__
@ -440,7 +441,7 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd
#endif
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
return false;
//return false; //never used
}
@ -465,15 +466,15 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s
#elif defined(HAS_LIBSECRET)
// do synchronous store
GError *error = NULL;
GError *error = nullptr;
secret_password_store_sync (libsecret_get_schema(), SECRET_COLLECTION_DEFAULT,
(gchar*)("RetroShare password for SSL Id " + ssl_id.toStdString()).c_str(),
(gchar*)ssl_passwd.c_str(),
NULL, &error,
static_cast<const gchar*>(("RetroShare password for SSL Id " + ssl_id.toStdString()).c_str()),
static_cast<const gchar*>(ssl_passwd.c_str()),
nullptr, &error,
"RetroShare SSL Id", ssl_id.toStdString().c_str(),
NULL);
if (error != NULL) {
if (error) {
g_error_free (error);
std::cerr << "Could not store passwd using libsecret" << std::endl;
return false;
@ -624,10 +625,10 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s
free(pbDataInput);
free(pbDataEnt);
LocalFree(DataOut.pbData);
return false;
#endif
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
return false;
#endif
}
@ -647,12 +648,12 @@ bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id)
#elif defined(HAS_LIBSECRET)
// do synchronous clear
GError *error = NULL;
gboolean removed = secret_password_clear_sync (libsecret_get_schema(), NULL, &error,
GError *error = nullptr;
gboolean removed = secret_password_clear_sync (libsecret_get_schema(), nullptr, &error,
"RetroShare SSL Id", ssl_id.toStdString().c_str(),
NULL);
if (error != NULL) {
if (error) {
g_error_free (error);
std::cerr << "Could not clearpasswd for SSLID " << ssl_id << " using libsecret: error" << std::endl;
return false ;

View File

@ -397,7 +397,7 @@ void RetroShareLink::fromUrl(const QUrl& url)
_name = decodedQueryItemValue(urlQuery, FILE_TREE_NAME);
_size = urlQuery.queryItemValue(FILE_TREE_SIZE).toULongLong(&ok);
_radix = decodedQueryItemValue(urlQuery, FILE_TREE_DATA);
_count = urlQuery.queryItemValue(FILE_TREE_COUNT).toULongLong(&ok);
_count = urlQuery.queryItemValue(FILE_TREE_COUNT).toUInt(&ok);
#ifdef DEBUG_RSLINK
std::cerr << "Got a file tree link!!" << std::endl;
@ -553,7 +553,10 @@ RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id)
RetroShareLink link;
link.clear();
#warning csoler 2012-08-14: This is baaaaaad code:
#ifndef RS_NO_WARN_CPP
#pragma message("csoler 2012-08-14: This is baaaaaad code")
#endif
// - we should not need to parse and re-read a cert in old format.
//
RsPeerDetails detail;
@ -730,10 +733,11 @@ void RetroShareLink::check()
if(!checkSSLId(_SSLid))
_valid = false; // no break! We also test file stuff below.
/* fallthrough */
[[clang::fallthrough]];
case TYPE_FILE_TREE:
/* fallthrough */
case TYPE_FILE:
if(_size > (((uint64_t)1)<<40)) // 1TB. Who has such large files?
if(_size > ((static_cast<uint64_t>(1))<<40)) // 1TB. Who has such large files?
_valid = false;
if(!checkName(_name))
@ -1172,9 +1176,9 @@ bool RetroShareLink::checkSSLId(const QString& ssl_id)
for(int i=0;i<qb.length();++i)
{
unsigned char b(qb[i]) ;
char b(qb[i]) ;
if(!((b>47 && b<58) || (b>96 && b<103)))
if(!((b>='0' && b<='9') || (b>='a' && b<='f')))
return false ;
}
@ -1190,9 +1194,9 @@ bool RetroShareLink::checkPGPId(const QString& pgp_id)
for(int i=0;i<qb.length();++i)
{
unsigned char b(qb[i]) ;
char b(qb[i]) ;
if(!((b>47 && b<58) || (b>64 && b<71)))
if(!((b>='0' && b<='9') || (b>='A' && b<='F')))
return false ;
}
@ -1205,9 +1209,9 @@ bool RetroShareLink::checkRadix64(const QString& s)
for(int i=0;i<qb.length();++i)
{
unsigned char b(qb[i]) ;
char b(qb[i]) ;
if(!( (b > 46 && b < 58) || (b > 64 && b < 91) || (b > 96 && b < 123) || b=='+' || b=='='))
if(!( (b >= '0' && b <= '9') || (b >= 'A' && b <= 'Z') || (b >= 'a' && b <= 'z') || b=='/' || b=='+' || b=='='))
{
std::cerr << "Character not allowed in radix: " << b << std::endl;
return false;
@ -1225,9 +1229,9 @@ bool RetroShareLink::checkHash(const QString& hash)
for(int i=0;i<qb.length();++i)
{
unsigned char b(qb[i]) ;
char b(qb[i]) ;
if(!((b>47 && b<58) || (b>96 && b<103)))
if(!((b>='0' && b<='9') || (b>='a' && b<='f')))
return false ;
}
@ -1504,7 +1508,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
{
if(gxs_details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID)
{
QMessageBox::warning(NULL,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?"));
QMessageBox::warning(nullptr,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?"));
break ;
}
@ -1556,6 +1560,8 @@ static void processList(const QStringList &list, const QString &textSingular, co
}
}
//break;
/* fallthrough */
[[clang::fallthrough]];
case TYPE_EXTRAFILE:
{
#ifdef DEBUG_RSLINK
@ -1618,7 +1624,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
question += QObject::tr("Before you do so, please make sure that this file does not contain malicious executable code.");
question += "<br><br>" + cleanname + "</body></html>";
QMessageBox mb(QObject::tr("Confirmation"), question, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, links.size()>1 ? QMessageBox::NoToAll : 0, 0);
QMessageBox mb(QObject::tr("Confirmation"), question, QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, links.size()>1 ? QMessageBox::NoToAll : 0, nullptr);
int ret = mb.exec();
if(ret == QMessageBox::Yes) {
++countFileOpened;
@ -1693,9 +1699,9 @@ static void processList(const QStringList &list, const QString &textSingular, co
case TYPE_IDENTITY:
{
if(rsIdentity->deserialiseIdentityFromMemory(link.radixGroupData().toStdString()))
QMessageBox::information(NULL,QObject::tr("Identity added to People"),QObject::tr("The identity was added to people. You can now chat with it, send messages to it, etc.")) ;
QMessageBox::information(nullptr,QObject::tr("Identity added to People"),QObject::tr("The identity was added to people. You can now chat with it, send messages to it, etc.")) ;
else
QMessageBox::warning(NULL,QObject::tr("Identity cannot be added to People"),QObject::tr("The identity was not added to people. Some error occured. The link is probably corrupted.")) ;
QMessageBox::warning(nullptr,QObject::tr("Identity cannot be added to People"),QObject::tr("The identity was not added to people. Some error occured. The link is probably corrupted.")) ;
}
break;
@ -1739,7 +1745,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
else
{
ChatDialog* chatDialog = ChatDialog::getChat(chatId, Settings->getChatFlags());
if (chatDialog != NULL) {
if (chatDialog) {
chatroomFound.append(link.name());
} else {
chatroomUnknown.append(link.name());

View File

@ -43,12 +43,12 @@
#include <stdint.h>
#define RSLINK_PROCESS_NOTIFY_SUCCESS 1 // notify on success
#define RSLINK_PROCESS_NOTIFY_ERROR 2 // notify on error
#define RSLINK_PROCESS_NOTIFY_ASK 4 // ask for add the links
#define RSLINK_PROCESS_NOTIFY_BAD_CHARS 8 // / or \\ characters in a filename
#define RSLINK_PROCESS_NOTIFY_SUCCESS 0x01u // notify on success
#define RSLINK_PROCESS_NOTIFY_ERROR 0x02u // notify on error
#define RSLINK_PROCESS_NOTIFY_ASK 0x04u // ask for add the links
#define RSLINK_PROCESS_NOTIFY_BAD_CHARS 0x08u // / or \\ characters in a filename
#define RSLINK_PROCESS_NOTIFY_ALL 15
#define RSLINK_PROCESS_NOTIFY_ALL 0x0Fu
#define RSLINK_SCHEME "retroshare"

View File

@ -83,7 +83,7 @@ void MessagePage::distantMsgsComboBoxChanged(int i)
void MessagePage::updateMsgToReadOnActivate() { Settings->setMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); }
void MessagePage::updateLoadEmbededImages() { Settings->setMsgLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); }
void MessagePage::updateMsgOpen() { Settings->setMsgOpen((RshareSettings::enumMsgOpen) ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt());}
void MessagePage::updateMsgOpen() { Settings->setMsgOpen( static_cast<RshareSettings::enumMsgOpen>(ui.openComboBox->itemData(ui.openComboBox->currentIndex()).toInt()) ); }
void MessagePage::updateDistantMsgs() { Settings->setValue("DistantMessages", ui.comboBox->currentIndex()); }
void MessagePage::updateMsgTags()
@ -169,11 +169,11 @@ void MessagePage::addTag()
void MessagePage::editTag()
{
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
if (pItemWidget == NULL) {
if (!pItemWidget) {
return;
}
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
uint32_t nId = pItemWidget->data(Qt::UserRole).toUInt();
if (nId == 0) {
return;
}
@ -200,11 +200,11 @@ void MessagePage::editTag()
void MessagePage::deleteTag()
{
QListWidgetItem *pItemWidget = ui.tags_listWidget->currentItem();
if (pItemWidget == NULL) {
if (!pItemWidget) {
return;
}
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
uint32_t nId = pItemWidget->data(Qt::UserRole).toUInt();
if (nId == 0) {
return;
}
@ -258,7 +258,7 @@ void MessagePage::currentRowChangedTag(int row)
if (pItemWidget) {
bEditEnable = true;
uint32_t nId = pItemWidget->data(Qt::UserRole).toInt();
uint32_t nId = pItemWidget->data(Qt::UserRole).toUInt();
if (nId >= RS_MSGTAGTYPE_USER) {
bDeleteEnable = true;

View File

@ -53,7 +53,7 @@ bool MousePressEventFilter::eventFilter(QObject * watched, QEvent * event) {
filter(event);
return false;
}
} catch (std::bad_cast) {
} catch (const std::bad_cast&) {
//LOG_FATAL("exception when casting a QEvent to a QMouseEvent");
}
}
@ -74,7 +74,7 @@ bool MouseReleaseEventFilter::eventFilter(QObject * watched, QEvent * event) {
filter(event);
return false;
}
} catch (std::bad_cast) {
} catch (const std::bad_cast&) {
//LOG_FATAL("exception when casting a QEvent to a QMouseEvent");
}
}