summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-04 19:26:46 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-04 19:26:46 +0000
commitfba57c10d9f9552c9c31c20283147348789ef650 (patch)
tree165c4c7ed8fad3c092bf455abf99af4a7a058383 /protocols
parent73504917190e8d183212ec62ad1668d3e72901a7 (diff)
some code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@7499 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/EmLanProto/src/mlan.cpp6
-rw-r--r--protocols/FacebookRM/src/avatars.cpp1
-rw-r--r--protocols/FacebookRM/src/communication.cpp6
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp2
-rw-r--r--protocols/FacebookRM/src/json.cpp6
-rw-r--r--protocols/FacebookRM/src/process.cpp4
-rw-r--r--protocols/FacebookRM/src/proto.cpp6
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp12
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp16
-rw-r--r--protocols/Gadu-Gadu/src/libgadu/common.c10
-rw-r--r--protocols/Gadu-Gadu/src/libgadu/dcc7.c2
-rw-r--r--protocols/Gadu-Gadu/src/libgadu/pubdir.c2
-rw-r--r--protocols/Gadu-Gadu/src/ownerinfo.cpp4
14 files changed, 35 insertions, 46 deletions
diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp
index 11367d265a..1b84fb79c7 100644
--- a/protocols/EmLanProto/src/mlan.cpp
+++ b/protocols/EmLanProto/src/mlan.cpp
@@ -321,7 +321,7 @@ void CMLan::OnRecvPacket(u_char* mes, int len, in_addr from)
db_set_w(hContact,PROTONAME, "Status", cont->m_status);
if (db_get_dw(hContact,PROTONAME, "RemoteVersion", 0)!=cont->m_ver)
db_set_dw(hContact,PROTONAME, "RemoteVersion", cont->m_ver);
- if (old_status = ID_STATUS_OFFLINE)
+ if (old_status == ID_STATUS_OFFLINE)
{
u_int rip = cont->m_addr.S_un.S_addr;
int tip = (rip<<24)|((rip&0xff00)<<8)|((rip&0xff0000)>>8)|(rip>>24);
@@ -428,7 +428,7 @@ void CMLan::RecvMessageUrl(CCSDATA* ccs)
ZeroMemory(&dbei,sizeof(dbei));
- if (ccs->szProtoService == PSR_MESSAGE)
+ if (!lstrcmpA(ccs->szProtoService, PSR_MESSAGE))
dbei.eventType = EVENTTYPE_MESSAGE;
else
dbei.eventType = EVENTTYPE_URL;
@@ -438,7 +438,7 @@ void CMLan::RecvMessageUrl(CCSDATA* ccs)
dbei.timestamp = pre->timestamp;
dbei.flags = pre->flags&PREF_CREATEREAD?DBEF_READ:0;
dbei.cbBlob = lstrlen(pre->szMessage)+1;
- if (ccs->szProtoService==PSR_URL)
+ if (!lstrcmpA(ccs->szProtoService, PSR_URL))
{
dbei.cbBlob += 2+lstrlen(pre->szMessage+dbei.cbBlob+1);
}
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp
index 48bfd898ba..ab9011b8b4 100644
--- a/protocols/FacebookRM/src/avatars.cpp
+++ b/protocols/FacebookRM/src/avatars.cpp
@@ -40,7 +40,6 @@ bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::string *
std::tstring filename = GetAvatarFolder() + L'\\' + dbv.ptszVal + (TCHAR*)_A2T(ext.c_str());
db_free(&dbv);
- ai.hContact = ai.hContact;
_tcsncpy_s(ai.filename, SIZEOF(ai.filename), filename.c_str(), _TRUNCATE);
ai.format = ProtoGetAvatarFormat(ai.filename);
return true;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 85547d09bb..fb2f712265 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -583,7 +583,7 @@ NETLIBHTTPHEADER* facebook_client::get_request_headers(int request_type, int* he
std::string facebook_client::get_newsfeed_type()
{
BYTE feed_type = parent->getByte(FACEBOOK_KEY_FEED_TYPE, 0);
- if (feed_type < 0 || feed_type >= SIZEOF(feed_types))
+ if (feed_type >= SIZEOF(feed_types))
feed_type = 0;
return feed_types[feed_type].id;
}
@@ -591,7 +591,7 @@ std::string facebook_client::get_newsfeed_type()
std::string facebook_client::get_server_type()
{
BYTE server_type = parent->getByte(FACEBOOK_KEY_SERVER_TYPE, 0);
- if (server_type < 0 || server_type >= SIZEOF(server_types))
+ if (server_type >= SIZEOF(server_types))
server_type = 0;
return server_types[server_type].id;
}
@@ -599,7 +599,7 @@ std::string facebook_client::get_server_type()
std::string facebook_client::get_privacy_type()
{
BYTE privacy_type = parent->getByte(FACEBOOK_KEY_PRIVACY_TYPE, 0);
- if (privacy_type < 0 || privacy_type >= SIZEOF(privacy_types))
+ if (privacy_type >= SIZEOF(privacy_types))
privacy_type = 0;
return privacy_types[privacy_type].id;
}
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index fbc388bf26..e946928c4f 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -408,7 +408,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
proto->setString(FACEBOOK_KEY_PASS, str);
GetDlgItemText(hwnd,IDC_GROUP,tstr,sizeof(tstr));
- if (lstrlen(tstr) > 0)
+ if (tstr[0] != '\0')
{
proto->setTString(FACEBOOK_KEY_DEF_GROUP, tstr);
Clist_CreateGroup( 0, tstr);
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 9abb95c088..4611d3119b 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -515,7 +515,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
}
}
- HANDLE hChatContact;
+ HANDLE hChatContact = NULL;
// RM TODO: better use check if chatroom exists/is in db/is online... no?
/// e.g. HANDLE hChatContact = proto->ChatIDToHContact(thread_id); ?
@@ -593,7 +593,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
if (time_ == NULL)
continue;
JSONNODE *time = json_get(time_, "time");
- if (time == NULL || text == NULL || url == NULL || alert_id == NULL || time == NULL)
+ if (time == NULL || text == NULL || url == NULL || alert_id == NULL)
continue;
unsigned __int64 timestamp = json_as_float(time);
@@ -659,7 +659,6 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
JSONNODE *time_ = json_get(it, "actor");
JSONNODE *story_ = json_get(it, "story_xhp");
- std::string id = json_as_pstring(actor_);
time_t time = json_as_float(time_);
std::string text = json_as_pstring(story_);
text = utils::text::slashu_to_utf8(text);
@@ -711,7 +710,6 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
JSONNODE *alert_ids = json_get(it, "alert_ids");
for (unsigned int n = 0; n < json_size(alert_ids); n++) {
JSONNODE *idItr = json_at(alert_ids, n);
- std::string alert_id = json_as_pstring(idItr);
// PUDeletePopup(hWndPopup);
}
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 866bc8cf00..e4731c0111 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -357,7 +357,7 @@ void FacebookProto::ProcessUnreadMessage(void *p)
for (std::map<std::string, facebook_chatroom*>::iterator it = chatrooms.begin(); it != chatrooms.end(); ) {
facebook_chatroom *room = it->second;
- HANDLE hChatContact;
+ HANDLE hChatContact = NULL;
if (GetChatUsers(room->thread_id.c_str()) == NULL) {
AddChat(room->thread_id.c_str(), room->chat_name.c_str());
hChatContact = ChatIDToHContact(room->thread_id);
@@ -366,7 +366,7 @@ void FacebookProto::ProcessUnreadMessage(void *p)
for (std::map<std::string, std::string>::iterator jt = room->participants.begin(); jt != room->participants.end(); ) {
AddChatContact(room->thread_id.c_str(), jt->first.c_str(), jt->second.c_str());
- jt++;
+ ++jt;
}
}
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 834f096c3d..86ab425c2d 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -63,12 +63,9 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
// Create standard network connection
TCHAR descr[512];
- char module[512];
NETLIBUSER nlu = {sizeof(nlu)};
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
nlu.szSettingsModule = m_szModuleName;
- mir_snprintf(module, SIZEOF(module), "%s", m_szModuleName);
- nlu.szSettingsModule = module;
mir_sntprintf(descr, SIZEOF(descr), TranslateT("%s server connection"), m_tszUserName);
nlu.ptszDescriptiveName = descr;
m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
@@ -726,8 +723,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
{
// After close, free
popup_data *data = (popup_data *)PUGetPluginData(hwnd);
- if (data != NULL)
- delete data;
+ delete data;
} return FALSE;
default:
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index ad7933052f..0845a550be 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -97,7 +97,7 @@ int GGPROTO::gc_destroy()
for(l = chats; l; l = l->next)
{
GGGC *chat = (GGGC *)l->data;
- if (chat->recipients) free(chat->recipients);
+ free(chat->recipients);
}
list_destroy(chats, 1); chats = NULL;
return 1;
@@ -606,7 +606,7 @@ INT_PTR GGPROTO::gc_clearignored(WPARAM wParam, LPARAM lParam)
l = l->next;
if (chat->ignore)
{
- if (chat->recipients) free(chat->recipients);
+ free(chat->recipients);
list_remove(&chats, chat, 1);
cleared = TRUE;
}
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp
index 88efe07a86..abcd765e88 100644
--- a/protocols/Gadu-Gadu/src/image.cpp
+++ b/protocols/Gadu-Gadu/src/image.cpp
@@ -139,12 +139,10 @@ static int gg_img_releasepicture(void *img)
{
if (!img)
return FALSE;
- if (((GGIMAGEENTRY *)img)->lpszFileName)
- free(((GGIMAGEENTRY *)img)->lpszFileName);
+ free(((GGIMAGEENTRY *)img)->lpszFileName);
if (((GGIMAGEENTRY *)img)->hBitmap)
DeleteObject(((GGIMAGEENTRY *)img)->hBitmap);
- if (((GGIMAGEENTRY *)img)->lpData)
- free(((GGIMAGEENTRY *)img)->lpData);
+ free(((GGIMAGEENTRY *)img)->lpData);
free(img);
return TRUE;
@@ -1067,10 +1065,8 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName)
debugLogA("img_loadpicture(): MS_IMG_LOAD(MEM) failed.");
if (dat)
{
- if (dat->lpData)
- free(dat->lpData);
- if (dat->lpszFileName)
- free(dat->lpszFileName);
+ free(dat->lpData);
+ free(dat->lpszFileName);
free(dat);
}
return NULL;
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 523d077111..1ac699ffcd 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -237,14 +237,14 @@ void GGPROTO::parsecontacts(char *contacts)
}
// Release stuff
- if (strFirstName) free(strFirstName);
- if (strLastName) free(strLastName);
- if (strNickname) free(strNickname);
- if (strNick) free(strNick);
- if (strPhone) free(strPhone);
- if (strGroup) free(strGroup);
- if (strUin) free(strUin);
- if (strMail) free(strMail);
+ free(strFirstName);
+ free(strLastName);
+ free(strNickname);
+ free(strNick);
+ free(strPhone);
+ free(strGroup);
+ free(strUin);
+ free(strMail);
}
}
diff --git a/protocols/Gadu-Gadu/src/libgadu/common.c b/protocols/Gadu-Gadu/src/libgadu/common.c
index b9b41c0547..f1db6c4b7f 100644
--- a/protocols/Gadu-Gadu/src/libgadu/common.c
+++ b/protocols/Gadu-Gadu/src/libgadu/common.c
@@ -366,7 +366,7 @@ char *gg_read_line(SOCKET sock, char *buf, int length)
*
* \ingroup helper
*/
-#ifdef GG_CONFIG_MIRANDA
+#ifdef GG_CONFIG_MIRANDA
SOCKET gg_connect_internal(void *addr, int port, int async, SOCKET *gg_sock)
#else
SOCKET gg_connect(void *addr, int port, int async)
@@ -398,8 +398,8 @@ SOCKET gg_connect(void *addr, int port, int async)
return -1;
}
-#ifdef GG_CONFIG_MIRANDA
- if (gg_sock) *gg_sock = sock;
+#ifdef GG_CONFIG_MIRANDA
+ if (gg_sock) *gg_sock = sock;
#endif
if (async) {
@@ -435,7 +435,7 @@ SOCKET gg_connect(void *addr, int port, int async)
return sock;
}
-#ifdef GG_CONFIG_MIRANDA
+#ifdef GG_CONFIG_MIRANDA
SOCKET gg_connect(void *addr, int port, int async)
{
return gg_connect_internal(addr, port, async, 0);
@@ -541,7 +541,7 @@ int gg_http_hash(const char *format, ...)
char *arg, buf[16];
if (format[j] == 'u') {
- snprintf(buf, sizeof(buf), "%d", va_arg(ap, uin_t));
+ mir_snprintf(buf, sizeof(buf), "%d", va_arg(ap, uin_t));
arg = buf;
} else {
if (!(arg = va_arg(ap, char*)))
diff --git a/protocols/Gadu-Gadu/src/libgadu/dcc7.c b/protocols/Gadu-Gadu/src/libgadu/dcc7.c
index f3813e6e83..fcfefa0500 100644
--- a/protocols/Gadu-Gadu/src/libgadu/dcc7.c
+++ b/protocols/Gadu-Gadu/src/libgadu/dcc7.c
@@ -330,7 +330,7 @@ static int gg_dcc7_listen_and_send_info(struct gg_dcc7 *dcc)
// we MUST fill hash to recive from server request for server connection
//snprintf((char*) pkt.hash, sizeof(pkt.hash), "0");
count = dcc->local_addr + external_port * rand();
- snprintf((char*) pkt.hash, sizeof(pkt.hash), "%d", count);
+ mir_snprintf(pkt.hash, sizeof(pkt.hash), "%d", count);
return gg_send_packet(dcc->sess, GG_DCC7_INFO, &pkt, sizeof(pkt), NULL);
}
diff --git a/protocols/Gadu-Gadu/src/libgadu/pubdir.c b/protocols/Gadu-Gadu/src/libgadu/pubdir.c
index f9d656dfe3..c74ff4f309 100644
--- a/protocols/Gadu-Gadu/src/libgadu/pubdir.c
+++ b/protocols/Gadu-Gadu/src/libgadu/pubdir.c
@@ -735,7 +735,7 @@ int gg_token_watch_fd(struct gg_http *h)
gg_debug(GG_DEBUG_MISC, "=> token body \"%s\"\n", h->body);
- if (h->body && (!(url = malloc(strlen(h->body))) || !(tokenid = malloc(strlen(h->body))))) {
+ if (h->body && (!(url = (char*)malloc(strlen(h->body) + 1)) || !(tokenid = (char*)malloc(strlen(h->body) + 1)))) {
gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for results\n");
free(url);
return -1;
diff --git a/protocols/Gadu-Gadu/src/ownerinfo.cpp b/protocols/Gadu-Gadu/src/ownerinfo.cpp
index a8f56eb856..25bb183156 100644
--- a/protocols/Gadu-Gadu/src/ownerinfo.cpp
+++ b/protocols/Gadu-Gadu/src/ownerinfo.cpp
@@ -39,7 +39,7 @@ void __cdecl GGPROTO::remindpasswordthread(void *param)
debugLogA("remindpasswordthread(): Started.");
if (!rp || !rp->email || !rp->uin || !strlen(rp->email))
{
- if (rp) free(rp);
+ free(rp);
#ifdef DEBUGMODE
debugLogA("remindpasswordthread(): End. err1");
#endif
@@ -68,7 +68,7 @@ void __cdecl GGPROTO::remindpasswordthread(void *param)
MessageBox(NULL, TranslateT("Password was sent to your e-mail."), m_tszUserName, MB_OK | MB_ICONINFORMATION);
}
- if (rp) free(rp);
+ free(rp);
#ifdef DEBUGMODE
debugLogA("remindpasswordthread(): End.");
#endif