diff options
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | include/connection.h | 6 | ||||
-rw-r--r-- | include/dns.h | 4 | ||||
-rw-r--r-- | include/modules.h | 6 | ||||
-rw-r--r-- | src/commands.cpp | 30 | ||||
-rw-r--r-- | src/connection.cpp | 110 | ||||
-rw-r--r-- | src/dns.cpp | 69 | ||||
-rw-r--r-- | src/inspircd.cpp | 92 | ||||
-rw-r--r-- | src/inspircd_io.cpp | 6 | ||||
-rw-r--r-- | src/message.cpp | 12 | ||||
-rw-r--r-- | src/mode.cpp | 22 | ||||
-rw-r--r-- | src/modules/extra/m_sql.cpp | 16 | ||||
-rw-r--r-- | src/modules/extra/m_sqllog.cpp | 36 | ||||
-rw-r--r-- | src/modules/m_antibottler.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_park.cpp | 6 | ||||
-rw-r--r-- | src/users.cpp | 1 | ||||
-rw-r--r-- | src/xline.cpp | 6 |
17 files changed, 190 insertions, 238 deletions
@@ -57,12 +57,12 @@ if [ "$1" = "-update" -o "$2" = "-update" ] ; then case "$OSNAME" in FreeBSD) LDLIBS="-Ldl" - FLAGS="-fPIC -frtti $OPTIMISATI" + FLAGS="-fPIC -frtti $OPTIMISATI -Wcomment -Wformat -Wunused -Wshadow -Werror" MAKEPROG="gmake" ;; *) LDLIBS="-ldl" - FLAGS="-fPIC -frtti $OPTIMISATI" + FLAGS="-fPIC -frtti $OPTIMISATI -Wcomment -Wformat -Wunused -Wshadow -Werror" MAKEPROG="make" ;; esac diff --git a/include/connection.h b/include/connection.h index 444d82d23..304f20cd9 100644 --- a/include/connection.h +++ b/include/connection.h @@ -105,7 +105,7 @@ class ircd_connector : public Extensible /** Create an outbound connection to a listening socket */ - bool MakeOutboundConnection(char* host, int port); + bool MakeOutboundConnection(char* newhost, int newport); /** Return the servername on this established connection */ @@ -156,7 +156,7 @@ class ircd_connector : public Extensible /** Set both the host and the port in one operation for this connection */ - bool SetHostAndPort(char* host, int port); + bool SetHostAndPort(char* newhost, int newport); /** Close the connection by calling close() on its file descriptor * This function call updates no other data. @@ -268,7 +268,7 @@ class connection : public Extensible /** Begin an outbound mesh link to another ircd on a network you are already an authenticated member of */ - bool MeshCookie(char* targethost, int port, long cookie, char* servername); + bool MeshCookie(char* targethost, int port, unsigned long cookie, char* servername); /** Terminate a link to 'targethost' by calling the ircd_connector::CloseConnection method. */ diff --git a/include/dns.h b/include/dns.h index bdc7326bf..034efb930 100644 --- a/include/dns.h +++ b/include/dns.h @@ -35,9 +35,9 @@ struct dns_ip4list { class DNS { private: - char *result; in_addr *binip; - int t,i; + char* result; + int t; void dns_init(); unsigned int fd; void dns_init_2(const char* dnsserver); diff --git a/include/modules.h b/include/modules.h index 78cc2553d..a68b6e9b8 100644 --- a/include/modules.h +++ b/include/modules.h @@ -76,7 +76,7 @@ typedef std::deque<userrec*> chanuserlist; // loaded modules in a readable simple way, e.g.: // 'FOREACH_MOD OnConnect(user);' -#define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]-> +#define FOREACH_MOD for (int _i = 0; _i <= MODCOUNT; _i++) modules[_i]-> // This define is similar to the one above but returns a result in MOD_RESULT. // The first module to return a nonzero result is the value to be accepted, @@ -85,8 +85,8 @@ typedef std::deque<userrec*> chanuserlist; // ********************************************************************************************* #define FOREACH_RESULT(x) { MOD_RESULT = 0; \ - for (int i = 0; i <= MODCOUNT; i++) { \ - int res = modules[i]->x ; \ + for (int _i = 0; _i <= MODCOUNT; _i++) { \ + int res = modules[_i]->x ; \ if (res != 0) { \ MOD_RESULT = res; \ break; \ diff --git a/src/commands.cpp b/src/commands.cpp index 2727be777..8b024544e 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -200,7 +200,6 @@ extern address_cache IP; void handle_join(char **parameters, int pcnt, userrec *user) { chanrec* Ptr; - int i = 0; if (loop_call(handle_join,parameters,pcnt,user,0,0,1)) return; @@ -213,8 +212,6 @@ void handle_join(char **parameters, int pcnt, userrec *user) void handle_part(char **parameters, int pcnt, userrec *user) { - chanrec* Ptr; - if (pcnt > 1) { if (loop_call(handle_part,parameters,pcnt,user,0,pcnt-2,0)) @@ -313,7 +310,6 @@ void handle_die(char **parameters, int pcnt, userrec *user) void handle_restart(char **parameters, int pcnt, userrec *user) { - char restart[1024]; char *argv[32]; log(DEFAULT,"Restart: %s",user->nick); if (!strcmp(parameters[0],restartpass)) @@ -834,7 +830,6 @@ void handle_time(char **parameters, int pcnt, userrec *user) void handle_whois(char **parameters, int pcnt, userrec *user) { userrec *dest; - char *t; if (loop_call(handle_whois,parameters,pcnt,user,0,pcnt-1,0)) return; @@ -1076,8 +1071,6 @@ void handle_wallops(char **parameters, int pcnt, userrec *user) void handle_list(char **parameters, int pcnt, userrec *user) { - chanrec* Ptr; - WriteServ(user->fd,"321 %s Channel :Users Name",user->nick); for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++) { @@ -1593,8 +1586,6 @@ void handle_map(char **parameters, int pcnt, userrec *user) bool is_uline(const char* server) { char ServName[MAXBUF]; - int i,j; - for (int i = 0; i < ConfValueEnum("uline",&config_f); i++) { ConfValue("uline","server",i,ServName,&config_f); @@ -1624,7 +1615,7 @@ void handle_oper(char **parameters, int pcnt, userrec *user) char TypeName[MAXBUF]; char HostName[MAXBUF]; char TheHost[MAXBUF]; - int i,j; + int j; bool found = false; bool fail2 = false; char global[MAXBUF]; @@ -2204,6 +2195,7 @@ void handle_N(char token,char* params,serverrec* source,serverrec* reply, char* strlcpy(clientlist[nick]->server, server,256); strlcpy(clientlist[nick]->ident, ident,10); // +1 char to compensate for tilde strlcpy(clientlist[nick]->fullname, gecos,128); + strlcpy(clientlist[nick]->ip,ipaddr,32); clientlist[nick]->signon = TS; clientlist[nick]->nping = 0; // this is ignored for a remote user anyway. clientlist[nick]->lastping = 1; @@ -2428,7 +2420,7 @@ void handle_amp(char token,char* params,serverrec* source,serverrec* reply, char } } -long authcookie; +unsigned long authcookie; void handle_hash(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host) { @@ -2585,7 +2577,7 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve // now broadcast this new servers address out to all servers that are linked to us, // except the newcomer. They'll all attempt to connect back to it. authcookie = rand()*rand(); - snprintf(buffer,MAXBUF,"~ %d",authcookie); + snprintf(buffer,MAXBUF,"~ %lu",(unsigned long)authcookie); NetSendToAll(buffer); break; // ~ @@ -2763,7 +2755,7 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve nb_start = 0; // tell all the other servers to use this authcookie to connect back again // got '+ test3.chatspike.net 7010 -2016508415' from test.chatspike.net - snprintf(buffer,MAXBUF,"+ %s %s %d %d",tcp_host,ipaddr,port,authcookie); + snprintf(buffer,MAXBUF,"+ %s %s %d %lu",tcp_host,ipaddr,port,(unsigned long)authcookie); NetSendToAllExcept(tcp_host,buffer); break; case '/': @@ -2825,7 +2817,7 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) { - if ((!strncmp(udp_msg,"USER ",5)) || (!strncmp(udp_msg,"NICK ",5))) + if ((!strncmp(udp_msg,"USER ",5)) || (!strncmp(udp_msg,"NICK ",5)) || (!strncmp(udp_msg,"PASS ",5)) || (!strncmp(udp_msg,"SERVER ",7))) { // a user on a server port, just close their connection. RemoveServer(tcp_host); @@ -2833,7 +2825,6 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) } char response[10240]; - char old2[MAXBUF]; char token = udp_msg[0]; char* old = udp_msg; @@ -3010,6 +3001,8 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) char* revision = strtok(NULL," "); char* serverdesc = finalparam+2; + password = password; + WriteOpers("CONNECT from %s (%s) (their port: %d)",servername,tcp_host,atoi(myport)); ircd_connector* cn = serv->FindHost(servername); @@ -3095,6 +3088,8 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) char* servername = strtok(params," "); char* password = strtok(NULL," "); char* serverdesc = finalparam+2; + + password = password; // TODO: we should do a check here to ensure that this server is one we recently initiated a // link with, and didnt hear an 's' or 'E' back from yet (these are the only two valid responses @@ -3263,9 +3258,6 @@ void handle_link_packet(char* udp_msg, char* tcp_host, serverrec *serv) return; } else { - - serverrec* source_server = NULL; - for (int j = 0; j < 32; j++) { if (me[j] != NULL) @@ -3407,7 +3399,7 @@ void handle_gline(char **parameters, int pcnt, userrec *user) { add_gline(duration(parameters[1]),user->nick,parameters[2],parameters[0]); // # <mask> <who-set-it> <time-set> <duration> :<reason> - snprintf(netdata,MAXBUF,"# %s %s %ld %ld :%s",parameters[0],user->nick,TIME,duration(parameters[1]),parameters[2]); + snprintf(netdata,MAXBUF,"# %s %s %lu %lu :%s",parameters[0],user->nick,(unsigned long)TIME,(unsigned long)duration(parameters[1]),parameters[2]); NetSendToAll(netdata); if (!duration(parameters[1])) { diff --git a/src/connection.cpp b/src/connection.cpp index b7f99fb75..cd994ea65 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -44,7 +44,7 @@ connection::connection() } -bool connection::CreateListener(char* host, int p) +bool connection::CreateListener(char* newhost, int p) { sockaddr_in host_address; int flags; @@ -76,13 +76,13 @@ bool connection::CreateListener(char* host, int p) host_address.sin_family = AF_INET; - if (!strcmp(host,"")) + if (!strcmp(newhost,"")) { host_address.sin_addr.s_addr = htonl(INADDR_ANY); } else { - inet_aton(host,&addy); + inet_aton(newhost,&addy); host_address.sin_addr = addy; } @@ -114,17 +114,17 @@ int ircd_connector::GetServerPort() return this->port; } -bool ircd_connector::SetHostAndPort(char* host, int port) +bool ircd_connector::SetHostAndPort(char* newhost, int newport) { - strncpy(this->host,host,160); - this->port = port; + strncpy(this->host,newhost,160); + this->port = newport; return true; } -bool ircd_connector::SetHostAddress(char* host, int port) +bool ircd_connector::SetHostAddress(char* newhost, int newport) { - strncpy(this->host,host,160); - this->port = port; + strncpy(this->host,newhost,160); + this->port = newport; memset((void*)&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; inet_aton(host,&addr.sin_addr); @@ -174,23 +174,23 @@ std::string ircd_connector::GetBuffer() return z; } -bool ircd_connector::MakeOutboundConnection(char* host, int port) +bool ircd_connector::MakeOutboundConnection(char* newhost, int newport) { - log(DEBUG,"MakeOutboundConnection: Original param: %s",host); + log(DEBUG,"MakeOutboundConnection: Original param: %s",newhost); ClearBuffer(); - hostent* hoste = gethostbyname(host); + hostent* hoste = gethostbyname(newhost); if (!hoste) { - log(DEBUG,"MakeOutboundConnection: gethostbyname was NULL, setting %s",host); - this->SetHostAddress(host,port); - SetHostAndPort(host,port); + log(DEBUG,"MakeOutboundConnection: gethostbyname was NULL, setting %s",newhost); + this->SetHostAddress(newhost,newport); + SetHostAndPort(newhost,newport); } else { struct in_addr* ia = (in_addr*)hoste->h_addr; log(DEBUG,"MakeOutboundConnection: gethostbyname was valid, setting %s",inet_ntoa(*ia)); - this->SetHostAddress(inet_ntoa(*ia),port); - SetHostAndPort(inet_ntoa(*ia),port); + this->SetHostAddress(inet_ntoa(*ia),newport); + SetHostAndPort(inet_ntoa(*ia),newport); } this->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -220,7 +220,7 @@ bool ircd_connector::MakeOutboundConnection(char* host, int port) } -bool connection::BeginLink(char* targethost, int port, char* password, char* servername, int myport) +bool connection::BeginLink(char* targethost, int newport, char* password, char* servername, int myport) { char connect[MAXBUF]; @@ -237,44 +237,44 @@ bool connection::BeginLink(char* targethost, int port, char* password, char* ser if (this->fd) { - if (connector.MakeOutboundConnection(targethost,port)) + if (connector.MakeOutboundConnection(targethost,newport)) { // targethost has been turned into an ip... // we dont want this as the server name. connector.SetServerName(servername); - snprintf(connect,MAXBUF,"S %s %s %d %d :%s",getservername().c_str(),password,myport,GetRevision(),getserverdesc().c_str()); + snprintf(connect,MAXBUF,"S %s %s %lu %lu :%s",getservername().c_str(),password,(unsigned long)myport,(unsigned long)GetRevision(),getserverdesc().c_str()); connector.SetState(STATE_NOAUTH_OUTBOUND); - connector.SetHostAndPort(targethost, port); + connector.SetHostAndPort(targethost, newport); this->connectors.push_back(connector); return this->SendPacket(connect, servername); } else { connector.SetState(STATE_DISCONNECTED); - WriteOpers("Could not create outbound connection to %s:%d",targethost,port); + WriteOpers("Could not create outbound connection to %s:%d",targethost,newport); } } return false; } -bool connection::MeshCookie(char* targethost, int port, long cookie, char* servername) +bool connection::MeshCookie(char* targethost, int newport, unsigned long cookie, char* servername) { char connect[MAXBUF]; ircd_connector connector; - WriteOpers("Establishing meshed link to %s:%d",servername,port); + WriteOpers("Establishing meshed link to %s:%d",servername,newport); if (this->fd) { - if (connector.MakeOutboundConnection(targethost,port)) + if (connector.MakeOutboundConnection(targethost,newport)) { // targethost has been turned into an ip... // we dont want this as the server name. connector.SetServerName(servername); - snprintf(connect,MAXBUF,"- %d %s :%s",cookie,getservername().c_str(),getserverdesc().c_str()); + snprintf(connect,MAXBUF,"- %lu %s :%s",cookie,getservername().c_str(),getserverdesc().c_str()); connector.SetState(STATE_NOAUTH_OUTBOUND); - connector.SetHostAndPort(targethost, port); + connector.SetHostAndPort(targethost, newport); connector.SetState(STATE_CONNECTED); this->connectors.push_back(connector); return this->SendPacket(connect, servername); @@ -282,29 +282,27 @@ bool connection::MeshCookie(char* targethost, int port, long cookie, char* serve else { connector.SetState(STATE_DISCONNECTED); - WriteOpers("Could not create outbound connection to %s:%d",targethost,port); + WriteOpers("Could not create outbound connection to %s:%d",targethost,newport); } } return false; } -bool connection::AddIncoming(int fd, char* targethost, int sourceport) +bool connection::AddIncoming(int newfd, char* targethost, int sourceport) { - char connect[MAXBUF]; - ircd_connector connector; // targethost has been turned into an ip... // we dont want this as the server name. connector.SetServerName(targethost); - connector.SetDescriptor(fd); + connector.SetDescriptor(newfd); connector.SetState(STATE_NOAUTH_INBOUND); - int flags = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, flags | O_NONBLOCK); + int flags = fcntl(newfd, F_GETFL, 0); + fcntl(newfd, F_SETFL, flags | O_NONBLOCK); int sendbuf = 32768; int recvbuf = 32768; - setsockopt(fd,SOL_SOCKET,SO_SNDBUF,(const void *)&sendbuf,sizeof(sendbuf)); - setsockopt(fd,SOL_SOCKET,SO_RCVBUF,(const void *)&recvbuf,sizeof(sendbuf)); + setsockopt(newfd,SOL_SOCKET,SO_SNDBUF,(const void *)&sendbuf,sizeof(sendbuf)); + setsockopt(newfd,SOL_SOCKET,SO_RCVBUF,(const void *)&recvbuf,sizeof(sendbuf)); connector.SetHostAndPort(targethost, sourceport); connector.SetState(STATE_NOAUTH_INBOUND); log(DEBUG,"connection::AddIncoming() Added connection: %s:%d",targethost,sourceport); @@ -321,11 +319,11 @@ void connection::TerminateLink(char* targethost) // Returns a pointer to the connector for 'host' -ircd_connector* connection::FindHost(std::string host) +ircd_connector* connection::FindHost(std::string findhost) { for (int i = 0; i < this->connectors.size(); i++) { - if (this->connectors[i].GetServerName() == host) + if (this->connectors[i].GetServerName() == findhost) { return &this->connectors[i]; } @@ -365,9 +363,9 @@ int ircd_connector::GetState() } -void ircd_connector::SetState(int state) +void ircd_connector::SetState(int newstate) { - this->state = state; + this->state = newstate; if (state == STATE_DISCONNECTED) { NetSendMyRoutingTable(); @@ -383,17 +381,17 @@ void ircd_connector::CloseConnection() fcntl(this->fd, F_SETFL, flags | O_NONBLOCK); } -void ircd_connector::SetDescriptor(int fd) +void ircd_connector::SetDescriptor(int newfd) { - this->fd = fd; + this->fd = newfd; } -bool connection::SendPacket(char *message, const char* host) +bool connection::SendPacket(char *message, const char* sendhost) { - if ((!message) || (!host)) + if ((!message) || (!sendhost)) return true; - ircd_connector* cn = this->FindHost(host); + ircd_connector* cn = this->FindHost(sendhost); if (!strchr(message,'\n')) { @@ -408,7 +406,7 @@ bool connection::SendPacket(char *message, const char* host) { log(DEBUG,"Main route to %s is down, seeking alternative",host); // fix: can only route one hop to avoid a loop - if (strlcat(message,"R ",2)) + if (strncmp(message,"R ",2)) { // this route is down, we must re-route the packet through an available point in the mesh. for (int k = 0; k < this->connectors.size(); k++) @@ -416,11 +414,11 @@ bool connection::SendPacket(char *message, const char* host) // search for another point in the mesh which can 'reach' where we want to go for (int m = 0; m < this->connectors[k].routes.size(); m++) { - if (!strcasecmp(this->connectors[k].routes[m].c_str(),host)) + if (!strcasecmp(this->connectors[k].routes[m].c_str(),sendhost)) { log(DEBUG,"Found alternative route for packet: %s",this->connectors[k].GetServerName().c_str()); char buffer[MAXBUF]; - snprintf(buffer,MAXBUF,"R %s %s",host,message); + snprintf(buffer,MAXBUF,"R %s %s",sendhost,message); this->SendPacket(buffer,this->connectors[k].GetServerName().c_str()); return true; } @@ -428,10 +426,10 @@ bool connection::SendPacket(char *message, const char* host) } } char buffer[MAXBUF]; - snprintf(buffer,MAXBUF,"& %s",host); - NetSendToAllExcept(host,buffer); - log(DEBUG,"There are no routes to %s, we're gonna boot the server off!",host); - DoSplit(host); + snprintf(buffer,MAXBUF,"& %s",sendhost); + NetSendToAllExcept(sendhost,buffer); + log(DEBUG,"There are no routes to %s, we're gonna boot the server off!",sendhost); + DoSplit(sendhost); return false; } @@ -443,7 +441,7 @@ bool connection::SendPacket(char *message, const char* host) cn->CloseConnection(); cn->SetState(STATE_DISCONNECTED); // retry the packet along a new route so either arrival OR failure are gauranteed (bugfix) - return this->SendPacket(message,host); + return this->SendPacket(message,sendhost); } return true; } @@ -452,7 +450,7 @@ bool connection::SendPacket(char *message, const char* host) // receives a packet from any where there is data waiting, first come, first served // fills the message and host values with the host where the data came from. -bool connection::RecvPacket(std::deque<std::string> &messages, char* host) +bool connection::RecvPacket(std::deque<std::string> &messages, char* recvhost) { char data[4096]; memset(data, 0, 4096); @@ -463,7 +461,7 @@ bool connection::RecvPacket(std::deque<std::string> &messages, char* host) // returns false if the packet could not be sent (e.g. target host down) int rcvsize = 0; rcvsize = recv(this->connectors[i].GetDescriptor(),data,32,0); - data[rcvsize] == '\0'; + data[rcvsize] = '\0'; if (rcvsize == -1) { if (errno != EAGAIN) @@ -481,7 +479,7 @@ bool connection::RecvPacket(std::deque<std::string> &messages, char* host) { messages.push_back(this->connectors[i].GetBuffer().c_str()); strlcpy(host,this->connectors[i].GetServerName().c_str(),160); - log(DEBUG,"main: Connection::RecvPacket() got '%s' from %s",this->connectors[i].GetBuffer().c_str(),host); + log(DEBUG,"main: Connection::RecvPacket() got '%s' from %s",this->connectors[i].GetBuffer().c_str(),recvhost); this->connectors[i].ClearBuffer(); return true; } diff --git a/src/dns.cpp b/src/dns.cpp index 6788937c6..8e3f4f48d 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -182,11 +182,9 @@ void DNS::dns_init() { /* on first call only: populates servers4 struct with up fclose(f); } -void DNS::dns_init_2(const char* dnsserver) { /* populates servers4 struct with address from the given parameter */ - FILE *f; - int i; +void DNS::dns_init_2(const char* dnsserver) +{ in_addr addr4; - char buf[1024]; i4 = 0; srand((unsigned int) TIME); memset(servers4,'\0',sizeof(in_addr) * DNS_MAX); @@ -195,7 +193,8 @@ void DNS::dns_init_2(const char* dnsserver) { /* populates servers4 struct with } -static int dns_send_requests(const s_header *h, const s_connection *s, const int l) { /* send DNS query */ +static int dns_send_requests(const s_header *h, const s_connection *s, const int l) +{ int i; sockaddr_in addr4; unsigned char payload[sizeof(s_header)]; @@ -445,39 +444,39 @@ int DNS::dns_getname4(const in_addr *ip) { /* build, add and send PTR query; ret } char* DNS::dns_ntoa4(const in_addr * const ip) { /* numeric to ascii: convert 4part IP addr struct to static string */ - static char result[256]; - return dns_ntoa4_s(ip,result); + static char r[256]; + return dns_ntoa4_s(ip,r); } char* DNS::dns_ntoa4_r(const in_addr *ip) { /* numeric to ascii (reentrant): convert 4part IP addr struct to new string */ - char *result; - result = new char[256]; - return dns_ntoa4_s(ip,result); + char *r; + r = new char[256]; + return dns_ntoa4_s(ip,r); } -char* DNS::dns_ntoa4_s(const in_addr *ip, char *result) { /* numeric to ascii (buffered): convert 4part IP addr struct to given string */ +char* DNS::dns_ntoa4_s(const in_addr *ip, char *r) { /* numeric to ascii (buffered): convert 4part IP addr struct to given string */ unsigned char *m; m = (unsigned char *)&ip->s_addr; - sprintf(result,"%d.%d.%d.%d",m[0],m[1],m[2],m[3]); - return result; + sprintf(r,"%d.%d.%d.%d",m[0],m[1],m[2],m[3]); + return r; } -char* DNS::dns_getresult(const int fd) { /* retrieve result of DNS query */ - static char result[RESULTSIZE]; - return dns_getresult_s(fd,result); +char* DNS::dns_getresult(const int cfd) { /* retrieve result of DNS query */ + static char r[RESULTSIZE]; + return dns_getresult_s(cfd,r); } -char* DNS::dns_getresult_r(const int fd) { /* retrieve result of DNS query (reentrant) */ - char *result; - result = new char[RESULTSIZE]; - if(dns_getresult_s(fd,result) == NULL) { - delete result; +char* DNS::dns_getresult_r(const int cfd) { /* retrieve result of DNS query (reentrant) */ + char *r; + r = new char[RESULTSIZE]; + if(dns_getresult_s(cfd,r) == NULL) { + delete r; return NULL; } - return result; + return r; } -char* DNS::dns_getresult_s(const int fd, char *result) { /* retrieve result of DNS query (buffered) */ +char* DNS::dns_getresult_s(const int cfd, char *res) { /* retrieve result of DNS query (buffered) */ s_header h; s_connection *c, *prev; int l,i,q,curanswer,o; @@ -485,15 +484,15 @@ char* DNS::dns_getresult_s(const int fd, char *result) { /* retrieve result of D unsigned char buffer[sizeof(s_header)]; unsigned short p; - if (result) + if (res) { - result[0] = 0; + res[0] = 0; } prev = NULL; c = connection_head; while (c != NULL) { /* find query in list of open queries */ - if (c->fd == fd) + if (c->fd == cfd) break; prev = c; c = c->next; @@ -603,21 +602,21 @@ char* DNS::dns_getresult_s(const int fd, char *result) { /* retrieve result of D if (h.payload[i] == 0) q = 1; else { - result[o] = '\0'; + res[o] = '\0'; if (o != 0) - result[o++] = '.'; - memcpy(&result[o],&h.payload[i + 1],h.payload[i]); + res[o++] = '.'; + memcpy(&res[o],&h.payload[i + 1],h.payload[i]); o += h.payload[i]; i += h.payload[i] + 1; } } } - result[o] = '\0'; + res[o] = '\0'; break; case DNS_QRY_A: if (c->want_list) { - dns_ip4list *alist = (dns_ip4list *) result; /* we have to trust that this is aligned */ - while ((char *)alist - (char *)result < 700) { + dns_ip4list *alist = (dns_ip4list *) res; /* we have to trust that this is aligned */ + while ((char *)alist - (char *)res < 700) { if (rr.type != DNS_QRY_A) break; if (rr._class != 1) @@ -663,12 +662,12 @@ char* DNS::dns_getresult_s(const int fd, char *result) { /* retrieve result of D break; default: defaultcase: - memcpy(result,&h.payload[i],rr.rdlength); - result[rr.rdlength] = '\0'; + memcpy(res,&h.payload[i],rr.rdlength); + res[rr.rdlength] = '\0'; break; } delete c; - return result; + return res; } DNS::DNS() diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 9ab33fa99..8da38a225 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -220,10 +220,10 @@ long GetRevision() char Revision[] = "$Revision$"; char *s1 = Revision; char *savept; - char *v1 = strtok_r(s1," ",&savept); - s1 = savept; char *v2 = strtok_r(s1," ",&savept); s1 = savept; + v2 = strtok_r(s1," ",&savept); + s1 = savept; return (long)(atof(v2)*10000); } @@ -707,7 +707,7 @@ void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...) } -void WriteChannelWithServ(char* ServerName, chanrec* Ptr, userrec* user, char* text, ...) +void WriteChannelWithServ(char* ServName, chanrec* Ptr, userrec* user, char* text, ...) { if ((!Ptr) || (!user) || (!text)) { @@ -1115,7 +1115,6 @@ void WriteWallOps(userrec *source, bool local_only, char* text, ...) return; } - int i = 0; char textbuffer[MAXBUF]; va_list argsPtr; va_start (argsPtr, text); @@ -1379,7 +1378,6 @@ void userlist(userrec *user,chanrec *c) int usercount_i(chanrec *c) { - int i = 0; int count = 0; if (!c) @@ -1415,7 +1413,6 @@ int usercount_i(chanrec *c) int usercount(chanrec *c) { - int i = 0; int count = 0; if (!c) @@ -1454,7 +1451,6 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri return 0; } - int i = 0; chanrec* Ptr; int created = 0; char cname[MAXBUF]; @@ -1479,7 +1475,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri if (!FindChan(cname)) { - int MOD_RESULT = 0; + MOD_RESULT = 0; FOREACH_RESULT(OnUserPreJoin(user,NULL,cname)); if (MOD_RESULT == 1) { return NULL; @@ -1518,7 +1514,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri if ((!override) || (!strcasecmp(user->server,ServerName))) { log(DEBUG,"Not overriding..."); - int MOD_RESULT = 0; + MOD_RESULT = 0; FOREACH_RESULT(OnUserPreJoin(user,Ptr,cname)); if (MOD_RESULT == 1) { return NULL; @@ -1528,7 +1524,7 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri if (!MOD_RESULT) { log(DEBUG,"add_channel: checking key, invite, etc"); - int MOD_RESULT = 0; + MOD_RESULT = 0; FOREACH_RESULT(OnCheckKey(user, Ptr, key ? key : "")); if (MOD_RESULT == 0) { @@ -1632,23 +1628,23 @@ chanrec* add_channel(userrec *user, const char* cn, const char* key, bool overri log(DEBUG,"Passed channel checks"); - for (int i =0; i != MAXCHANS; i++) + for (int index =0; index != MAXCHANS; index++) { - log(DEBUG,"Check location %d",i); - if (user->chans[i].channel == NULL) + log(DEBUG,"Check location %d",index); + if (user->chans[index].channel == NULL) { - log(DEBUG,"Adding into their channel list at location %d",i); + log(DEBUG,"Adding into their channel list at location %d",index); if (created == 2) { /* first user in is given ops */ - user->chans[i].uc_modes = UCMODE_OP; + user->chans[index].uc_modes = UCMODE_OP; } else { - user->chans[i].uc_modes = 0; + user->chans[index].uc_modes = 0; } - user->chans[i].channel = Ptr; + user->chans[index].channel = Ptr; WriteChannel(Ptr,user,"JOIN :%s",Ptr->name); if (!override) // we're not overriding... so this isnt part of a netburst, broadcast it. @@ -1698,7 +1694,6 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool } chanrec* Ptr; - int created = 0; if ((!cname) || (!user)) { @@ -1777,9 +1772,6 @@ void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason) return; } - int i = 0; - int created = 0; - if ((!Ptr) || (!user) || (!src)) { return; @@ -1881,7 +1873,7 @@ int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start char *pars[32]; char blog[32][MAXBUF]; char blog2[32][MAXBUF]; - int i = 0, j = 0, q = 0, total = 0, t = 0, t2 = 0, total2 = 0; + int j = 0, q = 0, total = 0, t = 0, t2 = 0, total2 = 0; char keystr[MAXBUF]; char moo[MAXBUF]; @@ -2056,8 +2048,6 @@ void kill_link(userrec *user,const char* r) close(user->fd); } - bool do_purge = false; - if (user->registered == 7) { WriteOpers("*** Client exiting: %s!%s@%s [%s]",user->nick,user->ident,user->host,reason); AddWhoWas(user); @@ -2114,8 +2104,6 @@ void kill_link_silent(userrec *user,const char* r) close(user->fd); } - bool do_purge = false; - if (iter != clientlist.end()) { log(DEBUG,"deleting user hash value %d",iter->second); @@ -2322,9 +2310,6 @@ void AddWhoWas(userrec* u) /* add a client connection to the sockets list */ void AddClient(int socket, char* host, int port, bool iscached, char* ip) { - int i; - int blocking = 1; - char resolved[MAXBUF]; string tempnick; char tn2[MAXBUF]; user_hash::iterator iter; @@ -2639,10 +2624,10 @@ void handle_version(char **parameters, int pcnt, userrec *user) char *s1 = Revision; char *savept; - char *v1 = strtok_r(s1," ",&savept); - s1 = savept; char *v2 = strtok_r(s1," ",&savept); s1 = savept; + v2 = strtok_r(s1," ",&savept); + s1 = savept; WriteServ(user->fd,"351 %s :%s Rev. %s %s :%s (O=%d)",user->nick,VERSION,v2,ServerName,SYSTEM,OPTIMISATION); } @@ -2788,10 +2773,8 @@ void force_nickchange(userrec* user,const char* newnick) int process_parameters(char **command_p,char *parameters) { - int i = 0; int j = 0; - int q = 0; - q = strlen(parameters); + int q = strlen(parameters); if (!q) { /* no parameters, command_p invalid! */ @@ -2842,7 +2825,7 @@ void process_command(userrec *user, char* cmd) char *command; char *command_p[127]; char p[MAXBUF], temp[MAXBUF]; - int i, j, items, cmd_found; + int j, items, cmd_found; for (int i = 0; i < 127; i++) command_p[i] = NULL; @@ -3215,7 +3198,6 @@ void process_buffer(const char* cmdbuf,userrec *user) return; } char cmd[MAXBUF]; - int i; if (!cmdbuf) { log(DEFAULT,"*** BUG *** process_buffer was given an invalid parameter"); @@ -3475,17 +3457,17 @@ void erase_factory(int j) void erase_module(int j) { - int v = 0; + int v1 = 0; for (std::vector<Module*>::iterator m = modules.begin(); m!= modules.end(); m++) { - if (v == j) + if (v1 == j) { delete *m; modules.erase(m); modules.push_back(NULL); break; } - v++; + v1++; } int v2 = 0; for (std::vector<std::string>::iterator v = module_names.begin(); v != module_names.end(); v++) @@ -3633,8 +3615,7 @@ int InspIRCd(void) socklen_t length; int count = 0; int selectResult = 0, selectResult2 = 0; - char *temp, configToken[MAXBUF], stuff[MAXBUF], Addr[MAXBUF], Type[MAXBUF]; - char resolvedHost[MAXBUF]; + char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF]; fd_set selectFds; timeval tv; @@ -3664,8 +3645,8 @@ int InspIRCd(void) exit(0); } log(DEBUG,"InspIRCd: startup: read config"); - - int count2 = 0, count3 = 0; + + int clientportcount = 0, serverportcount = 0; for (count = 0; count < ConfValueEnum("bind",&config_f); count++) { @@ -3679,30 +3660,30 @@ int InspIRCd(void) ConfValue("bind","default",count,Default,&config_f); if (strchr(Default,'y')) { - defaultRoute = count3; + defaultRoute = serverportcount; log(DEBUG,"InspIRCd: startup: binding '%s:%s' is default server route",Addr,configToken); } - me[count3] = new serverrec(ServerName,100L,false); - if (!me[count3]->CreateListener(Addr,atoi(configToken))) + me[serverportcount] = new serverrec(ServerName,100L,false); + if (!me[serverportcount]->CreateListener(Addr,atoi(configToken))) { log(DEFAULT,"Warning: Failed to bind port %d",atoi(configToken)); printf("Warning: Failed to bind port %d\n",atoi(configToken)); } else { - count3++; + serverportcount++; } } else { - ports[count2] = atoi(configToken); - strlcpy(addrs[count2],Addr,256); - count2++; + ports[clientportcount] = atoi(configToken); + strlcpy(addrs[clientportcount],Addr,256); + clientportcount++; } log(DEBUG,"InspIRCd: startup: read binding %s:%s [%s] from config",Addr,configToken, Type); } - portCount = count2; - UDPportCount = count3; + portCount = clientportcount; + UDPportCount = serverportcount; log(DEBUG,"InspIRCd: startup: read %d total client ports and %d total server ports",portCount,UDPportCount); log(DEBUG,"InspIRCd: startup: InspIRCd is now starting!"); @@ -3711,9 +3692,9 @@ int InspIRCd(void) /* BugFix By Craig! :p */ MODCOUNT = -1; - for (count2 = 0; count2 < ConfValueEnum("module",&config_f); count2++) + for (count = 0; count < ConfValueEnum("module",&config_f); count++) { - ConfValue("module","name",count2,configToken,&config_f); + ConfValue("module","name",count,configToken,&config_f); printf("Loading module... \033[1;37m%s\033[0;37m\n",configToken); if (!LoadModule(configToken)) { @@ -3783,7 +3764,7 @@ int InspIRCd(void) WritePID(PID); length = sizeof (client); - char udp_msg[MAXBUF], tcp_host[MAXBUF]; + char udp_msg[MAXBUF],tcp_host[MAXBUF]; fd_set serverfds; timeval tvs; @@ -3873,7 +3854,6 @@ int InspIRCd(void) { for (int ctr = 0; ctr < msgs.size(); ctr++) { - char udp_msg[MAXBUF]; strlcpy(udp_msg,msgs[ctr].c_str(),MAXBUF); log(DEBUG,"Processing: %s",udp_msg); if (strlen(udp_msg)<1) diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp index 79e912175..03596b4bc 100644 --- a/src/inspircd_io.cpp +++ b/src/inspircd_io.cpp @@ -340,8 +340,7 @@ int EnumConf(std::stringstream *config, const char* tag) { int ptr = 0; char buffer[MAXBUF], c_tag[MAXBUF], c, lastc; - int in_token, in_quotes, tptr, j, idx = 0; - char* key; + int in_token, in_quotes, tptr, idx = 0; const char* buf = config->str().c_str(); long bptr = 0; @@ -411,8 +410,7 @@ int EnumValues(std::stringstream *config, const char* tag, int index) { int ptr = 0; char buffer[MAXBUF], c_tag[MAXBUF], c, lastc; - int in_token, in_quotes, tptr, j, idx = 0; - char* key; + int in_token, in_quotes, tptr, idx = 0; bool correct_tag = false; int num_items = 0; diff --git a/src/message.cpp b/src/message.cpp index ba1590f8e..4b2dfa98d 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -69,9 +69,6 @@ extern char DNSServer[MAXBUF]; int common_channels(userrec *u, userrec *u2) { - int i = 0; - int z = 0; - if ((!u) || (!u2)) { log(DEFAULT,"*** BUG *** common_channels was given an invalid parameter"); @@ -79,7 +76,7 @@ int common_channels(userrec *u, userrec *u2) } for (int i = 0; i != MAXCHANS; i++) { - for (z = 0; z != MAXCHANS; z++) + for (int z = 0; z != MAXCHANS; z++) { if ((u->chans[i].channel != NULL) && (u2->chans[z].channel != NULL)) { @@ -282,7 +279,6 @@ void ChangeDisplayedHost(userrec* user, const char* host) int isident(const char* n) { - char v[MAXBUF]; if (!n) { @@ -310,8 +306,6 @@ int isident(const char* n) int isnick(const char* n) { - int i = 0; - char v[MAXBUF]; if (!n) { return 0; @@ -355,8 +349,6 @@ char* cmode(userrec *user, chanrec *chan) log(DEFAULT,"*** BUG *** cmode was given an invalid parameter"); return ""; } - - int i; for (int i = 0; i != MAXCHANS; i++) { if (user->chans[i].channel) @@ -472,9 +464,7 @@ char lst[MAXBUF]; char* chlist(userrec *user) { - int i = 0; char cmp[MAXBUF]; - log(DEBUG,"chlist: %s",user->nick); strcpy(lst,""); if (!user) diff --git a/src/mode.cpp b/src/mode.cpp index 6f06027e4..b5e444fc3 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -84,7 +84,6 @@ extern time_t TIME; char* give_ops(userrec *user,char *dest,chanrec *chan,int status) { userrec *d; - int i; if ((!user) || (!dest) || (!chan)) { @@ -148,7 +147,6 @@ char* give_ops(userrec *user,char *dest,chanrec *chan,int status) char* give_hops(userrec *user,char *dest,chanrec *chan,int status) { userrec *d; - int i; if ((!user) || (!dest) || (!chan)) { @@ -205,7 +203,6 @@ char* give_hops(userrec *user,char *dest,chanrec *chan,int status) char* give_voice(userrec *user,char *dest,chanrec *chan,int status) { userrec *d; - int i; if ((!user) || (!dest) || (!chan)) { @@ -262,7 +259,6 @@ char* give_voice(userrec *user,char *dest,chanrec *chan,int status) char* take_ops(userrec *user,char *dest,chanrec *chan,int status) { userrec *d; - int i; if ((!user) || (!dest) || (!chan)) { @@ -322,7 +318,6 @@ char* take_ops(userrec *user,char *dest,chanrec *chan,int status) char* take_hops(userrec *user,char *dest,chanrec *chan,int status) { userrec *d; - int i; if ((!user) || (!dest) || (!chan)) { @@ -379,7 +374,6 @@ char* take_hops(userrec *user,char *dest,chanrec *chan,int status) char* take_voice(userrec *user,char *dest,chanrec *chan,int status) { userrec *d; - int i; if ((!user) || (!dest) || (!chan)) { @@ -1181,7 +1175,7 @@ void handle_mode(char **parameters, int pcnt, userrec *user) { chanrec* Ptr; userrec* dest; - int can_change,i; + int can_change; int direction = 1; char outpars[MAXBUF]; @@ -1356,7 +1350,7 @@ void handle_mode(char **parameters, int pcnt, userrec *user) z = strlen(b)-1; if ((b[z] == '-') || (b[z] == '+')) - b[z] == '\0'; + b[z] = '\0'; if ((!strcmp(b,"+")) || (!strcmp(b,"-"))) return; @@ -1459,7 +1453,7 @@ void server_mode(char **parameters, int pcnt, userrec *user) { chanrec* Ptr; userrec* dest; - int can_change,i; + int can_change; int direction = 1; char outpars[MAXBUF]; @@ -1603,7 +1597,7 @@ void server_mode(char **parameters, int pcnt, userrec *user) z = strlen(b)-1; if ((b[z] == '-') || (b[z] == '+')) - b[z] == '\0'; + b[z] = '\0'; if ((!strcmp(b,"+")) || (!strcmp(b,"-"))) return; @@ -1645,7 +1639,7 @@ void merge_mode(char **parameters, int pcnt) { chanrec* Ptr; userrec* dest; - int can_change,i; + int can_change; int direction = 1; char outpars[MAXBUF]; @@ -1789,7 +1783,7 @@ void merge_mode(char **parameters, int pcnt) z = strlen(b)-1; if ((b[z] == '-') || (b[z] == '+')) - b[z] == '\0'; + b[z] = '\0'; if ((!strcmp(b,"+")) || (!strcmp(b,"-"))) return; @@ -1823,7 +1817,7 @@ void merge_mode2(char **parameters, int pcnt, userrec* user) { chanrec* Ptr; userrec* dest; - int can_change,i; + int can_change; int direction = 1; char outpars[MAXBUF]; @@ -1974,7 +1968,7 @@ void merge_mode2(char **parameters, int pcnt, userrec* user) z = strlen(b)-1; if ((b[z] == '-') || (b[z] == '+')) - b[z] == '\0'; + b[z] = '\0'; if ((!strcmp(b,"+")) || (!strcmp(b,"-"))) return; diff --git a/src/modules/extra/m_sql.cpp b/src/modules/extra/m_sql.cpp index 45421e334..dd0cbdc1d 100644 --- a/src/modules/extra/m_sql.cpp +++ b/src/modules/extra/m_sql.cpp @@ -56,7 +56,9 @@ class SQLConnection this->pass = thispass; this->db = thisdb; this->id = myid; + unsigned int timeout = 1; mysql_init(&connection); + mysql_options(&connection,MYSQL_OPT_CONNECT_TIMEOUT,(char*)&timeout); } // This method connects to the database using the credentials supplied to the constructor, and returns @@ -187,18 +189,18 @@ class ModuleSQL : public Module } } - void LoadDatabases(ConfigReader* Conf) + void LoadDatabases(ConfigReader* ThisConf) { Srv->Log(DEFAULT,"SQL: Loading database settings"); Connections.clear(); Srv->Log(DEBUG,"Cleared connections"); - for (int j =0; j < Conf->Enumerate("database"); j++) + for (int j =0; j < ThisConf->Enumerate("database"); j++) { - std::string db = Conf->ReadValue("database","name",j); - std::string user = Conf->ReadValue("database","username",j); - std::string pass = Conf->ReadValue("database","password",j); - std::string host = Conf->ReadValue("database","hostname",j); - std::string id = Conf->ReadValue("database","id",j); + std::string db = ThisConf->ReadValue("database","name",j); + std::string user = ThisConf->ReadValue("database","username",j); + std::string pass = ThisConf->ReadValue("database","password",j); + std::string host = ThisConf->ReadValue("database","hostname",j); + std::string id = ThisConf->ReadValue("database","id",j); Srv->Log(DEBUG,"Read database settings"); if ((db != "") && (host != "") && (user != "") && (id != "") && (pass != "")) { diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp index 55343e96d..035012650 100644 --- a/src/modules/extra/m_sqllog.cpp +++ b/src/modules/extra/m_sqllog.cpp @@ -100,26 +100,26 @@ class ModuleSQLLog : public Module delete query; if (nid < 1) { - SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_actors VALUES('','"+nick+"')"); - Request queryrequest((char*)query, this, SQLModule); - SQLResult* result = (SQLResult*)queryrequest.Send(); - if (result->GetType() == SQL_ERROR) + SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_actors VALUES('','"+nick+"')"); + Request queryrequest2((char*)query2, this, SQLModule); + SQLResult* result2 = (SQLResult*)queryrequest2.Send(); + if (result2->GetType() == SQL_ERROR) { - Srv->Log(DEFAULT,"SQL log error: " + result->GetError()); + Srv->Log(DEFAULT,"SQL log error: " + result2->GetError()); } - if (result) + if (result2) delete result; - if (query) - delete query; + if (query2) + delete query2; nid = InsertNick(nick); } return nid; } - void InsertEntry(long category,long nickid,long hostid,long sourceid,unsigned long date) + void InsertEntry(unsigned long category,unsigned long nickid,unsigned long hostid,unsigned long sourceid,unsigned long date) { char querybuffer[MAXBUF]; - snprintf(querybuffer,MAXBUF,"INSERT INTO ircd_log VALUES('',%d,%d,%d,%d,%lu)",category,nickid,hostid,sourceid,date); + snprintf(querybuffer,MAXBUF,"INSERT INTO ircd_log VALUES('',%lu,%lu,%lu,%lu,%lu)",(unsigned long)category,(unsigned long)nickid,(unsigned long)hostid,(unsigned long)sourceid,(unsigned long)date); SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,querybuffer); Request queryrequest((char*)query, this, SQLModule); SQLResult* result = (SQLResult*)queryrequest.Send(); @@ -160,17 +160,17 @@ class ModuleSQLLog : public Module delete query; if (hid < 1) { - SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')"); - Request queryrequest((char*)query, this, SQLModule); - SQLResult* result = (SQLResult*)queryrequest.Send(); - if (result->GetType() == SQL_ERROR) + SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')"); + Request queryrequest2((char*)query2, this, SQLModule); + SQLResult* result2 = (SQLResult*)queryrequest2.Send(); + if (result2->GetType() == SQL_ERROR) { - Srv->Log(DEFAULT,"SQL log error: " + result->GetError()); + Srv->Log(DEFAULT,"SQL log error: " + result2->GetError()); } if (result) - delete result; + delete result2; if (query) - delete query; + delete query2; hid = InsertHost(host); } return hid; @@ -185,7 +185,7 @@ class ModuleSQLLog : public Module long nickid = InsertNick(nick); long sourceid = InsertNick(source); long hostid = InsertHost(host); - InsertEntry(category,nickid,hostid,sourceid,time(NULL)); + InsertEntry((unsigned)category,(unsigned)nickid,(unsigned)hostid,(unsigned)sourceid,(unsigned long)time(NULL)); } virtual void OnOper(userrec* user) diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp index 78db8f67c..fb85bb7b1 100644 --- a/src/modules/m_antibottler.cpp +++ b/src/modules/m_antibottler.cpp @@ -63,7 +63,7 @@ class ModuleAntiBottler : public Module } // Bug Fix (#14) -- FCS if (!strlen(data)) return; - char *user = strtok(data," "); + strtok(data," "); if (!strlen(data)) return; char *ident = strtok(NULL," "); if (!strlen(data)) return; diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp index 4407426b8..123a4dbe2 100644 --- a/src/modules/m_park.cpp +++ b/src/modules/m_park.cpp @@ -68,8 +68,8 @@ void handle_park(char **parameters, int pcnt, userrec *user) { awaylog* aw; char msg[MAXBUF]; - long key = abs(random() * 12345); - snprintf(msg,MAXBUF,"You are now parked. To unpark use /UNPARK %s %d",user->nick,key); + unsigned long key = abs(random() * 12345); + snprintf(msg,MAXBUF,"You are now parked. To unpark use /UNPARK %s %lu",user->nick,key); Srv->UserToPseudo(user,std::string(msg)); aw = new awaylog; user->Extend("park_awaylog",(char*)aw); @@ -84,7 +84,7 @@ void handle_park(char **parameters, int pcnt, userrec *user) void handle_parkstats(char **parameters, int pcnt, userrec *user) { char status[MAXBUF]; - snprintf(status,MAXBUF,"NOTICE %s :There are a total of %d parked clients on this server, with a maximum of %d parked sessions allowed per user.",user->nick,pinfo.size(),ConcurrentParks); + snprintf(status,MAXBUF,"NOTICE %s :There are a total of %lu parked clients on this server, with a maximum of %lu parked sessions allowed per user.",user->nick,(unsigned long)pinfo.size(),(unsigned long)ConcurrentParks); Srv->SendServ(user->fd,status); } diff --git a/src/users.cpp b/src/users.cpp index a32b94cf7..c0332dbe4 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -114,7 +114,6 @@ void userrec::RemoveInvite(char* channel) bool userrec::HasPermission(char* command) { char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF]; - char* myclass; char* mycmd; char* savept; char* savept2; diff --git a/src/xline.cpp b/src/xline.cpp index da03c0654..0e625bb52 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -392,7 +392,7 @@ void sync_xlines(serverrec* serv, char* tcp_host) { if (i->is_global) { - snprintf(data,MAXBUF,"} %s %s %ld %ld :%s",i->ipaddr,i->source,i->set_time,i->duration,i->reason); + snprintf(data,MAXBUF,"} %s %s %lu %lu :%s",i->ipaddr,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason); serv->SendPacket(data,tcp_host); } } @@ -400,14 +400,14 @@ void sync_xlines(serverrec* serv, char* tcp_host) { if (i->is_global) { - snprintf(data,MAXBUF,"{ %s %s %ld %ld :%s",i->nick,i->source,i->set_time,i->duration,i->reason); + snprintf(data,MAXBUF,"{ %s %s %lu %lu :%s",i->nick,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason); serv->SendPacket(data,tcp_host); } } // glines are always global, so no need to check for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++) { - snprintf(data,MAXBUF,"# %s %s %ld %ld :%s",i->hostmask,i->source,i->set_time,i->duration,i->reason); + snprintf(data,MAXBUF,"# %s %s %lu %lu :%s",i->hostmask,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason); serv->SendPacket(data,tcp_host); } } |