Skip to content

Commit

Permalink
codechange - fixed some compiler/analysis warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed May 23, 2022
1 parent 075dd6f commit 59977b6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions source/server/ScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,13 +1089,13 @@ void ServerScript::setUserColourNum(int uid, int num) {

std::string ServerScript::getUserToken(int uid) {
Client *c = seq->getClient(uid);
if (!c) return 0;
if (!c) return "";
return std::string(c->user.usertoken, 40);
}

std::string ServerScript::getUserVersion(int uid) {
Client *c = seq->getClient(uid);
if (!c) return 0;
if (!c) return "";
return std::string(c->user.clientversion, 25);
}

Expand Down Expand Up @@ -1187,7 +1187,7 @@ std::string ServerScript::get_IPAddr() { return Config::getIPAddr(); }

unsigned int ServerScript::get_listenPort() { return Config::getListenPort(); }

int ServerScript::get_serverMode() { return Config::getServerMode(); }
int ServerScript::get_serverMode() { return (int)Config::getServerMode(); }

std::string ServerScript::get_owner() { return Config::getOwner(); }

Expand Down
10 changes: 8 additions & 2 deletions source/server/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ along with Foobar. If not, see <http://www.gnu.org/licenses/>.
#include <cstdio>
#include <cstdarg>
#include <mutex>
#include <sstream>
#include <thread>

#ifndef _WIN32
Expand Down Expand Up @@ -67,8 +68,12 @@ namespace Logger {
strftime(time_str, 20, "%d-%m-%Y %H:%M:%S", localtime(&current_time));
const char *level_str = s_log_level_names[(int) level];

std::stringstream tid_ss;
tid_ss << std::this_thread::get_id();
std::string tid_str = tid_ss.str();

if (level >= s_log_level[LOGTYPE_DISPLAY]) {
printf("%s|t%02d|%5s|%s\n", time_str, std::this_thread::get_id(), level_str, msg);
printf("%s|t%s|%5s|%s\n", time_str, tid_str.c_str(), level_str, msg);
}

std::lock_guard<std::mutex> scoped_lock(s_log_mutex);
Expand All @@ -83,7 +88,8 @@ namespace Logger {
freopen(s_log_filename.c_str(), "a+", s_file);
}
#endif // _WIN32
fprintf(s_file, "%s|t%02d|%5s| %s\n", time_str, std::this_thread::get_id(), level_str, msg);

fprintf(s_file, "%s|t%s|%5s| %s\n", time_str, tid_str.c_str(), level_str, msg);
fflush(s_file);
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/server/messaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace Messaging {
if (head.size > 0) {
//read the rest
std::memset(out_payload, 0, payload_buf_len);
if (socket->frecv(out_payload, head.size, &error) < head.size) {
if (socket->frecv(out_payload, head.size, &error) < (int)head.size) {
return -1;
}
}
Expand Down
1 change: 1 addition & 0 deletions source/server/userauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ int UserAuth::readConfig(const char *authFile) {
Logger::Log(LOG_ERROR, "error parsing authorizations file: " + std::string(line));
continue;
}
token[255] = '\0';

// Seek to username
char* c = line;
Expand Down

0 comments on commit 59977b6

Please sign in to comment.