patch, getting rid of some compiler errors

Håkan Kvist <[email protected]> Fri, 9 Mar 2007 22:02:29 +0100
Newsgroups gmane.network.centericq
Message-ID <[email protected]>
This patch is just for decreasing the number of gcc warnings.

    Changed initialization order for some classes,
    variables should be initializated in the same order
    as they are defined.
    
    Changed some destructors to be virtual, since the classes
    contained some functions that are defined as virtual.
    
    Some unused variables removed.
    
    Some functions that was declared as having a return value
    did not return a value.
    
    Dumping the output (stdin and stdout) of make before my changes
    generated a file with 4433 lines.
    
    After these changes the log file with 2329 lines.
    
    Flags used when compiling was:
    CXXFLAGS="-O0 -pedantic -Wall"
    CFLAGS="-O0 -pedantic -Wall"


Patch attatched (yes I promise, this time it is really attatched :-)

Faild to setup my git-repository correct, so I couldn't commet
directly to the right branch of the repository...

regards
Håkan

_______________________________________________
Cicq mailing list
Cicq-xGejAJT2w6wWP6gT/[email protected]
http://mailman.linuxpl.org/mailman/listinfo/cicq
Questions? Check the FAQ first: http://centericq.de/faq/
centericq_warnings.patch (text/plain, 13 KB)
diff --git a/connwrap/connwrap.c b/connwrap/connwrap.c
index 9159d85..0aac76d 100644
--- a/connwrap/connwrap.c
+++ b/connwrap/connwrap.c
@@ -1,12 +1,15 @@
 #include "connwrap.h"
 
-#include <netdb.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <errno.h>
 #include <arpa/inet.h>
+#include <errno.h>
 #include <fcntl.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <sys/time.h>
+#include <unistd.h>
 
 #define PROXY_TIMEOUT   10
     // HTTP proxy timeout in seconds (for the CONNECT method)
@@ -379,7 +382,7 @@ int cw_close(int fd) {
 #ifdef HAVE_OPENSSL
     delsock(fd);
 #endif
-    close(fd);
+    return close(fd);
 }
 
 #define FREEVAR(v) if(v) free(v), v = 0;
diff --git a/kkconsui/include/abstractui.h b/kkconsui/include/abstractui.h
index 5bca5fd..b478347 100644
--- a/kkconsui/include/abstractui.h
+++ b/kkconsui/include/abstractui.h
@@ -18,7 +18,7 @@ class abstractuicontrol {
 
 	abstractuicontrol();
 	abstractuicontrol(const abstractuicontrol &a);
-	~abstractuicontrol();
+	virtual ~abstractuicontrol();
 
 	virtual bool empty() const;
 	bool getaborted() const;
diff --git a/kkconsui/include/cmenus.h b/kkconsui/include/cmenus.h
index 77064ce..2e9bbad 100644
--- a/kkconsui/include/cmenus.h
+++ b/kkconsui/include/cmenus.h
@@ -50,7 +50,7 @@ class verticalmenu: public abstractuicontrol {
 
 	verticalmenu(int px1, int py1, int px2, int py2, int pncolor, int pscolor);
 	verticalmenu(int pncolor = 0, int pscolor = 0);
-	~verticalmenu();
+	virtual ~verticalmenu();
 
 	// following special characters are valid in the items text:
 
@@ -132,7 +132,7 @@ class horizontalmenu: public abstractuicontrol {
 
 	horizontalmenu(int x, int y, int normcolor, int selcolor, int framecolor);
 	horizontalmenu();
-	~horizontalmenu();
+	virtual ~horizontalmenu();
 
 	void additemf(int color, const char *fmt, ...);
 	void additemf(const char *fmt, ...);
diff --git a/kkconsui/include/fileselector.h b/kkconsui/include/fileselector.h
index b7d2639..7d0dcab 100644
--- a/kkconsui/include/fileselector.h
+++ b/kkconsui/include/fileselector.h
@@ -61,7 +61,7 @@ class fileselector: public abstractuicontrol {
 
     public:
 	fileselector();
-	~fileselector();
+	virtual ~fileselector();
 
 	void setoptions(int noptions);
 	void setstartpoint(const string &aspoint);
diff --git a/kkconsui/include/horizontalbar.h b/kkconsui/include/horizontalbar.h
index 8ac619b..4ece7c6 100644
--- a/kkconsui/include/horizontalbar.h
+++ b/kkconsui/include/horizontalbar.h
@@ -23,7 +23,7 @@ class horizontalbar : public abstractuicontrol {
 
 	horizontalbar(int x, int y, int nc, int sc, ...);
 	horizontalbar(int nc, int sc, ...);
-	~horizontalbar();
+	virtual ~horizontalbar();
 
 	void movebar(int k);
 	virtual void redraw();
diff --git a/kkconsui/include/textbrowser.h b/kkconsui/include/textbrowser.h
index 71c81ef..65018c8 100644
--- a/kkconsui/include/textbrowser.h
+++ b/kkconsui/include/textbrowser.h
@@ -23,7 +23,7 @@ class textbrowser: public abstractuicontrol {
 	
 	textbrowser(int nx1, int ny1, int nx2, int ny2, int clr);
 	textbrowser(int clr = 0);
-	~textbrowser();
+	virtual ~textbrowser();
 
 	void setcolor(int clr);
 	void setcoords(int nx1, int ny1, int nx2, int ny2);
diff --git a/kkconsui/include/textwindow.h b/kkconsui/include/textwindow.h
index 6a01a8c..4f3a0e6 100644
--- a/kkconsui/include/textwindow.h
+++ b/kkconsui/include/textwindow.h
@@ -23,7 +23,7 @@ class textwindow: public abstractuicontrol {
 	textwindow(const textwindow &aw);
 	textwindow(int xx1, int yy1, int xx2, int yy2, int wcolor,
 	    int noptions = 0, int tcolor = 0, const char *tfmt = 0, ...);
-	~textwindow();
+	virtual ~textwindow();
 
 	void write(int x, int y, int c, const string &text);
 	void write(int x, int y, const string &text);
diff --git a/kkconsui/include/treeview.h b/kkconsui/include/treeview.h
index 6d4921b..d1a20f5 100644
--- a/kkconsui/include/treeview.h
+++ b/kkconsui/include/treeview.h
@@ -44,7 +44,7 @@ class treeview : public abstractuicontrol {
 	treeview(int nx1, int ny1, int nx2, int ny2, int nbgcolor, int nselectcolor, int nnodecolor, int nleafcolor);
 	treeview(int nbgcolor, int nselectcolor, int nnodecolor, int nleafcolor);
 	treeview();
-	~treeview();
+	virtual ~treeview();
 
 	bool empty();
 
diff --git a/kkconsui/src/abstractui.cc b/kkconsui/src/abstractui.cc
index 40d28ef..074e33a 100644
--- a/kkconsui/src/abstractui.cc
+++ b/kkconsui/src/abstractui.cc
@@ -25,7 +25,7 @@
 #include "abstractui.h"
 
 abstractuicontrol::abstractuicontrol()
-: fisopen(false), aborted(false), emacs(false), finished(false), x1(0), x2(0), y1(0), y2(0)
+: fisopen(false), finished(false), aborted(false), emacs(false), x1(0), x2(0), y1(0), y2(0)
 { }
 
 abstractuicontrol::abstractuicontrol(const abstractuicontrol &a)
diff --git a/kkconsui/src/dialogbox.cc b/kkconsui/src/dialogbox.cc
index b711199..f80894e 100644
--- a/kkconsui/src/dialogbox.cc
+++ b/kkconsui/src/dialogbox.cc
@@ -26,8 +26,8 @@
 
 dialogbox *dialogbox::it;
 
-dialogbox::dialogbox(): menu(0), tree(0), window(0), bar(0), browser(0),
-idle(0), otherkeys(0), first(true) {
+dialogbox::dialogbox(): first(true), menu(0), tree(0), window(0), bar(0), browser(0),
+otherkeys(0), idle(0) {
     freemenu = freetree = freewindow = freebar = freebrowser = false;
 }
 
@@ -108,7 +108,7 @@ bool dialogbox::open(int &menuitem, int &baritem, void **ref) {
 	int k;
 	menuitem = 0;
 
-	for(bool fin = false; !fin; ) {
+	for(fin = false; !fin; ) {
 	    proceed = idle ? keypressed() : true;
 	    it = this;
 
@@ -257,7 +257,6 @@ void dialogbox::browseridle(textbrowser &caller) {
 
 int dialogbox::menukeys(verticalmenu &caller, int k) {
     list<keybarassociation>::iterator i;
-    bool found;
     int ip;
     dialogbox *sit;
 
@@ -313,7 +312,6 @@ int dialogbox::menukeys(verticalmenu &caller, int k) {
 
 int dialogbox::browserkeys(textbrowser &caller, int k) {
     list<keybarassociation>::iterator i;
-    bool found;
     int ip;
     dialogbox *sit;
 
diff --git a/kkconsui/src/fileselector.cc b/kkconsui/src/fileselector.cc
index b69013e..a331067 100644
--- a/kkconsui/src/fileselector.cc
+++ b/kkconsui/src/fileselector.cc
@@ -7,7 +7,7 @@
 
 static fileselector *instance;
 
-fileselector::fileselector(): idle(0), otherkeys(0) {
+fileselector::fileselector(): otherkeys(0), idle(0) {
 }
 
 fileselector::~fileselector() {
diff --git a/kkconsui/src/texteditor.cc b/kkconsui/src/texteditor.cc
index 2cc9ce4..cd93d0b 100644
--- a/kkconsui/src/texteditor.cc
+++ b/kkconsui/src/texteditor.cc
@@ -76,7 +76,7 @@ texteditor::~texteditor() {
 }
 
 int texteditor::load(const string abuf, const string id) {
-    int newfn = addwindow(strdup(id.c_str())), k;
+    int newfn = addwindow(strdup(id.c_str()));
     string buf = abuf;
     vector<string> lst;
     vector<string>::iterator i;
@@ -479,7 +479,6 @@ void texteditor::delmark() {
 	    
 	} else {
 	    char *lch = (char *) curfile->lines->at(i-line);
-	    int li = strlen(lch);
 
 	    deltext += "\n";
 	    if(i == mb->y1) deltext += lch+mb->x1; else deltext += lch;
@@ -621,7 +620,6 @@ int dstralone(const char *buf, const char *startword, int wordlen, const char *d
 void texteditor::scancomments(bool visible) {
     int sl, el, i;
     const char *rsub, *lsub;
-    hl_kind hk;
 
     curfile->blocks->empty();
     
@@ -881,6 +879,13 @@ void texteditor::showline(int ln, int startx, int distance, int extrax) {
 			hi->color);
 		    
 		    break;
+
+                case h_quotes:
+                case h_comment:
+                    /* TODO: should these be handled,
+                     * are they possible to get here at all ?
+                     */
+                    break;
 	    }
 	}
 
diff --git a/kkstrtext/kkstrtext.cc b/kkstrtext/kkstrtext.cc
index a5bad23..6bc9179 100644
--- a/kkstrtext/kkstrtext.cc
+++ b/kkstrtext/kkstrtext.cc
@@ -27,7 +27,8 @@
 
 char *strcut(char *strin, int frompos, int count) {
     if(count > 0) {
-	if(count > strlen(strin)-frompos) count = strlen(strin)-frompos;
+	if(count > strlen(strin)-frompos) 
+	    count = strlen(strin)-frompos;
 	char *buf = (char *) malloc(strlen(strin) - frompos - count + 1);
 	memcpy(buf, strin + frompos + count, strlen(strin) - frompos - count);
 	memcpy(strin + frompos, buf, strlen(strin) - frompos - count);
@@ -60,13 +61,13 @@ char *time2str(const time_t *t, char *mask, char *sout) {
     struct tm *s;
     char ch, b[10], b1[20];
     int len, i, j;
-
+    
     sout[0] = 0;
     s = localtime(t);
-
+    
     for(i = 0; i < strlen(mask); i++) {
 	len = 0;
-    
+	
 	if(strchr("DMYhms", ch = mask[i])) {
 	    j = i; len = 1;
 	    while(mask[++j] == ch) len++;
@@ -99,9 +100,9 @@ time_t str2time(char *sdate, char *mask, time_t *t) {
     struct tm *s;
     int i, len, j, k;
     char ch, b[10];
-
+    
     s = (struct tm*) malloc(sizeof(struct tm));
-  
+    
     for(i = 0; i < strlen(mask); i++) {
 	len = 0;
     
@@ -761,8 +762,8 @@ string strdateandtime(time_t stamp, const string &fmt) {
 
 string strdateandtime(struct tm *tms, const string &fmt) {
     char buf[512];
-    time_t current_time = time(0);
-    time_t when = mktime(tms);
+    /*time_t current_time = time(0);*/
+    /*time_t when = mktime(tms);*/
     string afmt = fmt;
 
     if(afmt.empty()) {
diff --git a/src/hooks/HTTPClient.cc b/src/hooks/HTTPClient.cc
index b52a8e2..e1c3d6f 100644
--- a/src/hooks/HTTPClient.cc
+++ b/src/hooks/HTTPClient.cc
@@ -29,8 +29,8 @@
 
 #ifdef BUILD_RSS
 
-HTTPClient::HTTPClient() : m_recv(), m_state(NOT_CONNECTED),
-m_timeout(50), m_proxy_port(8080) {
+HTTPClient::HTTPClient() : m_state(NOT_CONNECTED), m_recv(), 
+m_proxy_port(8080), m_timeout(50)  {
     m_socket = new TCPSocket();
     Init();
 }
diff --git a/src/hooks/HTTPClient.h b/src/hooks/HTTPClient.h
index 0e65744..2512a00 100644
--- a/src/hooks/HTTPClient.h
+++ b/src/hooks/HTTPClient.h
@@ -38,8 +38,8 @@ class HTTPRequestEvent : public MessageEvent {
 
     public:
 	HTTPRequestEvent(const string &url, RequestMethod rt = GET)
-	    : MessageEvent(ContactRef()), m_url(url), method(rt),
-	      authTries(0), connectTries(0) { }
+	    : MessageEvent(ContactRef()), m_url(url), 
+	      authTries(0), connectTries(0), method(rt) { }
 
 	string getContent() const { return m_content; }
 	string getURL() const { return m_url; }
diff --git a/src/hooks/abstracthook.cc b/src/hooks/abstracthook.cc
index f5792c3..9abdb98 100644
--- a/src/hooks/abstracthook.cc
+++ b/src/hooks/abstracthook.cc
@@ -46,6 +46,9 @@ abstracthook::abstracthook(protocolname aproto)
     : proto(aproto), searchdest(0)
 { }
 
+abstracthook::~abstracthook() {
+}
+
 void abstracthook::init() {
 }
 
diff --git a/src/hooks/abstracthook.h b/src/hooks/abstracthook.h
index 7564a98..9bb54dd 100644
--- a/src/hooks/abstracthook.h
+++ b/src/hooks/abstracthook.h
@@ -98,6 +98,7 @@ class abstracthook {
 
     public:
 	abstracthook(protocolname aproto);
+        virtual ~abstracthook();
 
 	virtual void init();
 
diff --git a/src/hooks/aimhook.cc b/src/hooks/aimhook.cc
index ecd202c..415a509 100644
--- a/src/hooks/aimhook.cc
+++ b/src/hooks/aimhook.cc
@@ -35,7 +35,7 @@
 aimhook ahook;
 
 aimhook::aimhook()
-    : abstracthook(aim), handle(0), fonline(false), flogged(false),
+    : abstracthook(aim), fonline(false), flogged(false), handle(0), 
       ourstatus(offline)
 {
     fcapabs.insert(hookcapab::setaway);
diff --git a/src/hooks/icqhook.cc b/src/hooks/icqhook.cc
index 06263a1..6465a1d 100644
--- a/src/hooks/icqhook.cc
+++ b/src/hooks/icqhook.cc
@@ -1098,7 +1098,6 @@ static string fixicqrtf(string msg) {
 
 void icqhook::messaged_cb(MessageEvent *ev) {
     imcontact ic;
-    time_t t;
     string text;
 
     ic = imcontact(ev->getContact()->getUIN(), icq);
diff --git a/src/hooks/jabberhook.h b/src/hooks/jabberhook.h
index 2f7c547..ef7e957 100644
--- a/src/hooks/jabberhook.h
+++ b/src/hooks/jabberhook.h
@@ -86,7 +86,7 @@ class jabberhook: public abstracthook {
 
     public:
 	jabberhook();
-	~jabberhook();
+	virtual ~jabberhook();
 
 	void init();
 
diff --git a/src/hooks/msnhook.h b/src/hooks/msnhook.h
index 4bd96c0..88b4df8 100644
--- a/src/hooks/msnhook.h
+++ b/src/hooks/msnhook.h
@@ -138,7 +138,7 @@ class msnhook : public abstracthook {
 
     public:
 	msnhook();
-	~msnhook();
+	virtual ~msnhook();
 
 	void init();
 
diff --git a/src/icqcontact.h b/src/icqcontact.h
index ea51578..5fb73bf 100644
--- a/src/icqcontact.h
+++ b/src/icqcontact.h
@@ -24,8 +24,8 @@ class icqcontact {
     public:
 	struct basicinfo {
 	    basicinfo()
-		: country(0), requiresauth(false), webaware(false),
-		  authawait(false), randomgroup(0) { };
+              : country(0), randomgroup(0), requiresauth(false), 
+		  webaware(false), authawait(false)  { };
 
 	    string fname, lname, email, city, state, phone, fax;
 	    string street, cellular, zip;
@@ -123,8 +123,8 @@ class icqcontact {
 	bool hasevents() const { return fhasevents; }
 	void sethasevents(bool n) { fhasevents = n; }
 	bool isopenedforchat() const { return openedforchat; }
-	bool setopenedforchat(bool n) { openedforchat = n; }
-	bool toggleopenedforchat() { openedforchat = !openedforchat; }
+	void setopenedforchat(bool n) { openedforchat = n; }
+	void toggleopenedforchat() { openedforchat = !openedforchat; }
 
 	string getnick() const;
 	string getdispnick() const;