From: Darren Nickerson Date: Sat, 8 Feb 2003 22:32:29 +0000 (+0000) Subject: [Bug 267] Fix gcc warnings in -Wall mode X-Git-Tag: HYLAFAX-4_1_6BETA1~58 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=5ab07e4426ec2e9adc7328d586facebd881316cd;p=thirdparty%2FHylaFAX.git [Bug 267] Fix gcc warnings in -Wall mode Fixes suggest parentheses around assignment used as truth value This is Patrice's second kill. Nice work! --- diff --git a/faxd/DestControl.c++ b/faxd/DestControl.c++ index 27ecf591..b6352f0d 100644 --- a/faxd/DestControl.c++ +++ b/faxd/DestControl.c++ @@ -207,9 +207,9 @@ DestControl::readLine(FILE* fp, char line[], u_int cc) return (false); lineno++; char* cp; - if (cp = strchr(line, '#')) + if ((cp = strchr(line, '#'))) *cp = '\0'; - if (cp = strchr(line, '\n')) + if ((cp = strchr(line, '\n'))) *cp = '\0'; return (true); } diff --git a/faxd/FaxAcctInfo.c++ b/faxd/FaxAcctInfo.c++ index 143a75d4..452be14c 100644 --- a/faxd/FaxAcctInfo.c++ +++ b/faxd/FaxAcctInfo.c++ @@ -51,7 +51,7 @@ FaxAcctInfo::record(const char* cmd) const record.fput("\t%s", jobid); // $ 5 = jobid u_int i = 0; char c; - for (const char* cp = jobtag; c = *cp; cp++) { + for (const char* cp = jobtag; (c = *cp); cp++) { if (i == sizeof (buf)-2) // truncate string break; if (c == '\t') // tabs are field delimiters diff --git a/faxd/FaxRequest.c++ b/faxd/FaxRequest.c++ index 1b038203..3c5ecaf9 100644 --- a/faxd/FaxRequest.c++ +++ b/faxd/FaxRequest.c++ @@ -545,7 +545,7 @@ hasDotDot(const char* pathname) while (cp) { if (cp[0] == '.') // NB: good enough return (true); - if (cp = strchr(cp, '/')) + if ((cp = strchr(cp, '/'))) cp++; } return (false); diff --git a/faxd/G3Decoder.c++ b/faxd/G3Decoder.c++ index 21346859..0d6ac30c 100644 --- a/faxd/G3Decoder.c++ +++ b/faxd/G3Decoder.c++ @@ -116,7 +116,7 @@ void G3Decoder::setRuns(tiff_runlen_t* cr, tiff_runlen_t* rr, int w) { curruns = cr; - if (refruns = rr) { + if ((refruns = rr)) { refruns[0] = w; refruns[1] = 0; } diff --git a/faxmail/MsgFmt.c++ b/faxmail/MsgFmt.c++ index e067286a..64dd73eb 100644 --- a/faxmail/MsgFmt.c++ +++ b/faxmail/MsgFmt.c++ @@ -173,7 +173,7 @@ MsgFmt::setConfigItem(const char* tag, const char* value) } else { headToKeep.append(cp); } - } while (cp = tp); + } while ((cp = tp)); delete [] cp; } else if (streq(tag, "mapheader")) { char* tp = (char *) strchr(value, ' '); diff --git a/faxmail/faxmail.c++ b/faxmail/faxmail.c++ index 81400c30..3d866174 100644 --- a/faxmail/faxmail.c++ +++ b/faxmail/faxmail.c++ @@ -230,7 +230,7 @@ faxMailApp::run(int argc, char** argv) job->setDialString(dest); } const fxStr* s; - if (s = findHeader("x-fax-dialstring")) // dialstring in envelope + if ((s = findHeader("x-fax-dialstring"))) // dialstring in envelope job->setDialString(*s); if (job->getDialString() == "") fxFatal("No Destination/Dialstring specified"); @@ -240,7 +240,7 @@ faxMailApp::run(int argc, char** argv) */ if (optind+1 < argc) { client->setFromIdentity(argv[optind+1]); - } else if (s = findHeader("from")) { + } else if ((s = findHeader("from"))) { client->setFromIdentity(*s); } else { fxFatal("No From/Sender identity specified"); diff --git a/hfaxd/FileSystem.c++ b/hfaxd/FileSystem.c++ index cb2cf843..10d0b254 100644 --- a/hfaxd/FileSystem.c++ +++ b/hfaxd/FileSystem.c++ @@ -488,7 +488,7 @@ HylaFAXServer::listDirectory(FILE* fd, const SpoolDir& sd, DIR* dir) */ fxStr path(sd.pathname); struct dirent* dp; - while (dp = readdir(dir)) { + while ((dp = readdir(dir))) { if (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || strcmp(dp->d_name, "..") == 0)) continue; @@ -706,7 +706,7 @@ HylaFAXServer::nlstDirectory(FILE* fd, const SpoolDir& sd, DIR* dir) */ fxStr path(sd.pathname); struct dirent* dp; - while (dp = readdir(dir)) { + while ((dp = readdir(dir))) { if (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || strcmp(dp->d_name, "..") == 0)) continue; diff --git a/hfaxd/Jobs.c++ b/hfaxd/Jobs.c++ index be7c4ea8..aed2767e 100644 --- a/hfaxd/Jobs.c++ +++ b/hfaxd/Jobs.c++ @@ -1826,7 +1826,7 @@ void HylaFAXServer::listSendQ(FILE* fd, const SpoolDir&, DIR* dir) { struct dirent* dp; - while (dp = readdir(dir)) + while ((dp = readdir(dir))) if (dp->d_name[0] == 'q') { fxStr emsg; Job* job = findJob(&dp->d_name[1], emsg); @@ -1853,7 +1853,7 @@ void HylaFAXServer::nlstSendQ(FILE* fd, const SpoolDir&, DIR* dir) { struct dirent* dp; - while (dp = readdir(dir)) + while ((dp = readdir(dir))) if (dp->d_name[0] == 'q') { fxStr emsg; Job* job = findJob(&dp->d_name[1], emsg); diff --git a/hfaxd/OldProtocol.c++ b/hfaxd/OldProtocol.c++ index c56b4fef..db5c62ba 100644 --- a/hfaxd/OldProtocol.c++ +++ b/hfaxd/OldProtocol.c++ @@ -280,7 +280,7 @@ OldProtocolServer::doProtocol(void) */ if (strncmp(tag, _PATH_DEV, l) == 0) tag += l; - for (cp = tag; cp = strchr(cp, '/'); *cp = '_') + for (cp = tag; (cp = strchr(cp, '/')); *cp = '_') ; modem = tag; } else { @@ -1120,7 +1120,7 @@ OldProtocolServer::decodeLZW(FILE* fin, FILE* fout) char* tp = (len > sizeof (buf) ? (char*) malloc(len) : buf) + len; do { *--tp = codep->value; - } while (codep = codep->next); + } while ((codep = codep->next)); fwrite(tp, len, 1, fout); total += len; if (tp != buf) @@ -1359,7 +1359,7 @@ OldProtocolServer::sendRecvStatus(const char*) FAX_RECVDIR); fxStr path(FAX_RECVDIR "/"); struct dirent* dp; - while (dp = readdir(dir)) { + while ((dp = readdir(dir))) { const char* name = dp->d_name; if (name[0] != 'f' || name[1] != 'a' || name[2] != 'x') continue; diff --git a/hfaxd/RecvQueue.c++ b/hfaxd/RecvQueue.c++ index 26d33e1d..85f64f3e 100644 --- a/hfaxd/RecvQueue.c++ +++ b/hfaxd/RecvQueue.c++ @@ -196,7 +196,7 @@ HylaFAXServer::listRecvQ(FILE* fd, const SpoolDir& sd, DIR* dir) */ fxStr path(sd.pathname); struct dirent* dp; - while (dp = readdir(dir)) { + while ((dp = readdir(dir))) { struct stat sb; if (!isVisibleRecvQFile(dp->d_name, sb)) continue; diff --git a/hfaxd/Status.c++ b/hfaxd/Status.c++ index 3772aa96..232ceb9c 100644 --- a/hfaxd/Status.c++ +++ b/hfaxd/Status.c++ @@ -131,7 +131,7 @@ HylaFAXServer::listStatus(FILE* fd, const SpoolDir& sd, DIR* dir) struct stat sb; fxStr fifoPrefix("/" FAX_FIFO "."); struct dirent* dp; - while (dp = readdir(dir)) { + while ((dp = readdir(dir))) { fxStr statusFile(path | dp->d_name); if (!FileCache::update(statusFile, sb) || !S_ISREG(sb.st_mode)) continue; @@ -308,7 +308,7 @@ HylaFAXServer::nlstStatus(FILE* fd, const SpoolDir& sd, DIR* dir) struct stat sb; fxStr fifoPrefix("/" FAX_FIFO "."); struct dirent* dp; - while (dp = readdir(dir)) { + while ((dp = readdir(dir))) { fxStr statusFile(path | dp->d_name); if (!FileCache::update(statusFile, sb) || !S_ISREG(sb.st_mode)) continue; diff --git a/hfaxd/User.c++ b/hfaxd/User.c++ index 97555acf..6779e254 100644 --- a/hfaxd/User.c++ +++ b/hfaxd/User.c++ @@ -74,7 +74,7 @@ nextRecord(FILE* db, char line[], u_int size) break; *cp = '\0'; } - if (cp = strchr(line, '\n')) + if ((cp = strchr(line, '\n'))) *cp = '\0'; if (line[0] != '\0') return (true); diff --git a/util/DialRules.c++ b/util/DialRules.c++ index 1438399c..3fa7346c 100644 --- a/util/DialRules.c++ +++ b/util/DialRules.c++ @@ -120,7 +120,7 @@ DialStringRules::parseRules() { char line[1024]; char* cp; - while (cp = nextLine(line, sizeof (line))) { + while ((cp = nextLine(line, sizeof (line)))) { // collect token if (!isalpha(*cp)) { parseError("Syntax error, expecting identifier"); @@ -183,12 +183,12 @@ DialStringRules::nextLine(char* line, int lineSize) if (!fgets(line, lineSize, fp)) return (NULL); lineno++; - for (cp = line; cp = strchr(cp, '!'); cp++) + for (cp = line; (cp = strchr(cp, '!')); cp++) if (cp == line || cp[-1] != '\\') break; if (cp) *cp = '\0'; - else if (cp = strchr(line, '\n')) + else if ((cp = strchr(line, '\n'))) *cp = '\0'; for (cp = line; isspace(*cp); cp++) ; diff --git a/util/Dictionary.c++ b/util/Dictionary.c++ index 8f55471f..dcadee81 100644 --- a/util/Dictionary.c++ +++ b/util/Dictionary.c++ @@ -326,7 +326,7 @@ fxDictIter::advanceToValid() invalid = true; break; } - if (n = dict->buckets[bucket]) { // NB: intentional = + if ((n = dict->buckets[bucket])) { // NB: intentional = node = n; invalid = false; break; diff --git a/util/FaxDB.c++ b/util/FaxDB.c++ index bc857961..ef8cae0f 100644 --- a/util/FaxDB.c++ +++ b/util/FaxDB.c++ @@ -33,7 +33,7 @@ FaxDBRecord::FaxDBRecord() FaxDBRecord::FaxDBRecord(FaxDBRecord* other) { - if (parent = other) + if ((parent = other)) parent->inc(); } diff --git a/util/PageSize.c++ b/util/PageSize.c++ index a362a0d6..5a6997f0 100644 --- a/util/PageSize.c++ +++ b/util/PageSize.c++ @@ -84,7 +84,7 @@ PageSizeInfo::readPageInfoFile() char* cp = strchr(line, '#'); if (cp) *cp = '\0'; - else if (cp = strchr(line, '\n')) + else if ((cp = strchr(line, '\n'))) *cp = '\0'; for (cp = line; isspace(*cp); cp++) ; diff --git a/util/dialtest.c++ b/util/dialtest.c++ index 8061491b..31063fe5 100644 --- a/util/dialtest.c++ +++ b/util/dialtest.c++ @@ -109,7 +109,7 @@ main(int argc, char* argv[]) *cp = '\0'; if (verbose) printf("input = \"%s\"\n", line); - if (cp = strchr(line, '(')) { + if ((cp = strchr(line, '('))) { char* ep = strchr(cp, ')'); if (ep) *ep = '\0';