From 4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4 Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 20 Jan 2015 04:36:08 +0100 Subject: Minor fixes and tweaks suggested by cppcheck - Variable scopes reduced - Parenthesized ambiguous expressions - Removed or added NULL checks where (un)necessary - Corrected format strings - Fixed typos potentially leading to bugs Signed-off-by: Haru --- src/login/login.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/login/login.c') diff --git a/src/login/login.c b/src/login/login.c index 036456a85..846f24027 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -677,14 +677,12 @@ void login_fromchar_parse_account_offline(int fd) void login_fromchar_parse_online_accounts(int fd, int id) { - struct online_login_data *p; - int aid; uint32 i, users; login->online_db->foreach(login->online_db, login->online_db_setoffline, id); //Set all chars from this char-server offline first users = RFIFOW(fd,4); for (i = 0; i < users; i++) { - aid = RFIFOL(fd,6+i*4); - p = idb_ensure(login->online_db, aid, login->create_online_user); + int aid = RFIFOL(fd,6+i*4); + struct online_login_data *p = idb_ensure(login->online_db, aid, login->create_online_user); p->char_server = id; if (p->waiting_disconnect != INVALID_TIMER) { @@ -734,15 +732,14 @@ bool login_fromchar_parse_wrong_pincode(int fd) struct mmo_account acc; if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) { - struct online_login_data* ld; + struct online_login_data* ld = (struct online_login_data*)idb_get(login->online_db,acc.account_id); - if( ( ld = (struct online_login_data*)idb_get(login->online_db,acc.account_id) ) == NULL ) - { + if (ld == NULL) { RFIFOSKIP(fd,6); return true; } - login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" ); + login_log(host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed"); } login->remove_online_user(acc.account_id); @@ -1814,12 +1811,12 @@ int login_config_read(const char* cfgName) if (sscanf(w2, "%d, %32s", &group, md5) == 2) { struct client_hash_node *nnode; - int i; CREATE(nnode, struct client_hash_node, 1); if (strcmpi(md5, "disabled") == 0) { nnode->hash[0] = '\0'; } else { + int i; for (i = 0; i < 32; i += 2) { char buf[3]; unsigned int byte; -- cgit v1.2.3-60-g2f50