Skip to content

Commit

Permalink
Eliminate many of the warnings seen when the system is compiled with …
Browse files Browse the repository at this point in the history
…-Wall
  • Loading branch information
JonathanGuthrie committed Dec 6, 2013
1 parent 7dc4c2c commit b5ead20
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 26 deletions.
2 changes: 2 additions & 0 deletions checkhandler.cpp
Expand Up @@ -22,6 +22,8 @@ ImapHandler *checkHandler(ImapSession *session, INPUT_DATA_STRUCT &input) {
}

IMAP_RESULTS CheckHandler::receiveData(INPUT_DATA_STRUCT &input) {
(void) input;

// Unlike NOOP, I always call mailboxFlushBuffers because that recalculates the the cached data.
// That may be the only way to find out that the number of messages or the UIDNEXT value has
// changed.
Expand Down
2 changes: 2 additions & 0 deletions closehandler.cpp
Expand Up @@ -22,6 +22,8 @@ ImapHandler *closeHandler(ImapSession *session, INPUT_DATA_STRUCT &input) {
}

IMAP_RESULTS CloseHandler::receiveData(INPUT_DATA_STRUCT &input) {
(void) input;

// If the mailbox is open, close it
// In IMAP, deleted messages are always purged before a close
IMAP_RESULTS result = IMAP_TRY_AGAIN;
Expand Down
16 changes: 11 additions & 5 deletions datetime.cpp
Expand Up @@ -149,6 +149,8 @@ void DateTime::addDays(int days) {
// DOW MMM DD hh:mm:ss YYYY
// Note, no time zone.
bool DateTime::parseCtime(const uint8_t *data, size_t dataLen, size_t &parsingAt) {
(void) dataLen;

m_valid = false;
// Day of week
// tuesday and thursday
Expand Down Expand Up @@ -366,7 +368,7 @@ bool DateTime::parseCtime(const uint8_t *data, size_t dataLen, size_t &parsingAt
if (1 == m_tm.tm_mon) {
if ((29 < m_tm.tm_mday) ||
((29 == m_tm.tm_mday) &&
(0 != (m_tm.tm_year % 4)) || ((0 == m_tm.tm_year % 100) && (0 != m_tm.tm_year % 400)))) {
((0 != (m_tm.tm_year % 4)) || ((0 == m_tm.tm_year % 100) && (0 != m_tm.tm_year % 400))))) {
return false;
}
}
Expand Down Expand Up @@ -514,7 +516,7 @@ bool DateTime::parseImap(const uint8_t *data, size_t dataLen, size_t &parsingAt)

// If I'm looking at Feb 29, then it needs to be a leap year
if ((1 == m_tm.tm_mon) && (29 == m_tm.tm_mday) &&
(0 != (m_tm.tm_year % 4)) || ((0 == m_tm.tm_year % 100) && (0 != m_tm.tm_year % 400))) {
((0 != (m_tm.tm_year % 4)) || ((0 == m_tm.tm_year % 100) && (0 != m_tm.tm_year % 400)))) {
return false;
}

Expand Down Expand Up @@ -571,7 +573,7 @@ bool DateTime::parseImap(const uint8_t *data, size_t dataLen, size_t &parsingAt)

// Use Zeller's Congruence to calculate the day of the week
// See, for example http://en.wikipedia.org/wiki/Zeller's_congruence
int zMonth, zYear;
int zYear;
int table[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
zYear = (m_tm.tm_mon < 2) ? m_tm.tm_year - 1 : m_tm.tm_year;
m_tm.tm_wday = (zYear + zYear / 4 - zYear / 100 + zYear / 400 + table[m_tm.tm_mon] + m_tm.tm_mday) % 7;
Expand Down Expand Up @@ -645,6 +647,8 @@ bool DateTime::parseImap(const uint8_t *data, size_t dataLen, size_t &parsingAt)
* the obsolete fields are the same as the current fields.
*/
bool DateTime::parseRfc822(const uint8_t *data, size_t dataLen, size_t &parsingAt) {
(void) dataLen;

m_valid = false;
// Day of week
// tuesday and thursday
Expand Down Expand Up @@ -849,7 +853,7 @@ bool DateTime::parseRfc822(const uint8_t *data, size_t dataLen, size_t &parsingA
if (1 == m_tm.tm_mon) {
if ((29 < m_tm.tm_mday) ||
((29 == m_tm.tm_mday) &&
(0 != (m_tm.tm_year % 4)) || ((0 == m_tm.tm_year % 100) && (0 != m_tm.tm_year % 400)))) {
((0 != (m_tm.tm_year % 4)) || ((0 == m_tm.tm_year % 100) && (0 != m_tm.tm_year % 400))))) {
return false;
}
}
Expand Down Expand Up @@ -1054,6 +1058,8 @@ bool DateTime::parseRfc822(const uint8_t *data, size_t dataLen, size_t &parsingA
*/

bool DateTime::parseFromLine(const uint8_t *data, size_t dataLen, size_t &parsingAt) {
(void) dataLen;

m_valid = false;

// It appears as if PostFix puts an extra space before the date
Expand Down Expand Up @@ -1368,7 +1374,7 @@ bool DateTime::parseFromLine(const uint8_t *data, size_t dataLen, size_t &parsin
if (1 == m_tm.tm_mon) {
if ((29 < m_tm.tm_mday) ||
((29 == m_tm.tm_mday) &&
(0 != (m_tm.tm_year % 4)) || ((0 == m_tm.tm_year % 100) && (0 != m_tm.tm_year % 400)))) {
((0 != (m_tm.tm_year % 4)) || ((0 == m_tm.tm_year % 100) && (0 != m_tm.tm_year % 400))))) {
return false;
}
}
Expand Down
6 changes: 6 additions & 0 deletions expungehandler.cpp
Expand Up @@ -22,6 +22,8 @@ ImapHandler *expungeHandler(ImapSession *session, INPUT_DATA_STRUCT &input) {
}

IMAP_RESULTS ExpungeHandler::receiveData(INPUT_DATA_STRUCT &input) {
(void) input;

IMAP_RESULTS result = IMAP_MBOX_ERROR;
NUMBER_SET purgedMessages;

Expand All @@ -34,6 +36,10 @@ IMAP_RESULTS ExpungeHandler::receiveData(INPUT_DATA_STRUCT &input) {
case MailStore::CANNOT_COMPLETE_ACTION:
result = IMAP_TRY_AGAIN;
break;

default:
result = IMAP_NO;
break;
}

return result;
Expand Down
2 changes: 2 additions & 0 deletions imapsession.cpp
Expand Up @@ -953,6 +953,8 @@ void ImapSession::responseCode(const std::string &msg) {
}

void ImapSession::selectData(const std::string &mailbox, bool isReadWrite) {
(void) mailbox;

std::ostringstream ss;
m_currentNextUid = m_store->serialNumber();
m_currentUidValidity = m_store->uidValidityNumber();
Expand Down
1 change: 1 addition & 0 deletions imapuser.cpp
Expand Up @@ -19,6 +19,7 @@
#include "imapuser.hpp"

ImapUser::ImapUser(const char *user, const ImapMaster *master) {
(void) master;
m_name = new std::string(user);
m_userFound = false;
}
Expand Down
4 changes: 1 addition & 3 deletions listhandler.cpp
Expand Up @@ -28,7 +28,7 @@ ImapHandler *listHandler(ImapSession *session, INPUT_DATA_STRUCT &input) {

static std::string imapQuoteString(const std::string &to_be_quoted) {
std::string result("\"");
for (int i=0; i<to_be_quoted.size(); ++i) {
for (size_t i=0; i<to_be_quoted.size(); ++i) {
if ('\\' == to_be_quoted[i]) {
result += '\\';
}
Expand Down Expand Up @@ -74,8 +74,6 @@ static std::string genMailboxFlags(const uint32_t attr) {
}

IMAP_RESULTS ListHandler::execute(void) {
IMAP_RESULTS result = IMAP_MBOX_ERROR;

std::string reference = m_parseBuffer->arguments();
std::string mailbox = m_parseBuffer->arguments()+(strlen(m_parseBuffer->arguments())+1);

Expand Down
14 changes: 7 additions & 7 deletions mailmessage.cpp
Expand Up @@ -170,7 +170,7 @@ static MIME_MEDIA_TYPES GetMediaType(const insensitiveString &contentTypeLine) {

if (0 < contentTypeLine.size()) {
insensitiveString work = contentTypeLine;
int pos = work.find('/');
size_t pos = work.find('/');
if (std::string::npos != pos) {
int end = work.find_last_not_of(SPACE, pos-1);
int begin = work.find_first_not_of(SPACE);
Expand Down Expand Up @@ -204,10 +204,10 @@ std::string GetMediaBoundary(const insensitiveString &contentTypeLine) {
std::string result;
insensitiveString work = contentTypeLine;

int pos = work.find("boundary=");
size_t pos = work.find("boundary=");
if (std::string::npos != pos) {
int end = work.find_last_not_of(SPACE);
int begin = work.find_first_not_of(SPACE, pos+9);
size_t end = work.find_last_not_of(SPACE);
size_t begin = work.find_first_not_of(SPACE, pos+9);

result = contentTypeLine.substr(begin, end-begin+1).c_str();
pos = result.find(';');
Expand All @@ -231,11 +231,11 @@ bool MailMessage::processHeaderLine(const insensitiveString &line) {
bool result = true;

if (0 != line.size()) {
int colon = line.find(':');
size_t colon = line.find(':');

if (std::string::npos != colon) {
int end = line.find_last_not_of(SPACE);
int begin = line.find_first_not_of(SPACE, colon+1);
size_t end = line.find_last_not_of(SPACE);
size_t begin = line.find_first_not_of(SPACE, colon+1);
insensitiveString right;
if (std::string::npos != begin) {
right = line.substr(begin, end-begin+1);
Expand Down
7 changes: 5 additions & 2 deletions mailsearch.cpp
Expand Up @@ -361,7 +361,7 @@ static bool recursiveBodySearch(MESSAGE_BODY root, const MailSearch::TEXT_SEARCH
}
if (!result) {
if (NULL != root.subparts) {
for (int i = 0; i < root.subparts->size(); i++) {
for (size_t i = 0; i < root.subparts->size(); i++) {
result = recursiveBodySearch((*root.subparts)[i], target, bigBuffer);
}
}
Expand All @@ -380,7 +380,7 @@ MailStore::MAIL_STORE_RESULT MailSearch::evaluate(MailStore *where) {
}
else {
if ((0 != (m_includeMask | m_excludeMask)) ||
(0 < m_smallestSize) || ((~0) > m_largestSize) ||
(0 < m_smallestSize) || (LONG_MAX > m_largestSize) ||
(NULL != m_beginInternalDate) || (NULL != m_endInternalDate)) {
if ((0 == (m_includeMask & m_excludeMask)) &&
(m_smallestSize <= m_largestSize) &&
Expand Down Expand Up @@ -466,6 +466,9 @@ MailStore::MAIL_STORE_RESULT MailSearch::evaluate(MailStore *where) {
itIsIn = (std::string::npos != line.find(target));
}
break;

default:
break;
}
}

Expand Down
70 changes: 70 additions & 0 deletions mailstoreinvalid.cpp
Expand Up @@ -20,14 +20,19 @@ MailStoreInvalid::MailStoreInvalid(ImapSession *session) : MailStore(session) {
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::createMailbox(const std::string &FullName) {
(void) FullName;
return GENERAL_FAILURE;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::deleteMailbox(const std::string &FullName) {
(void) FullName;
return GENERAL_FAILURE;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::renameMailbox(const std::string &SourceName, const std::string &DestinationName) {
(void) SourceName;
(void) DestinationName;

return GENERAL_FAILURE;
}

Expand All @@ -36,22 +41,43 @@ MailStore::MAIL_STORE_RESULT MailStoreInvalid::mailboxClose() {
}

void MailStoreInvalid::mailboxList(const std::string &pattern, MAILBOX_LIST *result, bool listAll) {
(void) pattern;
(void) result;
(void) listAll;

// The nothing that MAILBOX_LIST starts as is is appropriate here.
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::subscribeMailbox(const std::string &MailboxName, bool isSubscribe) {
(void) MailboxName;
(void) isSubscribe;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::addMessageToMailbox(const std::string &MailboxName, const uint8_t *data, size_t length,
DateTime &createTime, uint32_t messageFlags, size_t *newUid ) {
(void) MailboxName;
(void) data;
(void) length;
(void) createTime;
(void) messageFlags;
(void) newUid;

return GENERAL_FAILURE;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::appendDataToMessage(const std::string &MailboxName, size_t uid, const uint8_t *data, size_t length) {
(void) MailboxName;
(void) uid;
(void) data;
(void) length;

return GENERAL_FAILURE;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::doneAppendingDataToMessage(const std::string &MailboxName, size_t uid) {
(void) MailboxName;
(void) uid;

return GENERAL_FAILURE;
}

Expand All @@ -66,20 +92,35 @@ unsigned MailStoreInvalid::uidValidityNumber() {
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::mailboxOpen(const std::string &MailboxName, bool readWrite) {
(void) MailboxName;
(void) readWrite;

return GENERAL_FAILURE;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::listDeletedMessages(NUMBER_SET *nowGone) {
(void) nowGone;

return GENERAL_FAILURE;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::expungeThisUid(unsigned long uid) {
(void) uid;

return GENERAL_FAILURE;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::getMailboxCounts(const std::string &MailboxName, uint32_t which, unsigned &messageCount,
unsigned &recentCount, unsigned &uidNext, unsigned &uidValidity,
unsigned &firstUnseen) {
(void) MailboxName;
(void) which;
(void) messageCount;
(void) recentCount;
(void) uidNext;
(void) uidValidity;
(void) firstUnseen;

return GENERAL_FAILURE;
}

Expand All @@ -96,12 +137,18 @@ unsigned MailStoreInvalid::mailboxFirstUnseen() {
}

const DateTime &MailStoreInvalid::messageInternalDate(const unsigned long uid) {
(void) uid;
// SYZYGY -- I need something like a void cast to DateTime that returns an error
static DateTime now;
return now;
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::messageUpdateFlags(unsigned long uid, uint32_t andMask, uint32_t orMask, uint32_t &flags) {
(void) uid;
(void) andMask;
(void) orMask;
(void) flags;

return GENERAL_FAILURE;
}

Expand All @@ -114,6 +161,8 @@ MailStore::MAIL_STORE_RESULT MailStoreInvalid::mailboxFlushBuffers(void) {
}

MailStore::MAIL_STORE_RESULT MailStoreInvalid::mailboxUpdateStats(NUMBER_SET *nowGone) {
(void) nowGone;

return GENERAL_FAILURE;
}

Expand All @@ -122,31 +171,52 @@ MailStoreInvalid::~MailStoreInvalid() {


MailStore::MAIL_STORE_RESULT MailStoreInvalid::deleteMessage(const std::string &MailboxName, unsigned long uid) {
(void) MailboxName;
(void) uid;

return GENERAL_FAILURE;
}

MailMessage::MAIL_MESSAGE_RESULT MailStoreInvalid::messageData(MailMessage **message, unsigned long uid) {
(void) message;
(void) uid;

*message = NULL;
return MailMessage::MESSAGE_DOESNT_EXIST;
}


MailStore::MAIL_STORE_RESULT MailStoreInvalid::openMessageFile(unsigned long uid) {
(void) uid;

return MailStore::GENERAL_FAILURE;
}

size_t MailStoreInvalid::bufferLength(unsigned long uid) {
(void) uid;

return 0;
}

size_t MailStoreInvalid::readMessage(char *buff, size_t offset, size_t length) {
(void) buff;
(void) offset;
(void) length;

return 0;
}

void MailStoreInvalid::closeMessageFile(void) {
}

const SEARCH_RESULT *MailStoreInvalid::searchMetaData(uint32_t xorMask, uint32_t andMask, size_t smallestSize, size_t largestSize, DateTime *beginInternalDate, DateTime *endInternalDate) {
(void) xorMask;
(void) andMask;
(void) smallestSize;
(void) largestSize;
(void) beginInternalDate;
(void) endInternalDate;

return NULL;
}

Expand Down

0 comments on commit b5ead20

Please sign in to comment.