Commit e63427c2 authored by Steffen Vogel's avatar Steffen Vogel

fix a lot of compiler warnings thrown by newer GCC versions

mostly warnings about:
 - comparison differing in signedness
 - unused functions and variables
 - some casts
parent 7ec96a10
......@@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <string.h>
#include "frotz.h"
extern void stream_char (zchar);
......
......@@ -21,6 +21,7 @@
#include "frotz.h"
extern int save_undo (void);
extern int os_read_mouse (void);
extern zchar stream_read_key (zword, zword, bool);
extern zchar stream_read_input (int, zchar *, zword, zword, bool, bool);
......
......@@ -32,9 +32,12 @@
#define cdecl
#endif
extern void interpret (void);
extern void init_memory (void);
extern void init_undo (void);
extern void init_sound (void);
extern void init_buffer (void);
extern void init_process (void);
extern void interpret (void);
extern void reset_memory (void);
/* Story file name, id number and size */
......
......@@ -64,7 +64,7 @@ static int zoptopt = 0;
static char *zoptarg = NULL;
static int zgetopt (int argc, char *argv[], const char *options)
{
static pos = 1;
static int pos = 1;
const char *p;
if (zoptind >= argc || argv[zoptind][0] != '-' || argv[zoptind][1] == 0)
return EOF;
......@@ -76,7 +76,7 @@ static int zgetopt (int argc, char *argv[], const char *options)
if (zoptopt == ':' || p == NULL) {
fputs ("illegal option -- ", stderr);
goto error;
} else if (p[1] == ':')
} else if (p[1] == ':') {
if (zoptind >= argc) {
fputs ("option requires an argument -- ", stderr);
goto error;
......@@ -86,6 +86,7 @@ static int zgetopt (int argc, char *argv[], const char *options)
zoptarg += pos;
pos = 1; zoptind++;
}
}
return zoptopt;
error:
fputc (zoptopt, stderr);
......@@ -201,8 +202,6 @@ void os_fatal (const char *s)
FILE *os_path_open(const char *name, const char *mode)
{
FILE *fp;
char buf[FILENAME_MAX + 1];
char *p;
/* Let's see if the file is in the currect directory */
/* or if the user gave us a full path. */
......
......@@ -248,7 +248,7 @@ static bool dumb_read_line(char *s, char *prompt, bool show_cursor,
if (type != INPUT_LINE_CONTINUED)
fprintf(stderr, "DUMB-FROTZ: No input to discard\n");
else {
dumb_discard_old_input(strlen(continued_line_chars));
dumb_discard_old_input(strlen((char *) continued_line_chars));
continued_line_chars[0] = '\0';
type = INPUT_LINE;
}
......@@ -262,7 +262,7 @@ static bool dumb_read_line(char *s, char *prompt, bool show_cursor,
int i;
for (i = 0; (i < h_screen_rows - 2) && *next_page; i++)
next_page = strchr(next_page, '\n') + 1;
printf("%.*s", next_page - current_page, current_page);
printf("%.*s", (int) (next_page - current_page), current_page);
current_page = next_page;
if (!*current_page)
break;
......@@ -369,7 +369,7 @@ zchar os_read_line (int max, zchar *buf, int timeout, int width, int continued)
dumb_display_user_input(read_line_buffer);
/* copy to the buffer and save the rest for next time. */
strcat(buf, read_line_buffer);
strcat((char *) buf, read_line_buffer);
p = read_line_buffer + strlen(read_line_buffer) + 1;
memmove(read_line_buffer, p, strlen(p) + 1);
......@@ -385,7 +385,6 @@ zchar os_read_line (int max, zchar *buf, int timeout, int width, int continued)
int os_read_file_name (char *file_name, const char *default_name, int flag)
{
char buf[INPUT_BUFFER_SIZE], prompt[INPUT_BUFFER_SIZE];
FILE *fp;
sprintf(prompt, "Please enter a filename [%s]: ", default_name);
dumb_read_misc_line(buf, prompt);
......@@ -397,6 +396,7 @@ int os_read_file_name (char *file_name, const char *default_name, int flag)
strcpy (file_name, buf[0] ? buf : default_name);
/* Warn if overwriting a file. */
// FILE *fp;
// if ((flag == FILE_SAVE || flag == FILE_SAVE_AUX || flag == FILE_RECORD)
// && ((fp = fopen(file_name, "rb")) != NULL)) {
// fclose (fp);
......@@ -427,4 +427,6 @@ void dumb_init_input(void)
zword os_read_mouse(void)
{
/* NOT IMPLEMENTED */
return 0;
}
......@@ -132,7 +132,7 @@ void os_set_text_style(int x)
static void dumb_display_char(char c)
{
dumb_set_cell(cursor_row, cursor_col, make_cell(current_style, c));
if (++cursor_col == h_screen_cols)
if (++cursor_col == h_screen_cols) {
if (cursor_row == h_screen_rows - 1)
cursor_col--;
else {
......@@ -140,6 +140,7 @@ static void dumb_display_char(char c)
cursor_col = 0;
}
}
}
void dumb_display_user_input(char *s)
{
......
......@@ -1440,6 +1440,7 @@ struct Dis {
std::string protocol;
};
__attribute__ ((unused))
static gboolean disconnectMe(void *data) {
Dis *d = (Dis *) data;
PurpleAccount *account = purple_accounts_find_wrapped(d->name.c_str(), d->protocol.c_str());
......@@ -2300,10 +2301,10 @@ int main(int argc, char **argv) {
purple_timeout_add_seconds_wrapped(30, pingTimeout, NULL);
np = new SpectrumNetworkPlugin();
bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";
GMainLoop *m_loop;
#ifdef WITH_LIBEVENT
bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";
if (!libev) {
m_loop = g_main_loop_new(NULL, FALSE);
}
......
......@@ -207,6 +207,9 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
case Swift::ClientError::InvalidCertificateSignatureError: message = ("Invalid certificate signature"); break;
case Swift::ClientError::InvalidCAError: message = ("Invalid Certificate Authority"); break;
case Swift::ClientError::InvalidServerIdentityError: message = ("Certificate does not match the host identity"); break;
case Swift::ClientError::CertificateCardRemoved: message = ("Certificate card has been removed"); break;
case Swift::ClientError::RevokedError: message = ("Certificate has been revoked"); break;
case Swift::ClientError::RevocationCheckFailedError: message = ("Certificate revocation check has failed"); break;
}
}
LOG4CXX_INFO(logger, user << ": Disconnected " << message);
......
......@@ -23,7 +23,7 @@ void FetchFriends::run()
req.init();
req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
for(int i=0 ; i<friends.size() ; i++) {
for(unsigned i=0 ; i<friends.size() ; i++) {
std::string img;
friendAvatars.push_back("");
if(req.GET(friends[i].getProfileImgURL(), img)) friendAvatars[i] = img;
......
......@@ -213,7 +213,7 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
std::string cmd = "", data = "";
/** Parsing the message - Assuming message format to be <cmd>[ ]*<data>**/
int i;
unsigned i;
for(i=0 ; i<message.size() && message[i] != ' '; i++) cmd += message[i];
while(i<message.size() && message[i] == ' ') i++;
data = message.substr(i);
......@@ -652,7 +652,7 @@ void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends
{
if(errMsg.getMessage().length() == 0)
{
for(int i=0 ; i<friends.size() ; i++) {
for(unsigned i=0 ; i<friends.size() ; i++) {
userdb[user].buddies.insert(friends[i].getScreenName());
userdb[user].buddiesInfo[friends[i].getScreenName()] = friends[i];
userdb[user].buddiesImgs[friends[i].getScreenName()] = friendAvatars[i];
......@@ -691,7 +691,7 @@ void TwitterPlugin::displayFriendlist(std::string &user, std::vector<User> &frie
if(errMsg.getMessage().length() == 0)
{
std::string userlist = "\n***************USER LIST****************\n";
for(int i=0 ; i < friends.size() ; i++) {
for(unsigned i=0 ; i < friends.size() ; i++) {
userlist += " - " + friends[i].getUserName() + " (" + friends[i].getScreenName() + ")\n";
}
userlist += "***************************************\n";
......@@ -714,7 +714,7 @@ void TwitterPlugin::displayTweets(std::string &user, std::string &userRequested,
std::map<std::string, int> lastTweet;
std::map<std::string, int>::iterator it;
for(int i = tweets.size() - 1 ; i >= 0 ; i--) {
for(unsigned i = tweets.size() - 1 ; i >= 0 ; i--) {
if(userdb[user].twitterMode != CHATROOM) {
std::string m = " - " + tweets[i].getUserData().getScreenName() + ": " + tweets[i].getTweet() + " (MsgId: " + (tweets[i].getRetweetID().empty() ? tweets[i].getID() : tweets[i].getRetweetID()) + ")\n";
handleMessage(user, adminLegacyName, m, "", "", tweets[i].getCreationTime(), true);
......@@ -788,7 +788,7 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
std::string msgID = getMostRecentDMID(user);
std::string maxID = msgID;
for(int i=0 ; i < messages.size() ; i++) {
for(unsigned i=0 ; i < messages.size() ; i++) {
if(cmp(msgID, messages[i].getID()) == -1) {
msglist += " - " + messages[i].getSenderData().getScreenName() + ": " + messages[i].getMessage() + "\n";
if(cmp(maxID, messages[i].getID()) == -1) maxID = messages[i].getID();
......@@ -803,7 +803,7 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
std::string msgID = getMostRecentDMID(user);
std::string maxID = msgID;
for(int i=0 ; i < messages.size() ; i++) {
for(unsigned i=0 ; i < messages.size() ; i++) {
if(cmp(msgID, messages[i].getID()) == -1) {
if(userdb[user].twitterMode == MULTIPLECONTACT)
handleMessage(user, messages[i].getSenderData().getScreenName(), messages[i].getMessage(), "");
......
......@@ -10,7 +10,7 @@ DEFINE_LOGGER(logger, "TwitterResponseParser")
static std::string tolowercase(std::string inp)
{
std::string out = inp;
for(int i=0 ; i<out.size() ; i++) out[i] = tolower(out[i]);
for(unsigned i=0 ; i<out.size() ; i++) out[i] = tolower(out[i]);
return out;
}
......@@ -246,7 +246,7 @@ std::vector<std::string> getIDs(std::string &json)
const rapidjson::Value & ids = rootElement[TwitterReponseTypes::ids.c_str()];
for(int i=0 ; i<ids.Size() ; i++) {
for(unsigned i=0 ; i<ids.Size() ; i++) {
IDs.push_back(stringOf( ids[i].GetInt64()) );
}
return IDs;
......
......@@ -127,9 +127,9 @@ class MySQLBackend : public StorageBackend
MYSQL *m_conn;
std::vector<MYSQL_BIND> m_params;
std::vector<MYSQL_BIND> m_results;
int m_resultOffset;
int m_offset;
int m_error;
unsigned m_resultOffset;
unsigned m_offset;
std::string m_string;
};
......
......@@ -41,6 +41,7 @@ namespace Transport {
DEFINE_LOGGER(logger, "AdminInterface");
__attribute__ ((unused))
static std::string getArg(const std::string &body) {
std::string ret;
if (body.find(" ") == std::string::npos)
......
......@@ -86,7 +86,7 @@ void LocalBuddy::setAlias(const std::string &alias) {
void LocalBuddy::setGroups(const std::vector<std::string> &groups) {
bool changed = m_groups.size() != groups.size();
if (!changed) {
for (int i = 0; i != m_groups.size(); i++) {
for (unsigned i = 0; i != m_groups.size(); i++) {
if (m_groups[i] != groups[i]) {
changed = true;
break;
......
......@@ -102,7 +102,7 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
return;
}
for (int i = 0; i < format.length() && m_resultOffset == -1; i++) {
for (unsigned i = 0; i < format.length() && m_resultOffset == -1; i++) {
switch (format.at(i)) {
case 's':
m_params.resize(m_params.size() + 1);
......@@ -138,7 +138,7 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
}
}
for (int i = m_resultOffset; i >= 0 && i < format.length(); i++) {
for (unsigned i = m_resultOffset; i >= 0 && i < format.length(); i++) {
switch (format.at(i)) {
case 's':
m_results.resize(m_results.size() + 1);
......@@ -186,11 +186,11 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
}
MySQLBackend::Statement::~Statement() {
for (int i = 0; i < m_params.size(); i++) {
for (unsigned i = 0; i < m_params.size(); i++) {
free(m_params[i].buffer);
free(m_params[i].length);
}
for (int i = 0; i < m_results.size(); i++) {
for (unsigned i = 0; i < m_results.size(); i++) {
free(m_results[i].buffer);
free(m_results[i].length);
}
......
......@@ -1317,7 +1317,7 @@ void NetworkPluginServer::pingTimeout() {
// reconnect them to long-running backend, where they can idle hapilly till the end of ages.
time_t now = time(NULL);
std::vector<User *> usersToMove;
unsigned long diff = CONFIG_INT(m_config, "service.idle_reconnect_time");
long diff = CONFIG_INT(m_config, "service.idle_reconnect_time");
if (diff != 0) {
for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
// Users from long-running backends can't be moved
......@@ -2060,7 +2060,7 @@ static void __unblock_signals ( void )
NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient(bool acceptUsers, bool longRun, bool check) {
NetworkPluginServer::Backend *c = NULL;
unsigned long diff = CONFIG_INT(m_config, "service.login_delay");
long diff = CONFIG_INT(m_config, "service.login_delay");
time_t now = time(NULL);
if (diff && (now - m_lastLogin < diff)) {
m_loginTimer->stop();
......@@ -2077,11 +2077,11 @@ NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient(bool acceptUser
// Check all backends and find free one
for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
if ((*it)->willDie == false && (*it)->acceptUsers == acceptUsers && (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection && (*it)->longRun == longRun) {
if ((*it)->willDie == false && (*it)->acceptUsers == acceptUsers && (int) (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection && (*it)->longRun == longRun) {
c = *it;
// if we're not reusing all backends and backend is full, stop accepting new users on this backend
if (!CONFIG_BOOL(m_config, "service.reuse_old_backends")) {
if (!check && c->users.size() + 1 >= CONFIG_INT(m_config, "service.users_per_backend")) {
if (!check && (int) c->users.size() + 1 >= CONFIG_INT(m_config, "service.users_per_backend")) {
c->acceptUsers = false;
}
}
......
......@@ -52,7 +52,7 @@ StorageBackend *StorageBackend::createBackend(Config *config, std::string &error
std::string StorageBackend::encryptPassword(const std::string &password, const std::string &key) {
std::string encrypted;
encrypted.resize(password.size());
for (int i = 0; i < password.size(); i++) {
for (unsigned i = 0; i < password.size(); i++) {
char c = password[i];
char keychar = key[i % key.size()];
c += keychar;
......@@ -67,7 +67,7 @@ std::string StorageBackend::decryptPassword(std::string &encrypted, const std::s
encrypted = Swift::byteArrayToString(Swift::Base64::decode(encrypted));
std::string password;
password.resize(encrypted.size());
for (int i = 0; i < encrypted.size(); i++) {
for (unsigned i = 0; i < encrypted.size(); i++) {
char c = encrypted[i];
char keychar = key[i % key.size()];
c -= keychar;
......
......@@ -183,7 +183,7 @@ std::string SlackAPI::getOwnerId(HTTPRequest *req, bool ok, rapidjson::Document
return "";
}
for (int i = 0; i < members.Size(); i++) {
for (unsigned i = 0; i < members.Size(); i++) {
if (!members[i].IsObject()) {
continue;
}
......@@ -231,7 +231,7 @@ void SlackAPI::getSlackChannelInfo(HTTPRequest *req, bool ok, rapidjson::Documen
info.name = name;
rapidjson::Value &members = channel["members"];
for (int y = 0; members.IsArray() && y < members.Size(); y++) {
for (unsigned y = 0; members.IsArray() && y < members.Size(); y++) {
if (!members[y].IsString()) {
continue;
}
......@@ -244,7 +244,7 @@ void SlackAPI::getSlackChannelInfo(HTTPRequest *req, bool ok, rapidjson::Documen
return;
}
for (int i = 0; i < channels.Size(); i++) {
for (unsigned i = 0; i < channels.Size(); i++) {
if (!channels[i].IsObject()) {
continue;
}
......@@ -258,7 +258,7 @@ void SlackAPI::getSlackChannelInfo(HTTPRequest *req, bool ok, rapidjson::Documen
info.name = name;
rapidjson::Value &members = channels[i]["members"];
for (int y = 0; members.IsArray() && y < members.Size(); y++) {
for (unsigned y = 0; members.IsArray() && y < members.Size(); y++) {
if (!members[y].IsString()) {
continue;
}
......@@ -280,7 +280,7 @@ void SlackAPI::getSlackImInfo(HTTPRequest *req, bool ok, rapidjson::Document &re
GET_ARRAY(resp, ims);
for (int i = 0; i < ims.Size(); i++) {
for (unsigned i = 0; i < ims.Size(); i++) {
if (!ims[i].IsObject()) {
continue;
}
......@@ -308,7 +308,7 @@ void SlackAPI::getSlackUserInfo(HTTPRequest *req, bool ok, rapidjson::Document &
GET_ARRAY(resp, users);
for (int i = 0; i < users.Size(); i++) {
for (unsigned i = 0; i < users.Size(); i++) {
if (!users[i].IsObject()) {
continue;
}
......@@ -337,7 +337,7 @@ void SlackAPI::getSlackUserInfo(HTTPRequest *req, bool ok, rapidjson::Document &
GET_ARRAY(resp, bots);
for (int i = 0; i < bots.Size(); i++) {
for (unsigned i = 0; i < bots.Size(); i++) {
if (!bots[i].IsObject()) {
continue;
}
......
......@@ -119,7 +119,7 @@ void SlackRTM::handlePayloadReceived(const std::string &payload) {
rapidjson::Value &attachments = d["attachments"];
if (attachments.IsArray()) {
for (int i = 0; i < attachments.Size(); i++) {
for (unsigned i = 0; i < attachments.Size(); i++) {
STORE_STRING_OPTIONAL(attachments[i], fallback);
if (!fallback.empty()) {
text += fallback;
......
......@@ -60,7 +60,7 @@ void DiscoItemsResponder::addAdHocCommand(const std::string &node, const std::st
}
void DiscoItemsResponder::addRoom(const std::string &node, const std::string &name) {
if (m_rooms->getItems().size() > CONFIG_INT(m_component->getConfig(), "service.max_room_list_size")) {
if ((int) m_rooms->getItems().size() > CONFIG_INT(m_component->getConfig(), "service.max_room_list_size")) {
return;
}
m_rooms->addItem(DiscoItems::Item(name, node));
......
......@@ -78,6 +78,7 @@ BOOL spectrum_control_handler( DWORD fdwCtrlType ) {
}
#endif
__attribute__ ((unused))
static void removeOldIcons(std::string iconDir) {
std::vector<std::string> dirs;
dirs.push_back(iconDir);
......
......@@ -242,7 +242,6 @@ void APIServer::serve_instances_register(Server *server, Server::session *sessio
response = server->send_command(instance, "register " + jid + " " + uin + " " + password);
if (!response.empty()) {
std::string value = jid;
int type = (int) TYPE_STRING;
m_storage->updateUserSetting(info.id, instance, value);
send_ack(conn, false, response);
}
......
......@@ -156,7 +156,6 @@ int main(int argc, char **argv)
float elapsed = 0;
gettimeofday(&td_start, NULL);
time_t started = time(NULL);
while(get_response().empty()) {
eventLoop.runUntilEvents();
}
......
......@@ -43,7 +43,7 @@ std::string searchForBinary(const std::string &binary) {
if (env_path != NULL) {
std::string buffer = "";
for (int s = 0; s < strlen(env_path); s++) {
for (unsigned s = 0; s < strlen(env_path); s++) {
if (env_path[s] == ':') {
path_list.insert(path_list.end(), std::string(buffer));
buffer = "";
......@@ -619,7 +619,6 @@ std::vector<std::string> show_list(ManagerConfig *config, bool show) {
return list;
}
bool found = false;
directory_iterator end_itr;
for (directory_iterator itr(p); itr != end_itr; ++itr) {
if (is_regular(itr->path()) && extension(itr->path()) == ".cfg") {
......
......@@ -287,7 +287,7 @@ void Server::print_html(struct mg_connection *conn, struct http_message *hm, con
mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Content-Length: %d\r\n" // Always set Content-Length
"Content-Length: %zu\r\n" // Always set Content-Length
"\r\n"
"%s%s%s",
(int) html.size() + m_header.size() + m_footer.size(), m_header.c_str(), html.c_str(), m_footer.c_str());
......@@ -299,13 +299,12 @@ std::string Server::send_command(const std::string &jid, const std::string &cmd,
try {
ask_local_server(m_config, networkFactories, jid, cmd);
struct timeval td_start,td_end;
float elapsed = 0;
struct timeval td_start, td_end;
gettimeofday(&td_start, NULL);
gettimeofday(&td_end, NULL);
time_t started = time(NULL);
while(get_response().empty() && td_end.tv_sec - td_start.tv_sec < timeout) {
while (get_response().empty() && td_end.tv_sec - td_start.tv_sec < timeout) {
gettimeofday(&td_end, NULL);
eventLoop.runOnce();
}
......@@ -400,7 +399,7 @@ void Server::serve_logout(struct mg_connection *conn, struct http_message *hm) {
host += std::string(host_hdr->p, host_hdr->len);
}
Server:session *session = get_session(hm);
Server::session *session = get_session(hm);
mg_printf(conn, "HTTP/1.1 302 Found\r\n"
"Set-Cookie: session=%s; max-age=0\r\n"
"Set-Cookie: admin=%s; max-age=0\r\n"
......@@ -425,7 +424,7 @@ void Server::serve_oauth2(struct mg_connection *conn, struct http_message *hm) {
boost::split(args, response, boost::is_any_of(" "));
std::cerr << "set_oauth2_code response size " << args.size() << "\n";
if (args.size() == 3) {
Server:session *session = get_session(hm);
Server::session *session = get_session(hm);
UserInfo info;
m_storage->getUser(session->user, info);
std::string username = "";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment