From 3188738be5ee78651e31c1340fac7fed81bbefb5 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 7 Jan 2016 16:47:24 +0100 Subject: Removed several unnecessary RFIFOP typecasts - While this is arguable, those explicit typecasts are potentially dangerous/misleading (for example, a const specifier might get accidentally dropped without even generating a compiler warning, or a variable type might change during code changes, and any related warning would get silenced by the explicit typecast). - As a reminder Hercules is written in C, and not in C++ (and there's no such thing as "compiling in C++ mode" - they're two different languages.) As such, it is legal to let the compiler automatically promote void* from/to any non-const pointer type, as well as const void* from/to any const pointer type. Signed-off-by: Haru --- src/login/account_sql.c | 4 ++-- src/login/login.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/login') diff --git a/src/login/account_sql.c b/src/login/account_sql.c index cb6fdba99..be797c443 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -719,7 +719,7 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { for (i = 0; i < count; i++) { unsigned int index; int len = RFIFOB(fd, cursor); - safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); + safestrncpy(key, RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); cursor += len + 1; index = RFIFOL(fd, cursor); @@ -739,7 +739,7 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { /* str */ case 2: len = RFIFOB(fd, cursor); - safestrncpy(sval, (char*)RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); + safestrncpy(sval, RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); cursor += len + 1; if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%d','%s','%u','%s')", db->global_acc_reg_str_db, account_id, key, index, sval) ) Sql_ShowDebug(sql_handle); diff --git a/src/login/login.c b/src/login/login.c index 8181cdae9..cedaeec2b 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -352,7 +352,7 @@ void login_fromchar_parse_request_change_email(int fd, int id, const char *const char email[40]; int account_id = RFIFOL(fd,2); - safestrncpy(email, (char*)RFIFOP(fd,6), 40); remove_control_chars(email); + safestrncpy(email, RFIFOP(fd,6), 40); remove_control_chars(email); RFIFOSKIP(fd,46); if( e_mail_check(email) == 0 ) @@ -449,8 +449,8 @@ void login_fromchar_parse_change_email(int fd, int id, const char *const ip) char new_email[40]; int account_id = RFIFOL(fd,2); - safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); - safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); + safestrncpy(actual_email, RFIFOP(fd,6), 40); + safestrncpy(new_email, RFIFOP(fd,46), 40); RFIFOSKIP(fd, 86); if( e_mail_check(actual_email) == 0 ) @@ -699,7 +699,7 @@ void login_fromchar_parse_change_pincode(int fd) struct mmo_account acc; if (accounts->load_num(accounts, &acc, RFIFOL(fd,2))) { - safestrncpy(acc.pincode, (char*)RFIFOP(fd,6), sizeof(acc.pincode)); + safestrncpy(acc.pincode, RFIFOP(fd,6), sizeof(acc.pincode)); acc.pincode_change = ((unsigned int)time(NULL)); accounts->save(accounts, &acc); } @@ -1429,8 +1429,8 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char // Shinryo: For the time being, just use token as password. if(command == 0x0825) { - const char *accname = (char *)RFIFOP(fd, 9); - const char *token = (char *)RFIFOP(fd, 0x5C); + const char *accname = RFIFOP(fd, 9); + const char *token = RFIFOP(fd, 0x5C); size_t uAccLen = strlen(accname); size_t uTokenLen = RFIFOREST(fd) - 0x5C; @@ -1448,10 +1448,10 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char else { version = RFIFOL(fd,2); - safestrncpy(username, (const char*)RFIFOP(fd,6), NAME_LENGTH); + safestrncpy(username, RFIFOP(fd,6), NAME_LENGTH); if( israwpass ) { - safestrncpy(password, (const char*)RFIFOP(fd,30), NAME_LENGTH); + safestrncpy(password, RFIFOP(fd,30), NAME_LENGTH); clienttype = RFIFOB(fd,54); } else @@ -1534,15 +1534,15 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const uint16 new_; int result; - safestrncpy(sd->userid, (char*)RFIFOP(fd,2), NAME_LENGTH); - safestrncpy(sd->passwd, (char*)RFIFOP(fd,26), NAME_LENGTH); + safestrncpy(sd->userid, RFIFOP(fd,2), NAME_LENGTH); + safestrncpy(sd->passwd, RFIFOP(fd,26), NAME_LENGTH); if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; sd->version = login->config->client_version_to_connect; // hack to skip version check server_ip = ntohl(RFIFOL(fd,54)); server_port = ntohs(RFIFOW(fd,58)); - safestrncpy(server_name, (char*)RFIFOP(fd,60), 20); + safestrncpy(server_name, RFIFOP(fd,60), 20); type = RFIFOW(fd,82); new_ = RFIFOW(fd,84); RFIFOSKIP(fd,86); -- cgit v1.2.3-60-g2f50