summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-01-20 04:36:08 +0100
committerHaru <haru@dotalux.com>2015-01-20 04:41:33 +0100
commit4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4 (patch)
treedab9d12a6a4b95a37598e27e6e86d6047360d61b /src/login
parent03709c136ad300be631adfd38dc36c2433bda718 (diff)
downloadhercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.gz
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.bz2
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.tar.xz
hercules-4ae2b9b72dd4fce3d7a7778222d1c39abbb564a4.zip
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 <haru@dotalux.com>
Diffstat (limited to 'src/login')
-rw-r--r--src/login/account_sql.c6
-rw-r--r--src/login/login.c15
2 files changed, 9 insertions, 12 deletions
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index adbb7914d..f745d3d13 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -666,12 +666,12 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
AccountDB_SQL* db = (AccountDB_SQL*)self;
int count = RFIFOW(fd, 12);
- if( count ) {
+ if (count) {
int cursor = 14, i;
char key[32], sval[254];
- unsigned int index;
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
+ unsigned int index;
safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
cursor += RFIFOB(fd, cursor) + 1;
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;