Compiler warnings when compiling centericq
Håkan Kvist <[email protected]> Sun, 25 Feb 2007 21:20:05 +0100
| Newsgroups | gmane.network.centericq |
|---|---|
| Message-ID | <[email protected]> |
Hello I think that centericq would benefit of getting the number of compiler warnings minimized when compiling with the options -Wall -pedantic (with gcc/g++). This would hopefully improve the quality of the code, and hopefully get rid of some memory leaks. Enabling these today will print out ALOT of thingies that gcc could be improved. I have created a small patch wich makes it possible to compile with the -pedantic flag (attatched). 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/
centerim_pedantic.patch
(text/plain, 3.6 KB)
diff --git a/kkconsui/src/texteditor.cc b/kkconsui/src/texteditor.cc
index 4b9e323..fdd8462 100644
--- a/kkconsui/src/texteditor.cc
+++ b/kkconsui/src/texteditor.cc
@@ -791,8 +791,8 @@ void texteditor::showline(int ln, int startx, int distance, int extrax) {
const char *p;
if(!(cs = (char *) curfile->lines->at(ln))) return;
- char cp[i = (strlen(cs)+1)*4];
- char buf[i];
+ char *cp = (char *) malloc(i = ((strlen(cs)+1)*4)*sizeof(char));
+ char *buf = (char *) malloc(i);
eolstart = i;
@@ -970,6 +970,9 @@ void texteditor::showline(int ln, int startx, int distance, int extrax) {
if(printed < 0) printed = 0; else
if(printed > distance) printed = distance;
mvhline(y1+ln-curfile->sy, x1+extrax+printed, ' ', distance-printed);
+
+ free (buf);
+ free (cp);
}
void texteditor::draw(int fromline) {
diff --git a/libicq2000/libicq2000/constants.h b/libicq2000/libicq2000/constants.h
index ea6cc3a..dcd2789 100644
--- a/libicq2000/libicq2000/constants.h
+++ b/libicq2000/libicq2000/constants.h
@@ -34,7 +34,7 @@ enum Status
STATUS_OCCUPIED,
STATUS_DND,
STATUS_FREEFORCHAT,
- STATUS_OFFLINE,
+ STATUS_OFFLINE
};
static const unsigned int SMS_Max_Length = 160;
diff --git a/libicq2000/libicq2000/events.h b/libicq2000/libicq2000/events.h
index a19451f..ab207e3 100644
--- a/libicq2000/libicq2000/events.h
+++ b/libicq2000/libicq2000/events.h
@@ -367,7 +367,7 @@ namespace ICQ2000 {
*/
enum EventType {
StatusChange,
- UserInfoChange,
+ UserInfoChange
};
protected:
diff --git a/libicq2000/libicq2000/userinfoconstants.h b/libicq2000/libicq2000/userinfoconstants.h
index 3f26afb..23f4417 100644
--- a/libicq2000/libicq2000/userinfoconstants.h
+++ b/libicq2000/libicq2000/userinfoconstants.h
@@ -154,7 +154,7 @@ enum Language
LANGUAGE_AFRIKAANS = 56,
LANGUAGE_PERSIAN = 57,
LANGUAGE_ALBANIAN = 58,
- LANGUAGE_ARMENIAN = 59,
+ LANGUAGE_ARMENIAN = 59
};
enum Country
@@ -401,7 +401,7 @@ enum Country
COUNTRY_YUGOSLAVIA = 381,
COUNTRY_ZAIRE = 243,
COUNTRY_ZAMBIA = 260,
- COUNTRY_ZIMBABWE = 263,
+ COUNTRY_ZIMBABWE = 263
};
enum Interest
@@ -456,7 +456,7 @@ enum Interest
INTEREST_AUDIO_AND_VISUAL = 147,
INTEREST_SPORTING_AND_ATHLETICS = 148,
INTEREST_PUBLISHING = 149,
- INTEREST_HOME_AUTOMATION = 150,
+ INTEREST_HOME_AUTOMATION = 150
};
enum Background
@@ -468,7 +468,7 @@ enum Background
BACKGROUND_MILITARY = 304,
BACKGROUND_PAST_WORK_PLACE = 305,
BACKGROUND_PAST_ORGANIZATION = 306,
- BACKGROUND_OTHER = 399,
+ BACKGROUND_OTHER = 399
};
@@ -480,7 +480,7 @@ enum AgeRange
RANGE_30_39 = 3,
RANGE_40_49 = 4,
RANGE_50_59 = 5,
- RANGE_60_ABOVE = 6,
+ RANGE_60_ABOVE = 6
};
}
diff --git a/libicq2000/src/socket.cpp b/libicq2000/src/socket.cpp
index c8d1ea1..1cb89d4 100644
--- a/libicq2000/src/socket.cpp
+++ b/libicq2000/src/socket.cpp
@@ -183,7 +183,7 @@ namespace ICQ2000
int ret;
unsigned int sent = 0;
- unsigned char data[b.size()];
+ unsigned char *data = (unsigned char *) malloc(b.size());
copy( b.begin(), b.end(), data );
while (sent < b.size())
@@ -193,11 +193,13 @@ namespace ICQ2000
m_state = NOT_CONNECTED;
close(m_socketDescriptor);
m_socketDescriptor_valid = false;
+ free(data);
throw SocketException("Sending on socket");
}
sent += ret;
}
+ free(data);
}
bool TCPSocket::Recv(Buffer& b) {