diff options
Diffstat (limited to 'imap/src')
40 files changed, 506 insertions, 495 deletions
diff --git a/imap/src/c-client/auth_ext.c b/imap/src/c-client/auth_ext.c index 61dfc1b8..c8c5f4ac 100644 --- a/imap/src/c-client/auth_ext.c +++ b/imap/src/c-client/auth_ext.c @@ -59,11 +59,11 @@ long auth_external_client (authchallenge_t challenger,authrespond_t responder, unsigned long clen; long ret = NIL; *trial = 65535; /* never retry */ - if (challenge = (*challenger) (stream,&clen)) { + if ((challenge = (*challenger) (stream,&clen)) != NULL) { fs_give ((void **) &challenge); /* send authorization id (empty string OK) */ if ((*responder) (stream,strcpy (user,mb->user),strlen (mb->user))) { - if (challenge = (*challenger) (stream,&clen)) + if ((challenge = (*challenger) (stream,&clen)) != NULL) fs_give ((void **) &challenge); else ret = LONGT; /* check the authentication */ } diff --git a/imap/src/c-client/auth_gss.c b/imap/src/c-client/auth_gss.c index 26bf9e50..66be8cce 100644 --- a/imap/src/c-client/auth_gss.c +++ b/imap/src/c-client/auth_gss.c @@ -97,7 +97,7 @@ long auth_gssapi_client (authchallenge_t challenger,authrespond_t responder, long ret = NIL; *trial = 65535; /* never retry */ /* get initial (empty) challenge */ - if (chal.value = (*challenger) (stream,(unsigned long *) &chal.length)) { + if ((chal.value = (*challenger) (stream,(unsigned long *) &chal.length)) != NULL) { if (chal.length) { /* abort if challenge non-empty */ mm_log ("Server bug: non-empty initial GSSAPI challenge",WARN); (*responder) (stream,NIL,0); @@ -336,7 +336,7 @@ char *auth_gssapi_server (authresponse_t responder,int argc,char *argv[]) GSS_S_COMPLETE) { if ((smj = gss_acquire_cred (&smn,crname,0,NIL,GSS_C_ACCEPT,&crd,NIL,NIL)) == GSS_S_COMPLETE) { - if (resp.value = (*responder) ("",0,(unsigned long *) &resp.length)) { + if ((resp.value = (*responder) ("",0,(unsigned long *) &resp.length)) != NULL) { do { /* negotiate authentication */ smj = gss_accept_sec_context (&smn,&ctx,crd,&resp, GSS_C_NO_CHANNEL_BINDINGS,&name,&mech, diff --git a/imap/src/c-client/auth_log.c b/imap/src/c-client/auth_log.c index 1e1b1b5c..6615744f 100644 --- a/imap/src/c-client/auth_log.c +++ b/imap/src/c-client/auth_log.c @@ -63,7 +63,7 @@ long auth_login_client (authchallenge_t challenger,authrespond_t responder, unsigned long clen; long ret = NIL; /* get user name prompt */ - if (challenge = (*challenger) (stream,&clen)) { + if ((challenge = (*challenger) (stream,&clen)) != NULL) { fs_give ((void **) &challenge); pwd[0] = NIL; /* prompt user */ mm_login (mb,user,pwd,*trial); @@ -78,7 +78,7 @@ long auth_login_client (authchallenge_t challenger,authrespond_t responder, fs_give ((void **) &challenge); /* send password */ if ((*responder) (stream,pwd,strlen (pwd))) { - if (challenge = (*challenger) (stream,&clen)) + if ((challenge = (*challenger) (stream,&clen)) != NULL) fs_give ((void **) &challenge); else { ++*trial; /* can try again if necessary */ @@ -104,10 +104,10 @@ char *auth_login_server (authresponse_t responder,int argc,char *argv[]) { char *ret = NIL; char *user,*pass,*authuser; - if (user = (*responder) (PWD_USER,sizeof (PWD_USER),NIL)) { - if (pass = (*responder) (PWD_PWD,sizeof (PWD_PWD),NIL)) { + if ((user = (*responder) (PWD_USER,sizeof (PWD_USER),NIL)) != NULL) { + if ((pass = (*responder) (PWD_PWD,sizeof (PWD_PWD),NIL)) != NULL) { /* delimit user from possible admin */ - if (authuser = strchr (user,'*')) *authuser++ = '\0'; + if ((authuser = strchr (user,'*')) != NULL) *authuser++ = '\0'; if (server_login (user,pass,authuser,argc,argv)) ret = myusername (); fs_give ((void **) &pass); } diff --git a/imap/src/c-client/auth_md5.c b/imap/src/c-client/auth_md5.c index f32ebc88..9c81d308 100644 --- a/imap/src/c-client/auth_md5.c +++ b/imap/src/c-client/auth_md5.c @@ -100,7 +100,7 @@ long auth_md5_client (authchallenge_t challenger,authrespond_t responder, unsigned long clen; long ret = NIL; /* get challenge */ - if (challenge = (*challenger) (stream,&clen)) { + if ((challenge = (*challenger) (stream,&clen)) != NULL) { pwd[0] = NIL; /* prompt user */ mm_login (mb,user,pwd,*trial); if (!pwd[0]) { /* user requested abort */ @@ -115,7 +115,7 @@ long auth_md5_client (authchallenge_t challenger,authrespond_t responder, fs_give ((void **) &challenge); /* send credentials, allow retry if OK */ if ((*responder) (stream,pwd,strlen (pwd))) { - if (challenge = (*challenger) (stream,&clen)) + if ((challenge = (*challenger) (stream,&clen)) != NULL) fs_give ((void **) &challenge); else { ++*trial; /* can try again if necessary */ @@ -150,14 +150,14 @@ char *auth_md5_server (authresponse_t responder,int argc,char *argv[]) sprintf (chal,"<%lu.%lu@%s>",(unsigned long) getpid (), (unsigned long) time (0),mylocalhost ()); /* send challenge, get user and hash */ - if (user = (*responder) (chal,cl = strlen (chal),NIL)) { + if ((user = (*responder) (chal,cl = strlen (chal),NIL)) != NULL) { /* got user, locate hash */ - if (hash = strrchr (user,' ')) { + if ((hash = strrchr (user,' ')) != NULL) { *hash++ = '\0'; /* tie off user */ /* see if authentication user */ - if (authuser = strchr (user,'*')) *authuser++ = '\0'; + if ((authuser = strchr (user,'*')) != NULL) *authuser++ = '\0'; /* get password */ - if (p = auth_md5_pwd ((authuser && *authuser) ? authuser : user)) { + if ((p = auth_md5_pwd ((authuser && *authuser) ? authuser : user)) != NULL) { pl = strlen (p); u = (md5try && !strcmp (hash,hmac_md5 (hshbuf,chal,cl,p,pl))) ? user : NIL; @@ -234,9 +234,9 @@ char *apop_login (char *chal,char *user,char *md5,int argc,char *argv[]) MD5CONTEXT ctx; char *hex = "0123456789abcdef"; /* see if authentication user */ - if (authuser = strchr (user,'*')) *authuser++ = '\0'; + if ((authuser = strchr (user,'*')) != NULL) *authuser++ = '\0'; /* get password */ - if (s = auth_md5_pwd ((authuser && *authuser) ? authuser : user)) { + if ((s = auth_md5_pwd ((authuser && *authuser) ? authuser : user)) != NULL) { md5_init (&ctx); /* initialize MD5 context */ /* build string to get MD5 digest */ sprintf (tmp,"%.128s%.128s",chal,s); diff --git a/imap/src/c-client/auth_pla.c b/imap/src/c-client/auth_pla.c index 73ca2259..ef991f1d 100644 --- a/imap/src/c-client/auth_pla.c +++ b/imap/src/c-client/auth_pla.c @@ -63,7 +63,7 @@ long auth_plain_client (authchallenge_t challenger,authrespond_t responder, if (!mb->sslflag && !mb->tlsflag) mm_log ("SECURITY PROBLEM: insecure server advertised AUTH=PLAIN",WARN); /* get initial (empty) challenge */ - if (challenge = (*challenger) (stream,&clen)) { + if ((challenge = (*challenger) (stream,&clen)) != NULL) { fs_give ((void **) &challenge); if (clen) { /* abort if challenge non-empty */ mm_log ("Server bug: non-empty initial PLAIN challenge",WARN); @@ -91,7 +91,7 @@ long auth_plain_client (authchallenge_t challenger,authrespond_t responder, for (u = pwd; *u; *t++ = *u++); /* send credentials */ if ((*responder) (stream,response,rlen)) { - if (challenge = (*challenger) (stream,&clen)) + if ((challenge = (*challenger) (stream,&clen)) != NULL) fs_give ((void **) &challenge); else { ++*trial; /* can try again if necessary */ @@ -120,7 +120,7 @@ char *auth_plain_server (authresponse_t responder,int argc,char *argv[]) char *user,*aid,*pass; unsigned long len; /* get user name */ - if (aid = (*responder) ("",0,&len)) { + if ((aid = (*responder) ("",0,&len)) != NULL) { /* note: responders null-terminate */ if ((((unsigned long) ((user = aid + strlen (aid) + 1) - aid)) < len) && (((unsigned long) ((pass = user + strlen (user) + 1) - aid)) < len) && diff --git a/imap/src/c-client/imap4r1.c b/imap/src/c-client/imap4r1.c index f35b14b4..dbd945ec 100644 --- a/imap/src/c-client/imap4r1.c +++ b/imap/src/c-client/imap4r1.c @@ -504,10 +504,10 @@ void imap_lsub (MAILSTREAM *stream,char *ref,char *pat) if (ref && *ref) sprintf (mbx,"%s%s",ref,pat); else strcpy (mbx,pat); - if (s = sm_read (tmp,&sdb)) do if (imap_valid (s) && pmatch (s,mbx)) + if ((s = sm_read (tmp,&sdb)) != NULL) do if (imap_valid (s) && pmatch (s,mbx)) mm_lsub (stream,NIL,s,NIL); /* until no more subscriptions */ - while (s = sm_read (tmp,&sdb)); + while ((s = sm_read (tmp,&sdb)) != NULL); } /* IMAP find list of mailboxes @@ -849,7 +849,7 @@ MAILSTREAM *imap_open (MAILSTREAM *stream) * order, attempt to open via simap, tryssl, rimap, and finally TCP. */ /* try simap */ - else if (reply = imap_rimap (stream,"*imap",&mb,usr,tmp)); + else if ((reply = imap_rimap (stream,"*imap",&mb,usr,tmp)) != NULL); else if (ssld && /* try tryssl if enabled */ (stream->tryssl || mail_parameters (NIL,GET_TRYSSLFIRST,NIL)) && (LOCAL->netstream = @@ -1325,7 +1325,7 @@ void imap_close (MAILSTREAM *stream,long options) } if (LOCAL->threaddata) mail_free_threadnode (&LOCAL->threaddata); /* flush threaders */ - if (thr = LOCAL->cap.threader) while (t = thr) { + if ((thr = LOCAL->cap.threader) != NULL) while ((t = thr) != NULL) { fs_give ((void **) &t->name); thr = t->next; fs_give ((void **) &t); @@ -1507,8 +1507,8 @@ ENVELOPE *imap_structure (MAILSTREAM *stream,unsigned long msgno,BODY **body, set = set->next) { i = (set->first == 0xffffffff) ? stream->nmsgs : min (set->first,stream->nmsgs); - if (j = (set->last == 0xffffffff) ? stream->nmsgs : - min (set->last,stream->nmsgs)) { + if ((j = (set->last == 0xffffffff) ? stream->nmsgs : + min (set->last,stream->nmsgs)) != 0L) { if (i > j) { /* swap the range if backwards */ x = i; i = j; j = x; } @@ -1530,7 +1530,7 @@ ENVELOPE *imap_structure (MAILSTREAM *stream,unsigned long msgno,BODY **body, sprintf (s += strlen (s),",%lu:%lu",i,x); i = 1 + x - i; /* number of messages in this range */ /* still can look ahead some more? */ - if (k = (k > i) ? k - i : 0) + if ((k = (k > i) ? k - i : 0) != 0) /* yes, scan further in this range */ for (i = x + 2; (i <= j) && ((i == msgno) || @@ -1708,7 +1708,7 @@ long imap_msgdata (MAILSTREAM *stream,unsigned long msgno,char *section, else if (!section[0]) /* BODY[] becomes RFC822 */ aatt.text = (void *) ((flags & FT_PEEK) ? "RFC822.PEEK" : "RFC822"); /* nested header */ - else if (t = strstr (section,".HEADER")) { + else if ((t = strstr (section,".HEADER")) != NULL) { aatt.type = (flags & FT_PEEK) ? BODYPEEK : BODYTEXT; args[2] = &acls; /* will need to close section */ aatt.text = (void *) tmp; /* convert .HEADER to .0 */ @@ -1892,7 +1892,7 @@ unsigned long imap_uid (MAILSTREAM *stream,unsigned long msgno) aatt.type = ATOM; aatt.text = (void *) "UID"; args[0] = &aseq; args[1] = &aatt; args[2] = NIL; sprintf (seq,"%lu",msgno); - if (k = imap_uidlookahead) {/* build UID list */ + if ((k = imap_uidlookahead) != 0L) {/* build UID list */ for (i = msgno + 1, s = seq; k && (i <= stream->nmsgs); i++) if (!mail_elt (stream,i)->private.uid) { s += strlen (s); /* find string end, see if nearing end */ @@ -2056,7 +2056,7 @@ long imap_search (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,long flags) LOCAL->filter = T; /* retry, filtering SEARCH results */ for (i = 1; i <= stream->nmsgs; i++) mail_elt (stream,i)->private.filter = NIL; - for (set = ss; set; set = set->next) if (i = set->first) { + for (set = ss; set; set = set->next) if ((i = set->first) != 0L) { /* single message becomes one-message range */ if (!(j = set->last)) j = i; else if (j < i) { /* swap reversed range */ @@ -2658,7 +2658,7 @@ void imap_gc (MAILSTREAM *stream,long gcflags) (*mc) (stream,stream->nmsgs,CH_SIZE); if (gcflags & GC_TEXTS) { /* garbage collect texts? */ if (!stream->scache) for (i = 1; i <= stream->nmsgs; ++i) - if (elt = (MESSAGECACHE *) (*mc) (stream,i,CH_ELT)) + if ((elt = (MESSAGECACHE *) (*mc) (stream,i,CH_ELT)) != NULL) imap_gc_body (elt->private.msg.body); imap_gc_body (stream->body); } @@ -2713,7 +2713,7 @@ void imap_capability (MAILSTREAM *stream) imap_send (stream,"CAPABILITY",NIL); if (!LOCAL->gotcapability) { /* did server get any? */ /* no, flush threaders just in case */ - if (thr = LOCAL->cap.threader) while (t = thr) { + if ((thr = LOCAL->cap.threader) != NULL) while ((t = thr) != NULL) { fs_give ((void **) &t->name); thr = t->next; fs_give ((void **) &t); @@ -2935,7 +2935,7 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) if (LOCAL->referral) fs_give ((void **) &LOCAL->referral); sprintf (CMDBASE,"%s %s",tag,cmd); s = CMDBASE + strlen (CMDBASE); - if (arglst = args) while (arg = *arglst++) { + if ((arglst = args) != NULL) while ((arg = *arglst++) != NULL) { *s++ = ' '; /* delimit argument with space */ switch (arg->type) { case ATOM: /* atom */ @@ -2955,11 +2955,11 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) break; case ASTRING: /* atom or string, must be literal? */ st.size = strlen ((char *) (st.data = (unsigned char *) arg->text)); - if (reply = imap_send_astring (stream,tag,&s,&st,NIL,CMDBASE+MAXCOMMAND)) + if ((reply = imap_send_astring (stream,tag,&s,&st,NIL,CMDBASE+MAXCOMMAND)) != NULL) return reply; break; case LITERAL: /* literal, as a stringstruct */ - if (reply = imap_send_literal (stream,tag,&s,arg->text)) return reply; + if ((reply = imap_send_literal (stream,tag,&s,arg->text)) != NULL) return reply; break; case LIST: /* list of strings */ @@ -2967,16 +2967,16 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) c = '('; /* open paren */ do { /* for each list item */ *s++ = c; /* write prefix character */ - if (reply = imap_send_astring (stream,tag,&s,&list->text,NIL, - CMDBASE+MAXCOMMAND)) return reply; + if ((reply = imap_send_astring (stream,tag,&s,&list->text,NIL, + CMDBASE+MAXCOMMAND)) != NULL) return reply; c = ' '; /* prefix character for subsequent strings */ } - while (list = list->next); + while ((list = list->next) != NULL); *s++ = ')'; /* close list */ break; case SEARCHPROGRAM: /* search program */ - if (reply = imap_send_spgm (stream,tag,CMDBASE,&s,arg->text, - CMDBASE+MAXCOMMAND)) + if ((reply = imap_send_spgm (stream,tag,CMDBASE,&s,arg->text, + CMDBASE+MAXCOMMAND)) != NULL) return reply; break; case SORTPROGRAM: /* search program */ @@ -3061,7 +3061,7 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) break; case LISTMAILBOX: /* astring with wildcards */ st.size = strlen ((char *) (st.data = (unsigned char *) arg->text)); - if (reply = imap_send_astring (stream,tag,&s,&st,T,CMDBASE+MAXCOMMAND)) + if ((reply = imap_send_astring (stream,tag,&s,&st,T,CMDBASE+MAXCOMMAND)) != NULL) return reply; break; @@ -3083,7 +3083,7 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) MESSAGECACHE elt; STRING es; if (!map->date || mail_parse_date (&elt,map->date)) { - if (t = map->flags) { /* flags given? */ + if ((t = map->flags) != NULL) { /* flags given? */ if (*t != '(') { *s++ = '('; /* wrap parens around string */ while (*t) *s++ = *t++; @@ -3095,11 +3095,11 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) if (map->date) { /* date given? */ st.size = strlen ((char *) (st.data = (unsigned char *) mail_date (datetmp,&elt))); - if (reply = imap_send_astring (stream,tag,&s,&st,NIL, - CMDBASE+MAXCOMMAND)) return reply; + if ((reply = imap_send_astring (stream,tag,&s,&st,NIL, + CMDBASE+MAXCOMMAND)) != NULL) return reply; *s++ = ' '; /* delimit with space */ } - if (reply = imap_send_literal (stream,tag,&s,map->message)) + if ((reply = imap_send_literal (stream,tag,&s,map->message)) != NULL) return reply; /* get next message */ if ((*map->af) (stream,map->data,&map->flags,&map->date, @@ -3129,7 +3129,7 @@ IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,IMAPARG *args[]) c = ' '; /* prefix character for subsequent strings */ } } - while (list = list->next); + while ((list = list->next) != NULL); *s++ = ')'; /* close list */ break; default: @@ -3363,26 +3363,26 @@ IMAPPARSEDREPLY *imap_send_spgm (MAILSTREAM *stream,char *tag,char *base, pgm->references,limit)))) return reply; /* all other headers */ - if (hdr = pgm->header) do { + if ((hdr = pgm->header) != NULL) do { *s = imap_send_spgm_trim (base,*s," HEADER "); - if (reply = imap_send_astring (stream,tag,s,&hdr->line,NIL,limit)) + if ((reply = imap_send_astring (stream,tag,s,&hdr->line,NIL,limit)) != NULL) return reply; *(*s)++ = ' '; - if (reply = imap_send_astring (stream,tag,s,&hdr->text,NIL,limit)) + if ((reply = imap_send_astring (stream,tag,s,&hdr->text,NIL,limit)) != NULL) return reply; - } while (hdr = hdr->next); + } while ((hdr = hdr->next) != NULL); for (pgo = pgm->or; pgo; pgo = pgo->next) { *s = imap_send_spgm_trim (base,*s," OR ("); - if (reply = imap_send_spgm (stream,tag,base,s,pgo->first,limit)) + if ((reply = imap_send_spgm (stream,tag,base,s,pgo->first,limit)) != NULL) return reply; for (t = ") ("; *t; *(*s)++ = *t++); - if (reply = imap_send_spgm (stream,tag,base,s,pgo->second,limit)) + if ((reply = imap_send_spgm (stream,tag,base,s,pgo->second,limit)) != NULL) return reply; *(*s)++ = ')'; } for (pgl = pgm->not; pgl; pgl = pgl->next) { *s = imap_send_spgm_trim (base,*s," NOT ("); - if (reply = imap_send_spgm (stream,tag,base,s,pgl->pgm,limit)) + if ((reply = imap_send_spgm (stream,tag,base,s,pgl->pgm,limit)) != NULL) return reply; *(*s)++ = ')'; } @@ -3460,9 +3460,9 @@ IMAPPARSEDREPLY *imap_send_sset (MAILSTREAM *stream,char *tag,char *base, for (t =" ((OR BCC FOO NOT BCC "; *t; *(*s)++ = *t++); /* but broken by a literal */ INIT (&st,mail_string,(void *) "FOO",3); - if (reply = imap_send_literal (stream,tag,s,&st)) return reply; + if ((reply = imap_send_literal (stream,tag,s,&st)) != NULL) return reply; *(*s)++ = ')'; /* close glue */ - if (reply = imap_send_sset (stream,tag,NIL,s,set,prefix,limit)) + if ((reply = imap_send_sset (stream,tag,NIL,s,set,prefix,limit)) != NULL) return reply; *(*s)++ = ')'; /* close second OR argument */ } @@ -3563,7 +3563,7 @@ IMAPPARSEDREPLY *imap_reply (MAILSTREAM *stream,char *tag) { IMAPPARSEDREPLY *reply; while (LOCAL->netstream) { /* parse reply from server */ - if (reply = imap_parse_reply (stream,net_getline (LOCAL->netstream))) { + if ((reply = imap_parse_reply (stream,net_getline (LOCAL->netstream))) != NULL) { /* continuation ready? */ if (!strcmp (reply->tag,"+")) return reply; /* untagged data? */ @@ -3814,7 +3814,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) sprintf (LOCAL->tmp,"Unterminated header section: %.80s", (char *) t); /* point after the text */ - else if (t = strchr (s = t,' ')) *t++ = '\0'; + else if ((t = strchr (s = t,' ')) != NULL) *t++ = '\0'; } if (s && !LOCAL->tmp[0]) { *s++ = '\0'; /* tie off section specifier */ @@ -3918,11 +3918,11 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) } else if (!stream->user_flags[i]) stream->user_flags[i++] = cpystr (s); } - while (s = strtok_r (NIL," )",&r)); + while ((s = strtok_r (NIL," )",&r)) != NULL); else if (!strcmp (reply->key,"SEARCH")) { /* only do something if have text */ if (reply->text && (t = strtok_r (reply->text," ",&r))) do - if (i = strtoul (t,NIL,10)) { + if ((i = strtoul (t,NIL,10)) != 0L) { /* UIDs always passed to main program */ if (LOCAL->uidsearch) mm_searched (stream,i); /* should be a msgno then */ @@ -3931,7 +3931,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) mail_elt (stream,i)->searched = T; if (!stream->silent) mm_searched (stream,i); } - } while (t = strtok_r (NIL," ",&r)); + } while ((t = strtok_r (NIL," ",&r)) != NULL); } else if (!strcmp (reply->key,"SORT")) { sortresults_t sr = (sortresults_t) @@ -3955,7 +3955,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) threadresults_t tr = (threadresults_t) mail_parameters (NIL,GET_THREADRESULTS,NIL); if (LOCAL->threaddata) mail_free_threadnode (&LOCAL->threaddata); - if (s = reply->text) { + if ((s = reply->text) != NULL) { LOCAL->threaddata = imap_parse_thread (stream,&s); if (tr) (*tr) (stream,LOCAL->threaddata); if (s && *s) { @@ -4019,7 +4019,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) char delimiter = '\0'; *s++ = '\0'; /* tie off attribute list */ /* parse attribute list */ - if (t = strtok_r (reply->text+1," ",&r)) do { + if ((t = strtok_r (reply->text+1," ",&r)) != NULL) do { if (!compare_cstring (t,"\\NoInferiors")) i |= LATT_NOINFERIORS; else if (!compare_cstring (t,"\\NoSelect")) i |= LATT_NOSELECT; else if (!compare_cstring (t,"\\Marked")) i |= LATT_MARKED; @@ -4028,7 +4028,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) else if (!compare_cstring (t,"\\HasNoChildren")) i |= LATT_HASNOCHILDREN; /* ignore extension flags */ } - while (t = strtok_r (NIL," ",&r)); + while ((t = strtok_r (NIL," ",&r)) != NULL); switch (*++s) { /* process delimiter */ case 'N': /* NIL */ case 'n': @@ -4039,7 +4039,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) s += 3; /* skip over <delimiter><quote><space> */ } /* parse the mailbox name */ - if (t = imap_parse_astring (stream,&s,reply,&j)) { + if ((t = imap_parse_astring (stream,&s,reply,&j)) != NULL) { /* prepend prefix if requested */ if (LOCAL->prefix && ((strlen (LOCAL->prefix) + j) < IMAPTMPLEN)) sprintf (s = LOCAL->tmp,"%s%s",LOCAL->prefix,(char *) t); @@ -4057,7 +4057,7 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) mail_free_namespace (&LOCAL->namespace[2]); } else LOCAL->namespace = (NAMESPACE **) fs_get (3 * sizeof (NAMESPACE *)); - if (s = reply->text) { /* parse namespace results */ + if ((s = reply->text) != NULL) { /* parse namespace results */ LOCAL->namespace[0] = imap_parse_namespace (stream,&s,reply); LOCAL->namespace[1] = imap_parse_namespace (stream,&s,reply); LOCAL->namespace[2] = imap_parse_namespace (stream,&s,reply); @@ -4177,10 +4177,10 @@ void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply) if ((qc->name = imap_parse_astring (stream,&s,reply,NIL)) && s && (*s++ == ' ') && (isdigit (*s) || (LOCAL->loser && (*s == '-')))) { if (isdigit (*s)) qc->usage = strtoul (s,(char **) &s,10); - else if (t = strchr (s,' ')) t = s; + else if ((t = strchr (s,' ')) != NULL) t = s; if ((*s++ == ' ') && (isdigit (*s) || (LOCAL->loser &&(*s == '-')))){ if (isdigit (*s)) qc->limit = strtoul (s,(char **) &s,10); - else if (t = strpbrk (s," )")) t = s; + else if ((t = strpbrk (s," )")) != NULL) t = s; /* another resource follows? */ if (*s == ' ') continue; /* end of resource list? */ @@ -4277,7 +4277,7 @@ void imap_parse_response (MAILSTREAM *stream,char *text,long errflg,long ntfy) if (text && (*text == '[') && (t = strchr (s = text + 1,']')) && ((i = t - s) < IMAPTMPLEN)) { LOCAL->tmp[i] = '\0'; /* make mungable copy of text code */ - if (s = strchr (strncpy (t = LOCAL->tmp,s,i),' ')) *s++ = '\0'; + if ((s = strchr (strncpy (t = LOCAL->tmp,s,i),' ')) != NULL) *s++ = '\0'; if (s) { /* have argument? */ ntfy = NIL; /* suppress mm_notify if normal SELECT data */ if (!compare_cstring (t,"CAPABILITY")) imap_parse_capabilities(stream,s); @@ -4287,7 +4287,7 @@ void imap_parse_response (MAILSTREAM *stream,char *text,long errflg,long ntfy) stream->perm_seen = stream->perm_deleted = stream->perm_answered = stream->perm_draft = stream->kwd_create = NIL; stream->perm_user_flags = NIL; - if (s = strtok_r (s+1," ",&r)) do { + if ((s = strtok_r (s+1," ",&r)) != NULL) do { if (*s == '\\') { /* system flags */ if (!compare_cstring (s,"\\Seen")) stream->perm_seen = T; else if (!compare_cstring (s,"\\Deleted")) @@ -4301,7 +4301,7 @@ void imap_parse_response (MAILSTREAM *stream,char *text,long errflg,long ntfy) } else stream->perm_user_flags |= imap_parse_user_flag (stream,s); } - while (s = strtok_r (NIL," ",&r)); + while ((s = strtok_r (NIL," ",&r)) != NULL); } else if (!compare_cstring (t,"UIDVALIDITY") && (j = strtoul (s,NIL,10))){ @@ -4311,7 +4311,7 @@ void imap_parse_response (MAILSTREAM *stream,char *text,long errflg,long ntfy) stream->uid_validity = j; /* purge any UIDs in cache */ for (j = 1; j <= stream->nmsgs; j++) - if (elt = (MESSAGECACHE *) (*mc) (stream,j,CH_ELT)) + if ((elt = (MESSAGECACHE *) (*mc) (stream,j,CH_ELT)) != NULL) elt->private.uid = 0; } } @@ -4864,7 +4864,7 @@ unsigned char *imap_parse_astring (MAILSTREAM *stream,unsigned char **txtptr, c && (c > ' ') && (c != '(') && (c != ')') && (c != '{') && (c != '%') && (c != '*') && (c != '"') && (c != '\\') && (c < 0x80); c = *++*txtptr); - if (i = *txtptr - s) { /* atom ends at atom_special */ + if ((i = *txtptr - s) != 0L) { /* atom ends at atom_special */ if (len) *len = i; /* return length of atom */ ret = strncpy ((char *) fs_get (i + 1),s,i); ret[i] = '\0'; /* tie off string */ @@ -4984,7 +4984,7 @@ unsigned char *imap_parse_string (MAILSTREAM *stream,unsigned char **txtptr, string = (char *) fs_get ((size_t) i + 1); *string = '\0'; /* init in case getbuffer fails */ /* get the literal */ - if (rp) for (k = 0; j = min ((long) MAILTMPLEN,(long) i); i -= j) { + if (rp) for (k = 0; (j = min ((long) MAILTMPLEN,(long) i)) != 0L; i -= j) { net_getbuffer (LOCAL->netstream,j,string + k); (*rp) (md,k += j); } @@ -4992,7 +4992,7 @@ unsigned char *imap_parse_string (MAILSTREAM *stream,unsigned char **txtptr, } fs_give ((void **) &reply->line); if (flags && string) /* need to filter newlines? */ - for (st = string; st = strpbrk (st,"\015\012\011"); *st++ = ' '); + for (st = string; (st = strpbrk (st,"\015\012\011")) != NULL; *st++ = ' '); /* get new reply text line */ if (!(reply->line = net_getline (LOCAL->netstream))) reply->line = cpystr (""); @@ -5142,7 +5142,7 @@ void imap_parse_body_structure (MAILSTREAM *stream,BODY *body, /* parse it */ imap_parse_body_structure (stream,&part->body,txtptr,reply); } while (**txtptr == '(');/* for each body part */ - if (body->subtype = imap_parse_string(stream,txtptr,reply,NIL,NIL,LONGT)) + if ((body->subtype = imap_parse_string(stream,txtptr,reply,NIL,NIL,LONGT)) != NULL) ucase (body->subtype); else { mm_notify (stream,"Missing multipart subtype",WARN); @@ -5182,7 +5182,7 @@ void imap_parse_body_structure (MAILSTREAM *stream,BODY *body, body->type = TYPEOTHER; /* assume unknown type */ body->encoding = ENCOTHER;/* and unknown encoding */ /* parse type */ - if (s = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT)) { + if ((s = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT)) != NULL) { ucase (s); /* application always gets uppercase form */ for (i = 0; /* look in existing table */ (i <= TYPEMAX) && body_types[i] && strcmp (s,body_types[i]); i++); @@ -5195,7 +5195,7 @@ void imap_parse_body_structure (MAILSTREAM *stream,BODY *body, } if (s) fs_give ((void **) &s); } - if (body->subtype = imap_parse_string(stream,txtptr,reply,NIL,NIL,LONGT)) + if ((body->subtype = imap_parse_string(stream,txtptr,reply,NIL,NIL,LONGT)) != NULL) ucase (body->subtype); /* parse subtype */ else { mm_notify (stream,"Missing body subtype",WARN); @@ -5206,7 +5206,7 @@ void imap_parse_body_structure (MAILSTREAM *stream,BODY *body, body->id = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT); body->description = imap_parse_string (stream,txtptr,reply,NIL,NIL, LONGT); - if (s = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT)) { + if ((s = imap_parse_string (stream,txtptr,reply,NIL,NIL,LONGT)) != NULL) { ucase (s); /* application always gets uppercase form */ for (i = 0; /* search for body encoding */ (i <= ENCMAX) && body_encodings[i] && strcmp(s,body_encodings[i]); @@ -5410,7 +5410,7 @@ STRINGLIST *imap_parse_language (MAILSTREAM *stream,unsigned char **txtptr, STRINGLIST *ret = NIL; /* language is a list */ if (*++*txtptr == '(') ret = imap_parse_stringlist (stream,txtptr,reply); - else if (s = imap_parse_string (stream,txtptr,reply,NIL,&i,LONGT)) { + else if ((s = imap_parse_string (stream,txtptr,reply,NIL,&i,LONGT)) != NULL) { (ret = mail_newstringlist ())->text.data = (unsigned char *) s; ret->text.size = i; } @@ -5479,7 +5479,7 @@ void imap_parse_extension (MAILSTREAM *stream,unsigned char **txtptr, break; case '{': /* get size of literal */ ++*txtptr; /* bump past open squiggle */ - if (i = strtoul (*txtptr,(char **) txtptr,10)) do + if ((i = strtoul (*txtptr,(char **) txtptr,10)) != 0L) do net_getbuffer (LOCAL->netstream,j = min (i,(long) IMAPTMPLEN - 1), LOCAL->tmp); while (i -= j); @@ -5515,7 +5515,7 @@ void imap_parse_capabilities (MAILSTREAM *stream,char *t) THREADER *thr,*th; if (!LOCAL->gotcapability) { /* need to save previous capabilities? */ /* no, flush threaders */ - if (thr = LOCAL->cap.threader) while (th = thr) { + if ((thr = LOCAL->cap.threader) != NULL) while ((th = thr) != NULL) { fs_give ((void **) &th->name); thr = th->next; fs_give ((void **) &th); @@ -5558,7 +5558,7 @@ void imap_parse_capabilities (MAILSTREAM *stream,char *t) ((t[2] == 'R') || (t[2] == 'r')) && ((t[3] == 'T') || (t[3] == 't'))) LOCAL->cap.sort = T; /* capability with value? */ - else if (s = strchr (t,'=')) { + else if ((s = strchr (t,'=')) != NULL) { *s++ = '\0'; /* separate token from value */ if (!compare_cstring (t,"THREAD") && !LOCAL->loser) { THREADER *thread = (THREADER *) fs_get (sizeof (THREADER)); @@ -5647,7 +5647,7 @@ char *imap_reform_sequence (MAILSTREAM *stream,char *sequence,long flags) /* flush old reformed sequence */ if (LOCAL->reform) fs_give ((void **) &LOCAL->reform); rs = LOCAL->reform = (char *) fs_get (1+ strlen (sequence)); - for (s = sequence; t = strpbrk (s,",:"); ) switch (*t++) { + for (s = sequence; (t = strpbrk (s,",:")) != NULL; ) switch (*t++) { case ',': /* single message */ strncpy (rs,s,i = t - s); /* copy string up to that point */ rs += i; /* advance destination pointer */ diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c index da703a0d..1b6f93c3 100644 --- a/imap/src/c-client/mail.c +++ b/imap/src/c-client/mail.c @@ -210,7 +210,7 @@ void *mm_cache (MAILSTREAM *stream,unsigned long msgno,long op) break; case CH_EXPUNGE: /* expunge cache slot */ for (i = msgno - 1; msgno < stream->nmsgs; i++,msgno++) { - if (stream->cache[i] = stream->cache[msgno]) + if ((stream->cache[i] = stream->cache[msgno]) != NULL) stream->cache[i]->msgno = msgno; stream->sc[i] = stream->sc[msgno]; } @@ -388,32 +388,32 @@ void *mail_parameters (MAILSTREAM *stream,long function,void *value) case ENABLE_DRIVER: for (d = maildrivers; d && compare_cstring (d->name,(char *) value); d = d->next); - if (ret = (void *) d) d->flags &= ~DR_DISABLE; + if ((ret = (void *) d) != NULL) d->flags &= ~DR_DISABLE; break; case DISABLE_DRIVER: for (d = maildrivers; d && compare_cstring (d->name,(char *) value); d = d->next); - if (ret = (void *) d) d->flags |= DR_DISABLE; + if ((ret = (void *) d) != NULL) d->flags |= DR_DISABLE; break; case ENABLE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); - if (ret = (void *) a) a->flags &= ~AU_DISABLE; + if ((ret = (void *) a) != NULL) a->flags &= ~AU_DISABLE; break; case DISABLE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); - if (ret = (void *) a) a->flags |= AU_DISABLE; + if ((ret = (void *) a) != NULL) a->flags |= AU_DISABLE; break; case UNHIDE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); - if (ret = (void *) a) a->flags &= ~AU_HIDE; + if ((ret = (void *) a) != NULL) a->flags &= ~AU_HIDE; break; case HIDE_AUTHENTICATOR: for (a = mailauthenticators;/* scan authenticators */ a && compare_cstring (a->name,(char *) value); a = a->next); - if (ret = (void *) a) a->flags |= AU_HIDE; + if ((ret = (void *) a) != NULL) a->flags |= AU_HIDE; break; case SET_EXTERNALAUTHID: if (value) { /* setting external authentication ID */ @@ -647,16 +647,16 @@ void *mail_parameters (MAILSTREAM *stream,long function,void *value) if (stream) ret = (void *) stream->snarf.name; break; default: - if (r = smtp_parameters (function,value)) ret = r; - if (r = env_parameters (function,value)) ret = r; - if (r = tcp_parameters (function,value)) ret = r; - if (r = utf8_parameters (function,value)) ret = r; + if ((r = smtp_parameters (function,value)) != NULL) ret = r; + if ((r = env_parameters (function,value)) != NULL) ret = r; + if ((r = tcp_parameters (function,value)) != NULL) ret = r; + if ((r = utf8_parameters (function,value)) != NULL) ret = r; if (stream && stream->dtb) {/* if have stream, do for its driver only */ - if (r = (*stream->dtb->parameters) (function,value)) ret = r; + if ((r = (*stream->dtb->parameters) (function,value)) != NULL) ret = r; } /* else do all drivers */ else for (d = maildrivers; d; d = d->next) - if (r = (d->parameters) (function,value)) ret = r; + if ((r = (d->parameters) (function,value)) != NULL) ret = r; break; } return ret; @@ -770,7 +770,7 @@ long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service) break; case '/': /* switch */ /* find delimiter */ - if (t = strpbrk (s = t,"/:=")) { + if ((t = strpbrk (s = t,"/:=")) != NULL) { c = *t; /* remember delimiter for later */ *t++ = '\0'; /* tie off switch name */ } @@ -788,7 +788,7 @@ long mail_valid_net_parse_work (char *name,NETMBX *mb,char *service) arg[i] = '\0'; /* tie off argument */ } else { /* non-quoted argument */ - if (t = strpbrk (v = t,"/:")) { + if ((t = strpbrk (v = t,"/:")) != NULL) { c = *t; /* remember delimiter for later */ *t++ = '\0'; /* tie off switch name */ } @@ -937,7 +937,7 @@ void mail_list (MAILSTREAM *stream,char *ref,char *pat) else do if (!((d->flags & DR_DISABLE) || ((d->flags & DR_LOCAL) && remote))) (d->list) (NIL,ref,pat); - while (d = d->next); /* until at the end */ + while ((d = d->next) != NULL); /* until at the end */ } /* Mail list subscribed mailboxes @@ -970,7 +970,7 @@ void mail_lsub (MAILSTREAM *stream,char *ref,char *pat) else do if (!((d->flags & DR_DISABLE) || ((d->flags & DR_LOCAL) && remote))) (d->lsub) (NIL,ref,pat); - while (d = d->next); /* until at the end */ + while ((d = d->next) != NULL); /* until at the end */ } /* Mail subscribe to mailbox @@ -1014,7 +1014,7 @@ long mail_create (MAILSTREAM *stream,char *mailbox) size_t i; DRIVER *d; /* never allow names with newlines */ - if (s = strpbrk (mailbox,"\015\012")) { + if ((s = strpbrk (mailbox,"\015\012")) != NULL) { MM_LOG ("Can't create mailbox with such a name",ERROR); return NIL; } @@ -1030,7 +1030,7 @@ long mail_create (MAILSTREAM *stream,char *mailbox) return NIL; } /* validate name */ - if (s = mail_utf7_valid (mailbox)) { + if ((s = mail_utf7_valid (mailbox)) != NULL) { sprintf (tmp,"Can't create %s: %.80s",s,mailbox); MM_LOG (tmp,ERROR); return NIL; @@ -1110,7 +1110,7 @@ long mail_rename (MAILSTREAM *stream,char *old,char *newname) DRIVER *dtb = mail_valid (stream,old,"rename mailbox"); if (!dtb) return NIL; /* validate name */ - if (s = mail_utf7_valid (newname)) { + if ((s = mail_utf7_valid (newname)) != NULL) { sprintf (tmp,"Can't rename to %s: %.80s",s,newname); MM_LOG (tmp,ERROR); return NIL; @@ -1217,7 +1217,7 @@ MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options) ((name[3] == 'V') || (name[3] == 'v')) && ((name[4] == 'E') || (name[4] == 'e')) && (c = name[5]) && (s = strchr (name+6,c)) && (i = s - (name + 6)) && (i < MAILTMPLEN)) { - if (stream = mail_open (stream,s+1,options)) { + if ((stream = mail_open (stream,s+1,options)) != NULL) { strncpy (tmp,name+6,i); /* copy snarf mailbox name */ tmp[i] = '\0'; /* tie off name */ mail_parameters (stream,SET_SNARFMAILBOXNAME,(void *) tmp); @@ -1234,7 +1234,7 @@ MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options) ((name[3] == 'P') || (name[3] == 'p')) && mail_valid_net_parse_work (name+4,&mb,"pop3") && !strcmp (mb.service,"pop3") && !mb.anoflag && !mb.readonlyflag) { - if (stream = mail_open (stream,mb.mailbox,options)) { + if ((stream = mail_open (stream,mb.mailbox,options)) != NULL) { sprintf (tmp,"{%.255s",mb.host); if (mb.port) sprintf (tmp + strlen (tmp),":%lu",mb.port); if (mb.user[0]) sprintf (tmp + strlen (tmp),"/user=%.64s",mb.user); @@ -1265,7 +1265,7 @@ MAILSTREAM *mail_open (MAILSTREAM *stream,char *name,long options) ((name[6] == 'R') || (name[6] == 'r')) && (name[7] == '.')) { sprintf (tmp,"%.80s",name+8); /* tie off name at likely delimiter */ - if (s = strpbrk (tmp,"/\\:")) *s++ = '\0'; + if ((s = strpbrk (tmp,"/\\:")) != NULL) *s++ = '\0'; else { sprintf (tmp,"Can't resolve mailbox %.80s: bad driver syntax",name); MM_LOG (tmp,ERROR); @@ -1565,7 +1565,7 @@ ENVELOPE *mail_fetch_structure (MAILSTREAM *stream,unsigned long msgno, if (stream->dtb && stream->dtb->structure) return (*stream->dtb->structure) (stream,msgno,body,flags); if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return NIL; /* must get UID/msgno map first */ } elt = mail_elt (stream,msgno);/* get elt for real message number */ @@ -1747,7 +1747,7 @@ char *mail_fetch_header (MAILSTREAM *stream,unsigned long msgno,char *section, if (len) *len = 0; /* default return size */ if (section && (strlen (section) > (MAILTMPLEN - 20))) return ""; if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } elt = mail_elt (stream,msgno);/* get cache data */ @@ -1800,8 +1800,8 @@ char *mail_fetch_header (MAILSTREAM *stream,unsigned long msgno,char *section, else { /* top-level header fetch */ /* mark message seen */ markseen (stream,elt,flags); - if (rt.data = (unsigned char *) - (*stream->dtb->header) (stream,msgno,&rt.size,flags)) { + if ((rt.data = (unsigned char *) + (*stream->dtb->header) (stream,msgno,&rt.size,flags)) != NULL) { /* make a safe copy if need to filter */ if (lines) textcpy (t = &stream->text,&rt); else t = &rt; /* top level header */ @@ -1838,7 +1838,7 @@ char *mail_fetch_text (MAILSTREAM *stream,unsigned long msgno,char *section, memset (&stream->private.string,NIL,sizeof (STRING)); if (section && (strlen (section) > (MAILTMPLEN - 20))) return ""; if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } elt = mail_elt (stream,msgno);/* get cache data */ @@ -1893,7 +1893,7 @@ char *mail_fetch_mime (MAILSTREAM *stream,unsigned long msgno,char *section, if (len) *len = 0; /* default return size */ if (section && (strlen (section) > (MAILTMPLEN - 20))) return ""; if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } flags &= ~FT_INTERNAL; /* can't win with this set */ @@ -1976,7 +1976,7 @@ char *mail_fetch_body (MAILSTREAM *stream,unsigned long msgno,char *section, } if (len) *len = 0; /* default return size */ if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } /* must have body */ @@ -2034,7 +2034,7 @@ long mail_partial_text (MAILSTREAM *stream,unsigned long msgno,char *section, if (!mailgets) fatal ("mail_partial_text() called without a mailgets!"); if (section && (strlen (section) > (MAILTMPLEN - 20))) return NIL; if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return NIL; /* must get UID/msgno map first */ } elt = mail_elt (stream,msgno);/* get cache data */ @@ -2104,7 +2104,7 @@ long mail_partial_body (MAILSTREAM *stream,unsigned long msgno,char *section, return mail_partial_text (stream,msgno,NIL,first,last,flags); if (!mailgets) fatal ("mail_partial_body() called without a mailgets!"); if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return NIL; /* must get UID/msgno map first */ } /* must have body */ @@ -2254,7 +2254,7 @@ unsigned long mail_msgno (MAILSTREAM *stream,unsigned long uid) if (uid == firstuid) return first; if (uid == lastuid) return last; /* have anything between endpoints? */ - if (delta = ((last - first) / 2)) { + if ((delta = ((last - first) / 2)) != 0L){ if ((miduid = mail_elt (stream,middle = first + delta)->private.uid) == uid) return middle; /* found match in middle */ @@ -2408,7 +2408,7 @@ long mail_search_default (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm, unsigned long i; char *msg; /* make sure that charset is good */ - if (msg = utf8_badcharset (charset)) { + if ((msg = utf8_badcharset (charset)) != NULL) { MM_LOG (msg,ERROR); /* output error */ fs_give ((void **) &msg); return NIL; @@ -2634,7 +2634,7 @@ long mail_append_multiple (MAILSTREAM *stream,char *mailbox,append_t af, } else ret = SAFE_APPEND (d,stream,mailbox + (s - tmp),af,data); } - else if (d = mail_valid (stream,mailbox,NIL)) + else if ((d = mail_valid (stream,mailbox,NIL)) != NULL) ret = SAFE_APPEND (d,stream,mailbox,af,data); /* No driver, try for TRYCREATE if no stream. Note that we use the * createProto here, not the appendProto, since the dummy driver already @@ -2672,7 +2672,7 @@ void mail_gc (MAILSTREAM *stream,long gcflags) } /* garbage collect per-message stuff */ for (i = 1; i <= stream->nmsgs; i++) - if (elt = (MESSAGECACHE *) (*mailcache) (stream,i,CH_ELT)) + if ((elt = (MESSAGECACHE *) (*mailcache) (stream,i,CH_ELT)) != NULL) mail_gc_msg (&elt->private.msg,gcflags); } @@ -2744,7 +2744,7 @@ BODY *mail_body_section (BODY *b, unsigned char *section) /* multipart content? */ if (b->type == TYPEMULTIPART) { /* yes, find desired part */ - if (pt = b->nested.part) while (--i && (pt = pt->next)); + if ((pt = b->nested.part) != NULL) while (--i && (pt = pt->next)); if (!pt) return NIL; /* bad specifier */ b = &pt->body; /* note new body */ } @@ -3122,7 +3122,7 @@ long mail_parse_date (MESSAGECACHE *elt,unsigned char *s) t = localtime (&tn); /* get local minutes since midnight */ mi = t->tm_hour * 60 + t->tm_min; ms = t->tm_yday; /* note Julian day */ - if (t = gmtime (&tn)) { /* minus UTC minutes since midnight */ + if ((t = gmtime (&tn)) != NULL) { /* minus UTC minutes since midnight */ mi -= t->tm_hour * 60 + t->tm_min; /* ms can be one of: * 36x local time is December 31, UTC is January 1, offset -24 hours @@ -3343,7 +3343,7 @@ long mail_uid_sequence (MAILSTREAM *stream,unsigned char *sequence) case ',': /* single message */ ++sequence; /* skip the delimiter, fall into end case */ case '\0': /* end of sequence, mark this message */ - if (x = mail_msgno (stream,i)) mail_elt (stream,x)->sequence = T; + if ((x = mail_msgno (stream,i)) != 0L) mail_elt (stream,x)->sequence = T; break; default: /* anything else is a syntax error! */ MM_LOG ("UID sequence syntax error",ERROR); @@ -3376,7 +3376,7 @@ long mail_match_lines (STRINGLIST *lines,STRINGLIST *msglines,long flags) } if (!m) return NIL; /* didn't find in the list */ } - while (lines = lines->next); + while ((lines = lines->next) != NULL); return T; /* all lines found */ } @@ -3408,7 +3408,7 @@ unsigned long mail_filter (char *text,unsigned long len,STRINGLIST *lines, *t++ = *s++); *t = '\0'; /* tie off */ notfound = T; /* not found yet */ - if (i = t - tmp) /* see if found in header */ + if ((i = t - tmp) != 0L) /* see if found in header */ for (hdrs = lines; hdrs && notfound; hdrs = hdrs->next) if ((hdrs->text.size == i) && !compare_csizedtext (tmp,&hdrs->text)) notfound = NIL; @@ -3660,7 +3660,7 @@ long mail_search_header_text (char *s,STRINGLIST *st) { SIZEDTEXT h; /* have any text? */ - if (h.data = (unsigned char *) s) { + if ((h.data = (unsigned char *) s) != NULL) { h.size = strlen (s); /* yes, get its size */ return mail_search_header (&h,st); } @@ -3711,7 +3711,7 @@ long mail_search_text (MAILSTREAM *stream,unsigned long msgno,char *section, for (stream->private.search.string = s; st;) { s->text.data = st->text.data; s->text.size = st->text.size; - if (st = st->next) s = s->next = mail_newstringlist (); + if ((st = st->next) != NULL) s = s->next = mail_newstringlist (); } stream->private.search.text = NIL; if (flags) { /* want header? */ @@ -3793,7 +3793,7 @@ long mail_search_body (MAILSTREAM *stream,unsigned long msgno,BODY *body, if (h.data != st.data) fs_give ((void **) &h.data); } } - if (body = body->nested.msg->body) + if ((body = body->nested.msg->body) != NULL) ret = (body->type == TYPEMULTIPART) ? mail_search_body (stream,msgno,body,(prefix ? prefix : ""), section - 1,flags) : @@ -3810,14 +3810,14 @@ long mail_search_body (MAILSTREAM *stream,unsigned long msgno,BODY *body, if (!strcmp (param->attribute,"CHARSET")) t = param->value; switch (body->encoding) { /* what encoding? */ case ENCBASE64: - if (st.data = (unsigned char *) - rfc822_base64 ((unsigned char *) s,i,&st.size)) { + if ((st.data = (unsigned char *) + rfc822_base64 ((unsigned char *) s,i,&st.size)) != NULL) { ret = mail_search_string (&st,t,&stream->private.search.string); fs_give ((void **) &st.data); } break; case ENCQUOTEDPRINTABLE: - if (st.data = rfc822_qprint ((unsigned char *) s,i,&st.size)) { + if ((st.data = rfc822_qprint ((unsigned char *) s,i,&st.size)) != NULL) { ret = mail_search_string (&st,t,&stream->private.search.string); fs_give ((void **) &st.data); } @@ -3898,7 +3898,7 @@ long mail_search_keyword (MAILSTREAM *stream,MESSAGECACHE *elt,STRINGLIST *st, break; } if (flag && !j) return NIL; - } while (st = st->next); + } while ((st = st->next) != NULL); tf = elt->user_flags & f; /* get set flags which match */ return flag ? (f == tf) : !tf; } @@ -3927,9 +3927,9 @@ long mail_search_addr (ADDRESS *adr,STRINGLIST *st) /* write address list */ for (txt.size = 0,a = adr; a; a = a->next) { k = (tadr.mailbox = a->mailbox) ? 4 + 2*strlen (a->mailbox) : 3; - if (tadr.personal = a->personal) k += 3 + 2*strlen (a->personal); - if (tadr.adl = a->adl) k += 3 + 2*strlen (a->adl); - if (tadr.host = a->host) k += 3 + 2*strlen (a->host); + if ((tadr.personal = a->personal) != NULL) k += 3 + 2*strlen (a->personal); + if ((tadr.adl = a->adl) != NULL) k += 3 + 2*strlen (a->adl); + if ((tadr.host = a->host) != NULL) k += 3 + 2*strlen (a->host); if (tadr.personal || tadr.adl) k += 2; if (k < (SENDBUFLEN-10)) {/* ignore ridiculous addresses */ tmp[0] = '\0'; @@ -4164,7 +4164,7 @@ int mail_criteria_string (STRINGLIST **s,char **r) if (strchr (c+1,'"')) end = "\""; else return NIL; /* falls through */ default: /* atomic string */ - if (d = strtok_r (c,end,r)) n = strlen (d); + if ((d = strtok_r (c,end,r)) != NULL) n = strlen (d); else return NIL; break; } @@ -4375,7 +4375,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&maildateline,NIL, FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4411,7 +4411,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&mailfromline,NIL, FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) { - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4419,7 +4419,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) break; case 'f': /* continuation but with extra "From:" */ case 'F': - if (v = strchr (v,':')) { + if ((v = strchr (v,':')) != NULL) { memmove (x,v+1,strlen (v+1)); break; } @@ -4445,7 +4445,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&mailtonline,NIL, FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) { - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4453,7 +4453,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) break; case 't': /* continuation but with extra "To:" */ case 'T': - if (v = strchr (v,':')) { + if ((v = strchr (v,':')) != NULL) { memmove (x,v+1,strlen (v+1)); break; } @@ -4479,7 +4479,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&mailccline,NIL, FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) { - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4487,7 +4487,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) break; case 'c': /* continuation but with extra "cc:" */ case 'C': - if (v = strchr (v,':')) { + if ((v = strchr (v,':')) != NULL) { memmove (x,v+1,strlen (v+1)); break; } @@ -4514,7 +4514,7 @@ SORTCACHE **mail_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm) else if ((t = mail_fetch_header (stream,i,NIL,&mailsubline, NIL,FT_INTERNAL | FT_PEEK)) && (t = strchr (t,':'))) - for (x = ++t; x = strpbrk (x,"\012\015"); x++) + for (x = ++t; (x = strpbrk (x,"\012\015")) != NULL; x++) switch (*(v = ((*x == '\015') && (x[1] == '\012')) ? x+2 : x+1)){ case ' ': /* erase continuation newlines */ case '\t': @@ -4548,7 +4548,7 @@ unsigned int mail_strip_subject (char *t,char **ret) unsigned long i,slen; char c,*s,*x; unsigned int refwd = NIL; - if (src.size = strlen (t)) { /* have non-empty subject? */ + if ((src.size = strlen (t)) != 0) { /* have non-empty subject? */ src.data = (unsigned char *) t; /* Step 1 */ /* make copy, convert MIME2 if needed */ @@ -4704,7 +4704,7 @@ int mail_sort_compare (const void *a1,const void *a2) } if (pgm->reverse) i = -i; /* flip results if necessary */ } - while (pgm = i ? NIL : pgm->next); + while ((pgm = i ? NIL : pgm->next) != NULL); /* return result, avoid 0 if at all possible */ return i ? i : compare_ulong (s1->num,s2->num); } @@ -4831,7 +4831,7 @@ THREADNODE *mail_thread_orderedsubject (MAILSTREAM *stream,char *charset, pgm.function = SORTSUBJECT; pgm.next = &pgm2; pgm2.function = SORTDATE; - if (lst = (*sorter) (stream,charset,spg,&pgm,flags & ~(SE_FREE | SE_UID))){ + if ((lst = (*sorter) (stream,charset,spg,&pgm,flags & ~(SE_FREE | SE_UID))) != NULL){ if (*(ls = lst)) { /* create thread */ /* note first subject */ cur = top = thr = mail_newthreadnode @@ -4945,7 +4945,7 @@ THREADNODE *mail_thread_references (MAILSTREAM *stream,char *charset, /* still missing data? */ if (!s->date || !s->subject || !s->message_id || !s->references) { /* try to load data from envelope */ - if (env = mail_fetch_structure (stream,s->num,NIL,NIL)) { + if ((env = mail_fetch_structure (stream,s->num,NIL,NIL)) != NULL) { if (!s->date && env->date && mail_parse_date (&telt,env->date)) s->date = mail_longdate (&telt); if (!s->subject && env->subject) @@ -4993,7 +4993,7 @@ THREADNODE *mail_thread_references (MAILSTREAM *stream,char *charset, /* Step 1A */ if ((st = (s = sc[i])->references) && st->text.data) for (con = hash_lookup_and_add (ht,(char *) st->text.data,NIL, - THREADLINKS); st = st->next; con = nxc) { + THREADLINKS); (st = st->next) != NULL; con = nxc) { nxc = hash_lookup_and_add (ht,(char *) st->text.data,NIL,THREADLINKS); /* only if no parent & won't introduce loop */ if (!PARENT (nxc) && !mail_thread_check_child (con,nxc)) { @@ -5231,11 +5231,11 @@ STRINGLIST *mail_thread_parse_references (char *s,long flag) STRINGLIST *ret = NIL; STRINGLIST *cur; /* found first reference? */ - if (t = mail_thread_parse_msgid (s,&s)) { + if ((t = mail_thread_parse_msgid (s,&s)) != NULL) { (ret = mail_newstringlist ())->text.data = (unsigned char *) t; ret->text.size = strlen (t); if (flag) /* parse subsequent references */ - for (cur = ret; t = mail_thread_parse_msgid (s,&s); cur = cur->next) { + for (cur = ret; (t = mail_thread_parse_msgid (s,&s)) != NULL; cur = cur->next) { (cur->next = mail_newstringlist ())->text.data = (unsigned char *) t; cur->next->text.size = strlen (t); } @@ -5337,7 +5337,7 @@ THREADNODE *mail_thread_c2node (MAILSTREAM *stream,container_t con,long flags) /* attach sequence or UID for non-dummy */ if (s) cur->num = (flags & SE_UID) ? mail_uid (stream,s->num) : s->num; /* attach the children */ - if (nxt = CHILD (con)) cur->next = mail_thread_c2node (stream,nxt,flags); + if ((nxt = CHILD (con)) != NULL) cur->next = mail_thread_c2node (stream,nxt,flags); } return ret; } @@ -5488,7 +5488,7 @@ long mail_parse_flags (MAILSTREAM *stream,char *flag,unsigned long *uf) tmp[j] = '\0'; while ((t = n) && *t) { /* parse the flags */ /* find end of flag */ - if (n = strchr (t,' ')) *n++ = '\0'; + if ((n = strchr (t,' ')) != NULL) *n++ = '\0'; if (*t == '\\') { /* system flag? */ if (!compare_cstring (t+1,"SEEN")) f |= fSEEN; else if (!compare_cstring (t+1,"DELETED")) f |= fDELETED; @@ -6256,7 +6256,7 @@ NETSTREAM *net_open_work (NETDRIVER *dv,char *host,char *service, service = NIL; /* yes, override service name */ port = portoverride; /* use that instead of default port */ } - if (tstream = (*dv->open) (host,service,port | flags)) { + if ((tstream = (*dv->open) (host,service,port | flags)) != NULL){ stream = (NETSTREAM *) fs_get (sizeof (NETSTREAM)); stream->stream = tstream; stream->dtb = dv; @@ -6278,7 +6278,7 @@ NETSTREAM *net_aopen (NETDRIVER *dv,NETMBX *mb,char *service,char *user) NETSTREAM *stream = NIL; void *tstream; if (!dv) dv = &tcpdriver; /* default to TCP driver */ - if (tstream = (*dv->aopen) (mb,service,user)) { + if ((tstream = (*dv->aopen) (mb,service,user)) != NULL) { stream = (NETSTREAM *) fs_get (sizeof (NETSTREAM)); stream->stream = tstream; stream->dtb = dv; diff --git a/imap/src/c-client/misc.c b/imap/src/c-client/misc.c index bcbc49e2..0f26a9c3 100644 --- a/imap/src/c-client/misc.c +++ b/imap/src/c-client/misc.c @@ -269,7 +269,7 @@ long ssearch (unsigned char *base,long basec,unsigned char *pat,long patc) for (i = 0; i < patc; i++) mask[pat[i]] = T; /* Boyer-Moore type search */ for (i = --patc, c = pat[i]; i < basec; i += (mask[c] ? 1 : (j + 1))) - for (j = patc,c = base[k = i]; (c == pat[j]); j--,c = base[--k]) + for (j = patc,c = base[k = i]; c == pat[j]; j--,c = base[--k]) if (!j) return T; /* found a match! */ } return NIL; /* pattern not found */ @@ -311,7 +311,7 @@ void hash_reset (HASHTAB *hashtab) size_t i; HASHENT *ent,*nxt; /* free each hash entry */ - for (i = 0; i < hashtab->size; i++) if (ent = hashtab->table[i]) + for (i = 0; i < hashtab->size; i++) if ((ent = hashtab->table[i]) != NULL) for (hashtab->table[i] = NIL; ent; ent = nxt) { nxt = ent->next; /* get successor */ fs_give ((void **) &ent); /* flush this entry */ @@ -328,7 +328,7 @@ unsigned long hash_index (HASHTAB *hashtab,char *key) { unsigned long i,ret; /* polynomial of letters of the word */ - for (ret = 0; i = (unsigned int) *key++; ret += i) ret *= HASHMULT; + for (ret = 0; (i = (unsigned int) *key++) != 0L; ret += i) ret *= HASHMULT; return ret % (unsigned long) hashtab->size; } @@ -447,7 +447,7 @@ int compare_string (unsigned char *s1,unsigned char *s2) int i; if (!s1) return s2 ? -1 : 0; /* empty string cases */ else if (!s2) return 1; - for (; *s1 && *s2; s1++,s2++) if (i = (compare_ulong (*s1,*s2))) return i; + for (; *s1 && *s2; s1++,s2++) if ((i = (compare_ulong (*s1,*s2))) != 0) return i; if (*s1) return 1; /* first string is longer */ return *s2 ? -1 : 0; /* second string longer : strings identical */ } @@ -466,7 +466,7 @@ int compare_cstring (unsigned char *s1,unsigned char *s2) int i; if (!s1) return s2 ? -1 : 0; /* empty string cases */ else if (!s2) return 1; - for (; *s1 && *s2; s1++,s2++) if (i = (compare_uchar (*s1,*s2))) return i; + for (; *s1 && *s2; s1++,s2++) if ((i = (compare_uchar (*s1,*s2))) != 0) return i; if (*s1) return 1; /* first string is longer */ return *s2 ? -1 : 0; /* second string longer : strings identical */ } @@ -486,7 +486,7 @@ int compare_csizedtext (unsigned char *s1,SIZEDTEXT *s2) if (!s1) return s2 ? -1 : 0; /* null string cases */ else if (!s2) return 1; for (s = (char *) s2->data,j = s2->size; *s1 && j; ++s1,++s,--j) - if (i = (compare_uchar (*s1,*s))) return i; + if ((i = (compare_uchar (*s1,*s))) != 0) return i; if (*s1) return 1; /* first string is longer */ return j ? -1 : 0; /* second string longer : strings identical */ } diff --git a/imap/src/c-client/netmsg.c b/imap/src/c-client/netmsg.c index 187e4ebb..4454c3be 100644 --- a/imap/src/c-client/netmsg.c +++ b/imap/src/c-client/netmsg.c @@ -61,7 +61,7 @@ FILE *netmsg_slurp (NETSTREAM *stream,unsigned long *size,unsigned long *hsiz) FILE *f = tmpfile (); if (!f) { sprintf (tmp,".%lx.%lx",(unsigned long) time (0),(unsigned long)getpid ()); - if (f = fopen (tmp,"wb+")) unlink (tmp); + if ((f = fopen (tmp,"wb+")) != NULL) unlink (tmp); else { sprintf (tmp,"Unable to create scratch file: %.80s",strerror (errno)); MM_LOG (tmp,ERROR); @@ -70,7 +70,7 @@ FILE *netmsg_slurp (NETSTREAM *stream,unsigned long *size,unsigned long *hsiz) } *size = 0; /* initially emtpy */ if (hsiz) *hsiz = 0; - while (s = net_getline (stream)) { + while ((s = net_getline (stream)) != NULL) { if (*s == '.') { /* possible end of text? */ if (s[1]) t = s + 1; /* pointer to true start of line */ else { diff --git a/imap/src/c-client/newsrc.c b/imap/src/c-client/newsrc.c index 41f1fd24..ce694c61 100644 --- a/imap/src/c-client/newsrc.c +++ b/imap/src/c-client/newsrc.c @@ -123,9 +123,10 @@ long newsrc_newmessages (FILE *f,MAILSTREAM *stream,char *nl) } else if (j) { /* unread message, ending a range */ /* calculate end of range */ - if (k = elt->private.uid - 1) { + if ((k = elt->private.uid - 1) != 0L) { /* dump range */ - sprintf (tmp,(j == k) ? "%c%ld" : "%c%ld-%ld",c,j,k); + if(j == k) sprintf (tmp, "%c%ld",c,j); + else sprintf (tmp, "%c%ld-%ld",c,j,k); if (fputs (tmp,f) == EOF) return NIL; c = ','; /* need a comma after the first time */ } @@ -133,7 +134,8 @@ long newsrc_newmessages (FILE *f,MAILSTREAM *stream,char *nl) } } if (j) { /* dump trailing range */ - sprintf (tmp,(j == k) ? "%c%ld" : "%c%ld-%ld",c,j,k); + if(j == k) sprintf (tmp, "%c%ld",c,j); + else sprintf (tmp,"%c%ld-%ld",c,j,k); if (fputs (tmp,f) == EOF) return NIL; } } @@ -340,7 +342,7 @@ long newsrc_write (char *group,MAILSTREAM *stream) char *s,tmp[MAILTMPLEN],backup[MAILTMPLEN],nl[3]; FILE *f,*bf; nl[0] = nl[1] = nl[2] = '\0'; /* no newline known yet */ - if (f = fopen (newsrc,"rb")) {/* have existing newsrc file? */ + if ((f = fopen (newsrc,"rb")) != NULL) {/* have existing newsrc file? */ if (!(bf = fopen ((strcat (strcpy (backup,newsrc),OLDFILESUFFIX)),"wb"))) { fclose (f); /* punt input file */ return newsrc_error("Can't create backup news state %.80s",backup,ERROR); @@ -365,7 +367,7 @@ long newsrc_write (char *group,MAILSTREAM *stream) return newsrc_error ("Error closing backup news state %.80s", newsrc,ERROR); if (d == EOF) { /* open for write if empty file */ - if (f = newsrc_create (stream,NIL)) bf = NIL; + if ((f = newsrc_create (stream,NIL)) != NULL) bf = NIL; else return NIL; } else if (!nl[0]) /* make sure newlines valid */ @@ -381,7 +383,7 @@ long newsrc_write (char *group,MAILSTREAM *stream) } } else { /* create new newsrc file */ - if (f = newsrc_create (stream,T)) bf = NIL; + if ((f = newsrc_create (stream,T)) != NULL) bf = NIL; else return NIL; /* can't create newsrc */ } diff --git a/imap/src/c-client/nntp.c b/imap/src/c-client/nntp.c index dd2b8604..8fa32df1 100644 --- a/imap/src/c-client/nntp.c +++ b/imap/src/c-client/nntp.c @@ -352,12 +352,12 @@ void nntp_list (MAILSTREAM *stream,char *ref,char *pat) /* namespace format name? */ if (*(lcl = strchr (strcpy (name,pattern),'}') + 1) == '#') lcl += 6; /* process data until we see final dot */ - while (s = net_getline (LOCAL->nntpstream->netstream)) { + while ((s = net_getline (LOCAL->nntpstream->netstream)) != NULL) { if ((*s == '.') && !s[1]){/* end of text */ fs_give ((void **) &s); break; } - if (t = strchr (s,' ')) { /* tie off after newsgroup name */ + if ((t = strchr (s,' ')) != NULL) { /* tie off after newsgroup name */ *t = '\0'; strcpy (lcl,s); /* make full form of name */ /* report if match */ @@ -396,10 +396,10 @@ void nntp_lsub (MAILSTREAM *stream,char *ref,char *pat) if (ref && *ref) sprintf (mbx,"%s%s",ref,pat); else strcpy (mbx,pat); - if (s = sm_read (tmp,&sdb)) do if (nntp_valid (s) && pmatch (s,mbx)) + if ((s = sm_read (tmp,&sdb)) != NULL) do if (nntp_valid (s) && pmatch (s,mbx)) mm_lsub (stream,NIL,s,NIL); /* until no more subscriptions */ - while (s = sm_read (tmp,&sdb)); + while ((s = sm_read (tmp,&sdb)) != NULL); } /* NNTP canonicalize newsgroup name @@ -430,7 +430,7 @@ long nntp_canonicalize (char *ref,char *pat,char *pattern,char *wildmat) /* don't return wildmat if specials present */ if (strpbrk (wildmat,",?![\\]")) wildmat[0] = '\0'; /* replace all % with * */ - for (s = wildmat; s = strchr (s,'%'); *s = '*'); + for (s = wildmat; (s = strchr (s,'%')) != NULL; *s = '*'); } return ret ? LONGT : NIL; } @@ -556,7 +556,7 @@ long nntp_status (MAILSTREAM *stream,char *mbx,long flags) else if (!(flags & (SA_RECENT | SA_UNSEEN))) status.messages = k; /* have newsrc state? */ - else if (state = newsrc_state (stream,name)) { + else if ((state = newsrc_state (stream,name)) != NULL) { /* yes, get the UID/sequence map */ if (nntp_getmap (stream,name,i,status.uidnext - 1,rnmsgs, status.messages,tmp)) { @@ -938,15 +938,15 @@ long nntp_overview (MAILSTREAM *stream,overview_t ofn) (j <= stream->nmsgs) && (elt = mail_elt (stream,j))->sequence && !elt->private.spare.ptr; j++); /* make NNTP range */ - sprintf (tmp,(i == (j - 1)) ? "%lu" : "%lu-%lu",mail_uid (stream,i), - mail_uid (stream,j - 1)); + if(i == (j - 1)) sprintf (tmp, "%lu", mail_uid (stream,i)); + else sprintf (tmp, "%lu-%lu",mail_uid (stream,i), mail_uid (stream,j - 1)); i = j; /* advance beyond gap */ /* ask server for overview data to cache */ if (nntp_over (stream,tmp)) { while ((s = net_getline (LOCAL->nntpstream->netstream)) && strcmp (s,".")) { /* death to embedded newlines */ - for (t = v = s; c = *v++;) + for (t = v = s; (c = *v++) != '\0';) if ((c != '\012') && (c != '\015')) *t++ = c; *t++ = '\0'; /* tie off string in case it was shortened */ /* cache the overview if found its sequence */ @@ -1056,34 +1056,34 @@ long nntp_parse_overview (OVERVIEW *ov,char *text,MESSAGECACHE *elt) if (!(text && *text)) return NIL; ov->subject = cpystr (text); /* make hackable copy of overview */ /* find end of Subject */ - if (t = strchr (ov->subject,'\t')) { + if ((t = strchr (ov->subject,'\t')) != NULL) { *t++ = '\0'; /* tie off Subject, point to From */ /* find end of From */ - if (ov->date = strchr (t,'\t')) { + if ((ov->date = strchr (t,'\t')) != NULL) { *ov->date++ = '\0'; /* tie off From, point to Date */ /* load internaldate too */ if (!elt->day) mail_parse_date (elt,ov->date); /* parse From */ rfc822_parse_adrlist (&ov->from,t,BADHOST); /* find end of Date */ - if (ov->message_id = strchr (ov->date,'\t')) { + if ((ov->message_id = strchr (ov->date,'\t')) != NULL) { /* tie off Date, point to Message-ID */ *ov->message_id++ = '\0'; /* find end of Message-ID */ - if (ov->references = strchr (ov->message_id,'\t')) { + if ((ov->references = strchr (ov->message_id,'\t')) != NULL) { /* tie off Message-ID, point to References */ *ov->references++ = '\0'; /* fine end of References */ - if (t = strchr (ov->references,'\t')) { + if ((t = strchr (ov->references,'\t')) != NULL) { *t++ = '\0'; /* tie off References, point to octet size */ /* parse size of message in octets */ ov->optional.octets = atol (t); /* find end of size */ - if (t = strchr (t,'\t')) { + if ((t = strchr (t,'\t')) != NULL) { /* parse size of message in lines */ ov->optional.lines = atol (++t); /* find Xref */ - if (ov->optional.xref = strchr (t,'\t')) + if ((ov->optional.xref = strchr (t,'\t')) != NULL) *ov->optional.xref++ = '\0'; } } @@ -1116,7 +1116,7 @@ char *nntp_header (MAILSTREAM *stream,unsigned long msgno,unsigned long *size, /* get header text */ switch (nntp_send (LOCAL->nntpstream,"HEAD",tmp)) { case NNTPHEAD: - if (f = netmsg_slurp (LOCAL->nntpstream->netstream,size,NIL)) { + if ((f = netmsg_slurp (LOCAL->nntpstream->netstream,size,NIL)) != NULL) { fread (elt->private.msg.header.text.data = (unsigned char *) fs_get ((size_t) *size + 3), (size_t) 1,(size_t) *size,f); @@ -1168,8 +1168,8 @@ long nntp_text (MAILSTREAM *stream,unsigned long msgno,STRING *bs,long flags) sprintf (tmp,"%lu",elt->private.uid); switch (nntp_send (LOCAL->nntpstream,"BODY",tmp)) { case NNTPBODY: - if (LOCAL->txt = netmsg_slurp (LOCAL->nntpstream->netstream, - &LOCAL->txtsize,NIL)) break; + if ((LOCAL->txt = netmsg_slurp (LOCAL->nntpstream->netstream, + &LOCAL->txtsize,NIL)) != NULL) break; /* fall into default case */ default: /* failed, mark as deleted */ elt->deleted = T; @@ -1233,7 +1233,7 @@ long nntp_search (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,long flags) OVERVIEW ov; char *msg; /* make sure that charset is good */ - if (msg = utf8_badcharset (charset)) { + if ((msg = utf8_badcharset (charset)) != NULL) { MM_LOG (msg,ERROR); /* output error */ fs_give ((void **) &msg); return NIL; @@ -1286,7 +1286,7 @@ long nntp_search_msg (MAILSTREAM *stream,unsigned long msgno,SEARCHPGM *pgm, if (pgm->msgno || pgm->uid) { /* message set searches */ SEARCHSET *set; /* message sequences */ - if (set = pgm->msgno) { /* must be inside this sequence */ + if ((set = pgm->msgno) != NULL) { /* must be inside this sequence */ while (set) { /* run down until find matching range */ if (set->last ? ((msgno < set->first) || (msgno > set->last)) : msgno != set->first) set = set->next; @@ -1294,7 +1294,7 @@ long nntp_search_msg (MAILSTREAM *stream,unsigned long msgno,SEARCHPGM *pgm, } if (!set) return NIL; /* not found within sequence */ } - if (set = pgm->uid) { /* must be inside this sequence */ + if ((set = pgm->uid) != NULL) { /* must be inside this sequence */ unsigned long uid = mail_uid (stream,msgno); while (set) { /* run down until find matching range */ if (set->last ? ((uid < set->first) || (uid > set->last)) : @@ -1530,7 +1530,7 @@ SORTCACHE **nntp_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm, if (!nntp_over (stream,tmp)) return mail_sort_loadcache (stream,pgm); while ((s = net_getline (LOCAL->nntpstream->netstream)) && strcmp (s,".")){ /* death to embedded newlines */ - for (t = v = s; c = *v++;) if ((c != '\012') && (c != '\015')) *t++ = c; + for (t = v = s; (c = *v++) != '\0';) if ((c != '\012') && (c != '\015')) *t++ = c; *t++ = '\0'; /* tie off resulting string */ /* parse OVER response */ if ((i = mail_msgno (stream,atol (s))) && @@ -1539,14 +1539,14 @@ SORTCACHE **nntp_sort_loadcache (MAILSTREAM *stream,SORTPGM *pgm, /* put stripped subject in sortcache */ r = (SORTCACHE *) (*mailcache) (stream,i,CH_SORTCACHE); r->refwd = mail_strip_subject (t,&r->subject); - if (t = strchr (v,'\t')) { + if ((t = strchr (v,'\t')) != NULL) { *t++ = '\0'; /* tie off from */ - if (adr = rfc822_parse_address (&adr,adr,&v,BADHOST,0)) { + if ((adr = rfc822_parse_address (&adr,adr,&v,BADHOST,0)) != NULL) { r->from = adr->mailbox; adr->mailbox = NIL; mail_free_address (&adr); } - if (v = strchr (t,'\t')) { + if ((v = strchr (t,'\t')) != NULL) { *v++ = '\0'; /* tie off date */ if (mail_parse_date (&telt,t)) r->date = mail_longdate (&telt); if ((v = strchr (v,'\t')) && (v = strchr (++v,'\t'))) @@ -1696,10 +1696,10 @@ SENDSTREAM *nntp_open_full (NETDRIVER *dv,char **hostlist,char *service, /* default port */ if (mb.port) port = mb.port; else if (!port) port = nntp_port ? nntp_port : NNTPTCPPORT; - if (netstream = /* try to open ordinary connection */ + if ((netstream = /* try to open ordinary connection */ net_open (&mb,dv,port, (NETDRIVER *) mail_parameters (NIL,GET_SSLDRIVER,NIL), - "*nntps",nntp_sslport ? nntp_sslport : NNTPSSLPORT)) { + "*nntps",nntp_sslport ? nntp_sslport : NNTPSSLPORT)) != NULL) { stream = (SENDSTREAM *) fs_get (sizeof (SENDSTREAM)); /* initialize stream */ memset ((void *) stream,0,sizeof (SENDSTREAM)); @@ -1737,9 +1737,9 @@ SENDSTREAM *nntp_open_full (NETDRIVER *dv,char **hostlist,char *service, mb.tlsflag = T; /* TLS OK, get into TLS at this end */ stream->netstream->dtb = ssld; /* negotiate TLS */ - if (stream->netstream->stream = + if ((stream->netstream->stream = (*stls) (stream->netstream->stream,mb.host, - SSL_MTHD(mb) | (mb.novalidate ? NET_NOVALIDATECERT:NIL))) + SSL_MTHD(mb) | (mb.novalidate ? NET_NOVALIDATECERT:NIL))) != NULL) extok = nntp_extensions (stream,(mb.secflag ? AU_SECURE : NIL) | (mb.authuser[0] ? AU_AUTHUSER : NIL)); else { @@ -1834,7 +1834,7 @@ long nntp_extensions (SENDSTREAM *stream,long flags) while ((t = net_getline (stream->netstream)) && (t[1] || (*t != '.'))) { if (stream->debug) mm_dlog (t); /* get optional capability arguments */ - if (args = strchr (t,' ')) *args++ = '\0'; + if ((args = strchr (t,' ')) != NULL) *args++ = '\0'; if (!compare_cstring (t,"LISTGROUP")) NNTP.ext.listgroup = T; else if (!compare_cstring (t,"OVER")) NNTP.ext.over = T; else if (!compare_cstring (t,"HDR")) NNTP.ext.hdr = T; @@ -1933,7 +1933,7 @@ long nntp_mail (SENDSTREAM *stream,ENVELOPE *env,BODY *body) env->sender ? env->sender->mailbox : (env->from ? env->from->mailbox : "not-for-mail")); /* here's another cretinism */ - if (s = strstr (env->date," (")) *s = NIL; + if ((s = strstr (env->date," (")) != NULL) *s = NIL; do if ((ret = nntp_send_work (stream,"POST",NIL)) == NNTPREADY) /* output data, return success status */ ret = (net_soutr (stream->netstream, @@ -2231,7 +2231,7 @@ long nntp_soutr (void *stream,char *s) /* "." on first line */ if (s[0] == '.') net_soutr (stream,"."); /* find lines beginning with a "." */ - while (t = strstr (s,"\015\012.")) { + while ((t = strstr (s,"\015\012.")) != NULL) { c = *(t += 3); /* remember next character after "." */ *t = '\0'; /* tie off string */ /* output prefix */ diff --git a/imap/src/c-client/pop3.c b/imap/src/c-client/pop3.c index 52573f52..46c050ee 100644 --- a/imap/src/c-client/pop3.c +++ b/imap/src/c-client/pop3.c @@ -273,10 +273,10 @@ void pop3_lsub (MAILSTREAM *stream,char *ref,char *pat) if (ref && *ref) sprintf (mbx,"%s%s",ref,pat); else strcpy (mbx,pat); - if (s = sm_read (tmp,&sdb)) do if (pop3_valid (s) && pmatch (s,mbx)) + if ((s = sm_read (tmp,&sdb)) != NULL) do if (pop3_valid (s) && pmatch (s,mbx)) mm_lsub (stream,NIL,s,NIL); /* until no more subscriptions */ - while (s = sm_read (tmp,&sdb)); + while ((s = sm_read (tmp,&sdb)) != NULL); } @@ -428,7 +428,7 @@ MAILSTREAM *pop3_open (MAILSTREAM *stream) if (mb.notlsflag) strcat (tmp,"/notls"); if (mb.sslflag) strcat (tmp,"/ssl"); if (mb.novalidate) strcat (tmp,"/novalidate-cert"); - if (LOCAL->loser = mb.loser) strcat (tmp,"/loser"); + if ((LOCAL->loser = mb.loser) != 0) strcat (tmp,"/loser"); if (stream->secure) strcat (tmp,"/secure"); sprintf (tmp + strlen (tmp),"/user=\"%s\"}%s",usr,mb.mailbox); stream->inbox = T; /* always INBOX */ @@ -498,7 +498,7 @@ long pop3_capa (MAILSTREAM *stream,long flags) while ((t = net_getline (LOCAL->netstream)) && (t[1] || (*t != '.'))) { if (stream->debug) mm_dlog (t); /* get optional capability arguments */ - if (args = strchr (t,' ')) *args++ = '\0'; + if ((args = strchr (t,' ')) != NULL) *args++ = '\0'; if (!compare_cstring (t,"STLS")) LOCAL->cap.stls = T; else if (!compare_cstring (t,"PIPELINING")) LOCAL->cap.pipelining = T; else if (!compare_cstring (t,"RESP-CODES")) LOCAL->cap.respcodes = T; @@ -509,7 +509,7 @@ long pop3_capa (MAILSTREAM *stream,long flags) LOCAL->cap.implementation = cpystr (args); else if (!compare_cstring (t,"EXPIRE") && args) { LOCAL->cap.expire = T; /* note that it is present */ - if (s = strchr(args,' ')){/* separate time from possible USER */ + if ((s = strchr(args,' ')) != NULL){/* separate time from possible USER */ *s++ = '\0'; /* in case they add something after USER */ if ((strlen (s) > 4) && (s[4] == ' ')) s[4] = '\0'; @@ -520,7 +520,7 @@ long pop3_capa (MAILSTREAM *stream,long flags) } else if (!compare_cstring (t,"LOGIN-DELAY") && args) { LOCAL->cap.logindelay = T;/* note that it is present */ - if (s = strchr(args,' ')){/* separate time from possible USER */ + if ((s = strchr(args,' ')) != NULL){/* separate time from possible USER */ *s++ = '\0'; /* in case they add something after USER */ if ((strlen (s) > 4) && (s[4] == ' ')) s[4] = '\0'; @@ -841,7 +841,7 @@ char *pop3_header (MAILSTREAM *stream,unsigned long msgno,unsigned long *size, &elt->private.msg.header.text.size); } /* otherwise load the cache with the message */ - else if (elt->private.msg.header.text.size = pop3_cache (stream,elt)) + else if ((elt->private.msg.header.text.size = pop3_cache (stream,elt)) != 0L) f = LOCAL->txt; if (f) { /* got it, make sure at start of file */ fseek (f,(unsigned long) 0,SEEK_SET); @@ -945,10 +945,10 @@ long pop3_expunge (MAILSTREAM *stream,char *sequence,long options) MESSAGECACHE *elt; unsigned long i = 1,n = 0; long ret; - if (ret = sequence ? ((options & EX_UID) ? + if ((ret = sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : mail_sequence (stream,sequence)) : - LONGT) { /* build selected sequence if needed */ + LONGT) != 0L) { /* build selected sequence if needed */ while (i <= stream->nmsgs) { elt = mail_elt (stream,i); if (elt->deleted && (sequence ? elt->sequence : T) && diff --git a/imap/src/c-client/rfc822.c b/imap/src/c-client/rfc822.c index 133f9e67..de919b3c 100644 --- a/imap/src/c-client/rfc822.c +++ b/imap/src/c-client/rfc822.c @@ -156,7 +156,7 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i, } /* find header item type */ - if (t = d = strchr (tmp,':')) { + if ((t = d = strchr (tmp,':')) != NULL) { *d++ = '\0'; /* tie off header item, point at its data */ while (*d == ' ') d++; /* flush whitespace */ while ((tmp < t--) && (*t == ' ')) *t = '\0'; @@ -205,7 +205,7 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i, if (!strcmp (tmp+1,"ROM")) rfc822_parse_adrlist (&env->from,d,host); else if (!strcmp (tmp+1,"OLLOWUP-TO")) { t = env->followup_to = (char *) fs_get (1 + strlen (d)); - while (c = *d++) if (c != ' ') *t++ = c; + while ((c = *d++) != '\0') if (c != ' ') *t++ = c; *t++ = '\0'; } break; @@ -219,7 +219,7 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i, env->message_id = cpystr (d); else if (!strcmp (tmp+1,"IME-VERSION")) { /* tie off at end of phrase */ - if (t = rfc822_parse_phrase (d)) *t = '\0'; + if ((t = rfc822_parse_phrase (d)) != NULL) *t = '\0'; rfc822_skipws (&d); /* skip whitespace */ /* known version? */ if (strcmp (d,"1.0") && strcmp (d,"RFC-XXXX")) @@ -230,7 +230,7 @@ void rfc822_parse_msg_full (ENVELOPE **en,BODY **bdy,char *s,unsigned long i, case 'N': /* possible Newsgroups: */ if (!env->newsgroups && !strcmp (tmp+1,"EWSGROUPS")) { t = env->newsgroups = (char *) fs_get (1 + strlen (d)); - while (c = *d++) if (c != ' ') *t++ = c; + while ((c = *d++) != '\0') if (c != ' ') *t++ = c; *t++ = '\0'; } break; @@ -443,7 +443,7 @@ void rfc822_parse_content (BODY *body,STRING *bs,char *h,unsigned long depth, j = strlen (s1) + 2; /* length of cookie and header */ c = '\012'; /* initially at beginning of line */ while (i > j) { /* examine data */ - if (m = GETPOS (bs)) m--; /* get position in front of character */ + if ((m = GETPOS (bs)) != 0L) m--; /* get position in front of character */ switch (c) { /* examine each line */ case '\015': /* handle CRLF form */ if (CHR (bs) == '\012'){/* following LF? */ @@ -453,7 +453,7 @@ void rfc822_parse_content (BODY *body,STRING *bs,char *h,unsigned long depth, if (!(i && i-- && ((c = SNX (bs)) == '-') && i-- && ((c = SNX (bs)) == '-'))) break; /* see if cookie matches */ - if (k = j - 2) for (s = s1; i-- && *s++ == (c = SNX (bs)) && --k;); + if ((k = j - 2) != 0L) for (s = s1; i-- && *s++ == (c = SNX (bs)) && --k;); if (k) break; /* strings didn't match if non-zero */ /* terminating delimiter? */ if ((c = ((i && i--) ? (SNX (bs)) : '\012')) == '-') { @@ -509,7 +509,7 @@ void rfc822_parse_content (BODY *body,STRING *bs,char *h,unsigned long depth, /* parse non-empty body parts */ for (part = body->nested.part; part; part = part->next) { /* part non-empty (header and/or content)? */ - if (i = part->body.mime.text.size) { + if ((i = part->body.mime.text.size) != 0L) { /* move to that part of the body */ SETPOS (bs,part->body.mime.offset); /* until end of header */ @@ -610,7 +610,7 @@ void rfc822_parse_content_header (BODY *body,char *name,char *s) STRINGLIST *stl; rfc822_skipws (&s); /* skip leading comments */ /* flush whitespace */ - if (t = strchr (name,' ')) *t = '\0'; + if ((t = strchr (name,' ')) != NULL) *t = '\0'; switch (*name) { /* see what kind of content */ case 'I': /* possible Content-ID */ if (!(strcmp (name+1,"D") || body->id)) body->id = cpystr (s); @@ -800,7 +800,7 @@ void rfc822_parse_adrlist (ADDRESS **lst,char *string,char *host) } if (!*string) string = NIL; /* punt if ran out of string */ /* got an address? */ - else if (adr = rfc822_parse_address (lst,last,&string,host,0)) { + else if ((adr = rfc822_parse_address (lst,last,&string,host,0)) != NULL) { last = adr; /* new tail address */ if (string) { /* analyze what follows */ rfc822_skipws (&string); @@ -854,9 +854,9 @@ ADDRESS *rfc822_parse_address (ADDRESS **lst,ADDRESS *last,char **string, if (!*string) return NIL; /* no string */ rfc822_skipws (string); /* skip leading WS */ if (!**string) return NIL; /* empty string */ - if (adr = rfc822_parse_group (lst,last,string,defaulthost,depth)) last = adr; + if ((adr = rfc822_parse_group (lst,last,string,defaulthost,depth)) != NULL) last = adr; /* got an address? */ - else if (adr = rfc822_parse_mailbox (string,defaulthost)) { + else if ((adr = rfc822_parse_mailbox (string,defaulthost)) != NULL) { if (!*lst) *lst = adr; /* yes, first time through? */ else last->next = adr; /* no, append to the list */ /* set for subsequent linking */ @@ -902,7 +902,7 @@ ADDRESS *rfc822_parse_group (ADDRESS **lst,ADDRESS *last,char **string, last = adr; /* set for subsequent linking */ *string = p; /* continue after this point */ while (*string && **string && (**string != ';')) { - if (adr = rfc822_parse_address (lst,last,string,defaulthost,depth+1)) { + if ((adr = rfc822_parse_address (lst,last,string,defaulthost,depth+1)) != NULL) { last = adr; /* new tail address */ if (*string) { /* anything more? */ rfc822_skipws (string); /* skip whitespace */ @@ -961,7 +961,7 @@ ADDRESS *rfc822_parse_mailbox (char **string,char *defaulthost) if (*(s = *string) == '<') /* note start, handle case of phraseless RA */ adr = rfc822_parse_routeaddr (s,string,defaulthost); /* otherwise, expect at least one word */ - else if (end = rfc822_parse_phrase (s)) { + else if ((end = rfc822_parse_phrase (s)) != NULL) { if ((adr = rfc822_parse_routeaddr (end,string,defaulthost))) { /* phrase is a personal name */ if (adr->personal) fs_give ((void **) &adr->personal); @@ -1090,7 +1090,7 @@ ADDRESS *rfc822_parse_addrspec (char *string,char **ret,char *defaulthost) string = ++t; /* skip past the dot and any WS */ rfc822_skipws (&string); /* get next word of mailbox */ - if (t = rfc822_parse_word (string,wspecials)) { + if ((t = rfc822_parse_word (string,wspecials)) != NULL) { end = t; /* remember new end of mailbox */ c = *t; /* remember delimiter */ *t = '\0'; /* tie off word */ @@ -1158,7 +1158,7 @@ char *rfc822_parse_domain (char *string,char **end) } } /* search for end of host */ - else if (t = rfc822_parse_word (string,wspecials)) { + else if ((t = rfc822_parse_word (string,wspecials)) != NULL) { c = *t; /* remember delimiter */ *t = '\0'; /* tie off host */ ret = rfc822_cpy (string); /* copy host */ @@ -1168,7 +1168,7 @@ char *rfc822_parse_domain (char *string,char **end) while (*t == '.') { /* some cretin taking RFC 822 too seriously? */ string = ++t; /* skip past the dot and any WS */ rfc822_skipws (&string); - if (string = rfc822_parse_domain (string,&t)) { + if ((string = rfc822_parse_domain (string,&t)) != NULL) { *end = t; /* remember new end of domain */ c = *t; /* remember delimiter */ *t = '\0'; /* tie off host */ @@ -1235,7 +1235,7 @@ char *rfc822_parse_word (char *s,const char *delimiters) case I2CS_94x94_JIS_OLD:/* old JIS (1978) */ case I2CS_94x94_JIS_NEW:/* new JIS (1983) */ str = ++st; /* skip past the shift to JIS */ - while (st = strchr (st,I2C_ESC)) + while ((st = strchr (st,I2C_ESC)) != NULL) if ((*++st == I2C_G0_94) && ((st[1] == I2CS_94_ASCII) || (st[1] == I2CS_94_JIS_ROMAN) || (st[1] == I2CS_94_JIS_BUGROM))) { @@ -1434,7 +1434,7 @@ static long rfc822_output_data (RFC822BUFFER *buf,char *string,long len) { while (len) { /* until request satified */ long i; - if (i = min (len,buf->end - buf->cur)) { + if ((i = min (len,buf->end - buf->cur)) != 0L) { memcpy (buf->cur,string,i); buf->cur += i; /* blat data */ string += i; @@ -1682,7 +1682,7 @@ long rfc822_output_cat (RFC822BUFFER *buf,char *src,const char *specials) /* yes, write as quoted string*/ if (!rfc822_output_char (buf,'"')) return NIL; /* embedded quote characters? */ - for (; s = strpbrk (src,"\\\""); src = s + 1) { + for (; (s = strpbrk (src,"\\\"")) != NULL; src = s + 1) { /* yes, insert quoting */ if (!(rfc822_output_data (buf,src,s-src) && rfc822_output_char (buf,'\\') && @@ -1800,7 +1800,7 @@ void rfc822_encode_body_7bit (ENVELOPE *env,BODY *body) } part = body->nested.part; /* encode body parts */ do rfc822_encode_body_7bit (env,&part->body); - while (part = part->next); /* until done */ + while ((part = part->next) != NULL); /* until done */ break; case TYPEMESSAGE: /* encapsulated message */ switch (body->encoding) { @@ -1868,7 +1868,7 @@ void rfc822_encode_body_8bit (ENVELOPE *env,BODY *body) } part = body->nested.part; /* encode body parts */ do rfc822_encode_body_8bit (env,&part->body); - while (part = part->next); /* until done */ + while ((part = part->next) != NULL); /* until done */ break; case TYPEMESSAGE: /* encapsulated message */ switch (body->encoding) { @@ -2024,7 +2024,7 @@ void *rfc822_base64 (unsigned char *src,unsigned long srcl,unsigned long *len) */ sprintf (tmp,"Possible data truncation in rfc822_base64(): %.80s", (char *) src - 1); - if (s = strpbrk (tmp,"\015\012")) *s = NIL; + if ((s = strpbrk (tmp,"\015\012")) != NULL) *s = NIL; mm_log (tmp,PARSE); srcl = 1; /* don't issue any more messages */ break; diff --git a/imap/src/c-client/smanager.c b/imap/src/c-client/smanager.c index 1f9b508c..437e1079 100644 --- a/imap/src/c-client/smanager.c +++ b/imap/src/c-client/smanager.c @@ -41,9 +41,9 @@ long sm_subscribe (char *mailbox) /* canonicalize INBOX */ if (!compare_cstring (mailbox,"INBOX")) mailbox = "INBOX"; SUBSCRIPTIONFILE (db); /* open subscription database */ - if (f = fopen (db,"r")) { /* make sure not already there */ + if ((f = fopen (db,"r")) != NULL) { /* make sure not already there */ while (fgets (tmp,MAILTMPLEN,f)) { - if (s = strchr (tmp,'\n')) *s = '\0'; + if ((s = strchr (tmp,'\n')) != NULL) *s = '\0'; if (!strcmp (tmp,mailbox)) {/* already subscribed? */ sprintf (tmp,"Already subscribed to mailbox %.80s",mailbox); MM_LOG (tmp,ERROR); @@ -83,7 +83,7 @@ long sm_unsubscribe (char *mailbox) } else { while (fgets (tmp,MAILTMPLEN,f)) { - if (s = strchr (tmp,'\n')) *s = '\0'; + if ((s = strchr (tmp,'\n')) != NULL) *s = '\0'; if (strcmp (tmp,mailbox)) fprintf (tf,"%s\n",tmp); else found = T; /* found the name */ } @@ -113,11 +113,11 @@ char *sm_read (char *sbname,void **sdb) if (!f) { /* first time through? */ SUBSCRIPTIONFILE (sbname); /* open subscription database */ /* make sure not already there */ - if (f = fopen (sbname,"r")) *sdb = (void *) f; + if ((f = fopen (sbname,"r")) != NULL) *sdb = (void *) f; else return NIL; } if (fgets (sbname,MAILTMPLEN,f)) { - if (s = strchr (sbname,'\n')) *s = '\0'; + if ((s = strchr (sbname,'\n')) != NULL) *s = '\0'; return sbname; } fclose (f); /* all done */ diff --git a/imap/src/c-client/smtp.c b/imap/src/c-client/smtp.c index 1a79d28d..405f8738 100644 --- a/imap/src/c-client/smtp.c +++ b/imap/src/c-client/smtp.c @@ -167,10 +167,10 @@ SENDSTREAM *smtp_open_full (NETDRIVER *dv,char **hostlist,char *service, } /* else port argument overrides SMTP port */ else if (!port) port = smtp_port ? smtp_port : SMTPTCPPORT; - if (netstream = /* try to open ordinary connection */ + if ((netstream = /* try to open ordinary connection */ net_open (&mb,dv,port, (NETDRIVER *) mail_parameters (NIL,GET_SSLDRIVER,NIL), - "*smtps",smtp_sslport ? smtp_sslport : SMTPSSLPORT)) { + "*smtps",smtp_sslport ? smtp_sslport : SMTPSSLPORT)) != NULL) { stream = (SENDSTREAM *) memset (fs_get (sizeof (SENDSTREAM)),0, sizeof (SENDSTREAM)); stream->netstream = netstream; @@ -788,7 +788,7 @@ long smtp_soutr (void *stream,char *s) /* "." on first line */ if (s[0] == '.') net_sout (stream,".",1); /* find lines beginning with a "." */ - while (t = strstr (s,"\015\012.")) { + while ((t = strstr (s,"\015\012.")) != NULL) { c = *(t += 3); /* remember next character after "." */ *t = '\0'; /* tie off string */ /* output prefix */ diff --git a/imap/src/c-client/utf8.c b/imap/src/c-client/utf8.c index cad4a7c7..844abefd 100644 --- a/imap/src/c-client/utf8.c +++ b/imap/src/c-client/utf8.c @@ -657,7 +657,7 @@ unsigned short *utf8_rmap_cs (const CHARSET *cs) unsigned short *ret = NIL; if (!cs); /* have charset? */ else if (cs == currmapcs) ret = currmap; - else if (ret = utf8_rmap_gen (cs,currmap)) { + else if ((ret = utf8_rmap_gen (cs,currmap)) != NULL) { currmapcs = cs; currmap = ret; } @@ -789,7 +789,7 @@ long utf8_rmaptext (SIZEDTEXT *text,unsigned short *rmap,SIZEDTEXT *ret, { unsigned long i,u,c; /* get size of buffer */ - if (i = utf8_rmapsize (text,rmap,errch,iso2022jp)) { + if ((i = utf8_rmapsize (text,rmap,errch,iso2022jp)) != 0L) { unsigned char *s = text->data; unsigned char *t = ret->data = (unsigned char *) fs_get (i); ret->size = i - 1; /* number of octets in destination buffer */ @@ -1320,7 +1320,7 @@ unsigned long *utf8_csvalidmap (char *charsets[]) /* substitute EUC-JP for ISO-2022-JP */ if (!compare_cstring (s,"ISO-2022-JP")) s = "EUC-JP"; /* look up charset */ - if (cs = utf8_charset (s)) { + if ((cs = utf8_charset (s)) != NULL) { csb = 1 << csi; /* charset bit */ switch (cs->type) { case CT_ASCII: /* 7-bit ASCII no table */ @@ -2424,7 +2424,7 @@ unsigned long ucs4_decompose (unsigned long c,void **more) struct decomposemore *m; if (c & U8G_ERROR) { /* want to chase more? */ /* do sanity check */ - if (m = (struct decomposemore *) *more) switch (m->type) { + if ((m = (struct decomposemore *) *more) != NULL) switch (m->type) { case MORESINGLE: /* single value */ ret = m->data.single; fs_give (more); /* no more decomposition */ @@ -2447,7 +2447,7 @@ unsigned long ucs4_decompose (unsigned long c,void **more) else if (c == UCS4_BMPLOMIN) ret = ucs4_dbmplotab[0]; else if (c <= UCS4_BMPLOMAX) { /* within range - have a decomposition? */ - if (i = ucs4_dbmploixtab[c - UCS4_BMPLOMIN]) { + if ((i = ucs4_dbmploixtab[c - UCS4_BMPLOMIN]) != 0L) { /* get first value of decomposition */ ret = ucs4_dbmplotab[ix = i & UCS4_BMPLOIXMASK]; /* has continuation? */ @@ -2477,7 +2477,7 @@ unsigned long ucs4_decompose (unsigned long c,void **more) else if (c < UCS4_BMPHIMIN) ret = c; else if (c <= UCS4_BMPHIMAX) { /* within range - have a decomposition? */ - if (i = ucs4_dbmphiixtab[c - UCS4_BMPHIMIN]) { + if ((i = ucs4_dbmphiixtab[c - UCS4_BMPHIMIN]) != 0L) { /* get first value of decomposition */ ret = ucs4_dbmphitab[ix = i & UCS4_BMPHIIXMASK]; /* has continuation? */ @@ -2542,7 +2542,7 @@ unsigned long ucs4_decompose_recursive (unsigned long c,void **more) RECURSIVEMORE *mr; if (c & U8G_ERROR) { /* want to chase more? */ mn = NIL; - if (mr = (RECURSIVEMORE *) *more) switch (mr->more->type) { + if ((mr = (RECURSIVEMORE *) *more) != NULL) switch (mr->more->type) { case MORESINGLE: /* decompose single value */ c = ucs4_decompose_recursive (mr->more->data.single,&mn); *more = mr->next; /* done with this more, remove it */ @@ -2562,7 +2562,7 @@ unsigned long ucs4_decompose_recursive (unsigned long c,void **more) fatal ("invalid more block argument to ucs4_decompose_recursive!"); } else fatal ("no more block provided to ucs4_decompose_recursive!"); - if (mr = mn) { /* did this value recurse on us? */ + if ((mr = mn) != NULL) { /* did this value recurse on us? */ mr->next = *more; /* yes, insert new more at head */ *more = mr; } diff --git a/imap/src/c-client/utf8aux.c b/imap/src/c-client/utf8aux.c index 5138987b..5241b9e1 100644 --- a/imap/src/c-client/utf8aux.c +++ b/imap/src/c-client/utf8aux.c @@ -44,7 +44,7 @@ static void utf8_stringlist (STRINGLIST *st,char *charset) fs_give ((void **) &st->text.data); st->text.data = txt.data; /* transfer this text */ st->text.size = txt.size; - } while (st = st->next); + } while ((st = st->next) != NULL); } @@ -133,7 +133,7 @@ long utf8_mime2text (SIZEDTEXT *src,SIZEDTEXT *dst,long flags) ((te - s) < MAXENCWORD)) { if (mime2_decode (e,t,te,&txt)) { *ce = '\0'; /* temporarily tie off charset */ - if (ls = strchr (cs,'*')) *ls = '\0'; + if ((ls = strchr (cs,'*')) != NULL) *ls = '\0'; /* convert to UTF-8 as best we can */ if (!utf8_text (&txt,cs,&rtxt,flags)) utf8_text (&txt,NIL,&rtxt,flags); if (dst->data) { /* make sure existing buffer fits */ @@ -238,7 +238,7 @@ long mime2_decode (unsigned char *e,unsigned char *t,unsigned char *te, txt->data[txt->size] = '\0'; break; case 'B': case 'b': /* BASE64 */ - if (txt->data = (unsigned char *) rfc822_base64 (t,te - t,&txt->size)) + if ((txt->data = (unsigned char *) rfc822_base64 (t,te - t,&txt->size)) != NULL) break; default: /* any other encoding is unknown */ return NIL; /* syntax error: unknown encoding */ diff --git a/imap/src/dmail/dmail.c b/imap/src/dmail/dmail.c index 25bc547f..cf9bb732 100644 --- a/imap/src/dmail/dmail.c +++ b/imap/src/dmail/dmail.c @@ -27,6 +27,7 @@ #include <stdio.h> #include <pwd.h> #include <errno.h> +#include <ctype.h> extern int errno; /* just in case */ #include <sysexits.h> #include <sys/file.h> @@ -115,7 +116,7 @@ void file_string_setpos (STRING *s,unsigned long i) s->offset = i; /* set new offset */ s->curpos = s->chunk; /* reset position */ /* set size of data */ - if (s->cursize = min (s->chunksize,SIZE (s))) { + if ((s->cursize = min (s->chunksize,SIZE (s))) != 0L) { /* move to that position in the file */ fseek ((FILE *) s->data,s->offset,SEEK_SET); fread (s->curpos,sizeof (char),(unsigned int) s->cursize,(FILE *) s->data); @@ -224,7 +225,7 @@ int deliver (FILE *f,unsigned long msglen,char *user) STRING st; struct stat sbuf; /* have a mailbox specifier? */ - if (mailbox = strchr (user,'+')) { + if ((mailbox = strchr (user,'+')) != NULL) { *mailbox++ = '\0'; /* yes, tie off user name */ if (!*mailbox || !compare_cstring ((unsigned char *) mailbox,"INBOX")) mailbox = NIL; /* user+ and user+INBOX same as user */ diff --git a/imap/src/imapd/imapd.c b/imap/src/imapd/imapd.c index 5f72ac70..980eadec 100644 --- a/imap/src/imapd/imapd.c +++ b/imap/src/imapd/imapd.c @@ -335,7 +335,7 @@ int main (int argc,char *argv[]) if (nntp) { /* desire NNTP proxy? */ if (fgets (proxy,MAILTMPLEN,nntp)) { /* remove newline and set NNTP proxy */ - if (s = strchr (proxy,'\n')) *s = '\0'; + if ((s = strchr (proxy,'\n')) != NULL) *s = '\0'; nntpproxy = cpystr (proxy); /* disable the news driver */ mail_parameters (NIL,DISABLE_DRIVER,"news"); @@ -407,13 +407,13 @@ int main (int argc,char *argv[]) if (lstref) fs_give ((void **) &lstref); while (litsp) fs_give ((void **) &litstk[--litsp]); /* find end of line */ - if (t = strchr (cmdbuf,'\012')) { + if ((t = strchr (cmdbuf,'\012')) != NULL) { /* tie off command termination */ if ((t > cmdbuf) && (t[-1] == '\015')) --t; *t = '\0'; /* tie off LF or CRLF */ } if (!t) { /* probably line too long if not terminated */ - if (t = strchr (cmdbuf,' ')) { + if ((t = strchr (cmdbuf,' ')) != NULL) { if ((t - cmdbuf) > MAXTAG) t = NIL; else *t = '\0'; } @@ -481,7 +481,7 @@ int main (int argc,char *argv[]) unsigned char *cl = cpystr (tcp_clienthost ()); size_t cls; /* get just host name, calculate length */ - if (t = strchr (cl,' ')) { + if ((t = strchr (cl,' ')) != NULL) { *t = '\0'; cls = t - cl; } @@ -561,7 +561,7 @@ int main (int argc,char *argv[]) } else response ="%.80s NO AUTHENTICATE ANONYMOUS failed\015\012"; } - else if (user = cpystr (mail_auth (s,imap_responder,argc,argv))) { + else if ((user = cpystr (mail_auth (s,imap_responder,argc,argv))) != NULL) { pass = cpystr ("*"); state = SELECT; /* make select */ alerttime = 0; /* force alert */ @@ -621,7 +621,7 @@ int main (int argc,char *argv[]) tcp_clienthost ()); } else { /* delimit user from possible admin */ - if (s = strchr (user,'*')) *s++ ='\0'; + if ((s = strchr (user,'*')) != NULL) *s++ ='\0'; /* see if username and password are OK */ if (server_login (user,pass,s,argc,argv)) { state = SELECT; /* make select */ @@ -639,7 +639,7 @@ int main (int argc,char *argv[]) /* start TLS security */ else if (!strcmp (cmd,"STARTTLS")) { if (arg) response = badarg; - else if (lsterr = ssl_start_tls (pgmname)) response = lose; + else if ((lsterr = ssl_start_tls (pgmname)) != NULL) response = lose; } else { response = badcml; @@ -785,7 +785,7 @@ int main (int argc,char *argv[]) else if (!strcmp (s,"CC")) pg->function = SORTCC; else if (!strcmp (s,"SIZE")) pg->function = SORTSIZE; else break; - } while (s = strtok_r (NIL," ",&sstate)); + } while ((s = strtok_r (NIL," ",&sstate)) != NULL); /* bad SORT attribute */ if (s) response = badatt; /* get charset and search criteria */ @@ -795,7 +795,7 @@ int main (int argc,char *argv[]) else if (!parse_criteria (spg = mail_newsearchpgm (),&arg,nmsgs, uidmax (stream),0)) response = badatt; else if (arg && *arg) response = badarg; - else if (slst = mail_sort (stream,cs,spg,pgm,uid ? SE_UID:NIL)) { + else if ((slst = mail_sort (stream,cs,spg,pgm,uid ? SE_UID:NIL)) != NULL) { PSOUT ("* SORT"); for (sl = slst; *sl; sl++) { PBOUT (' '); @@ -825,7 +825,7 @@ int main (int argc,char *argv[]) uidmax (stream),0)) response = badatt; else if (arg && *arg) response = badarg; else { - if (thr = mail_thread (stream,s,cs,spg,uid ? SE_UID : NIL)) { + if ((thr = mail_thread (stream,s,cs,spg,uid ? SE_UID : NIL)) != NULL) { PSOUT ("* THREAD "); pthread (thr); mail_free_threadnode (&thr); @@ -903,7 +903,7 @@ int main (int argc,char *argv[]) ((arg[6] == 'T') || (arg[6] == 't')) && (arg[7] == ' ')) { arg += 8; /* yes, skip over CHARSET token */ - if (s = snarf (&arg)) charset = cpystr (s); + if ((s = snarf (&arg)) != NULL) charset = cpystr (s); else break; /* missing character set */ } /* must have arguments here */ @@ -1049,7 +1049,7 @@ int main (int argc,char *argv[]) /* copy and tie off */ strncpy (tmp,t,i)[i] = '\0'; /* nuke any trailing newline */ - if (t = strpbrk (tmp,"\r\n")) *t = '\0'; + if ((t = strpbrk (tmp,"\r\n")) != NULL) *t = '\0'; /* try to open proxy */ if ((tstream = mail_open (NIL,tmp,f | OP_SILENT)) && (response == win) && tstream->nmsgs) { @@ -1216,7 +1216,7 @@ int main (int argc,char *argv[]) PSOUT (t); CRLF; } - } while (t = strtok_r (NIL," ",&sstate)); + } while ((t = strtok_r (NIL," ",&sstate)) != NULL); ping_mailbox (uid); /* in case the fool did STATUS on open mbx */ PFLUSH (); /* make sure stdout is dumped in case slave */ if (!compare_cstring (s,"INBOX")) s = "INBOX"; @@ -1301,7 +1301,7 @@ int main (int argc,char *argv[]) PARAMETER *p; PSOUT ("* NAMESPACE"); if (ns) for (i = 0; i < 3; i++) { - if (n = ns[i]) { + if ((n = ns[i]) != NULL) { PSOUT (" ("); do { PBOUT ('('); @@ -1321,16 +1321,16 @@ int main (int argc,char *argv[]) break; } /* NAMESPACE extensions are hairy */ - if (p = n->param) do { + if ((p = n->param) != NULL) do { PBOUT (' '); pstring (p->attribute); PSOUT (" ("); do pstring (p->value); while (p->next && !p->next->attribute && (p = p->next)); PBOUT (')'); - } while (p = p->next); + } while ((p = p->next) != NULL); PBOUT (')'); - } while (n = n->next); + } while ((n = n->next) != NULL); PBOUT (')'); } else PSOUT (" NIL"); @@ -1464,7 +1464,7 @@ int main (int argc,char *argv[]) clearerr (stdin); /* clear stdin errors */ status = "discarding unread literal"; /* read literal and discard it */ - while (i = (litplus.size > MAILTMPLEN) ? MAILTMPLEN : litplus.size) { + while ((i = (litplus.size > MAILTMPLEN) ? MAILTMPLEN : litplus.size) != 0L){ if (state == LOGOUT) litplus.size = 0; else { settimeout (INPUTTIMEOUT); @@ -1479,7 +1479,7 @@ int main (int argc,char *argv[]) /* get new command tail */ slurp (tmp,MAILTMPLEN,INPUTTIMEOUT); /* locate end of line */ - if (t = strchr (tmp,'\012')) { + if ((t = strchr (tmp,'\012')) != NULL) { /* back over CR */ if ((t > tmp) && (t[-1] == '\015')) --t; *t = NIL; /* tie off CRLF */ @@ -1583,7 +1583,7 @@ int main (int argc,char *argv[]) syslog (LOG_INFO,"%s user=%.80s host=%.80s",logout, user ? (char *) user : "???",tcp_clienthost ()); /* do logout hook if needed */ - if (lgoh = (logouthook_t) mail_parameters (NIL,GET_LOGOUTHOOK,NIL)) + if ((lgoh = (logouthook_t) mail_parameters (NIL,GET_LOGOUTHOOK,NIL)) != NULL) (*lgoh) (mail_parameters (NIL,GET_LOGOUTDATA,NIL)); _exit (ret); /* all done */ return ret; /* stupid compilers */ @@ -2134,7 +2134,7 @@ unsigned char *parse_astring (unsigned char **arg,unsigned long *size, (*t > ' ') && (*t < 0x7f) && (*t != '(') && (*t != ')') && (*t != '{') && (*t != '%') && (*t != '*') && (*t != '"') && (*t != '\\'); ++t,++i); - if (*size = i) break; /* got atom if non-empty */ + if ((*size = i) != 0L) break; /* got atom if non-empty */ case ')': case '%': case '*': case '\\': case '\0': case ' ': return NIL; /* empty atom is a bogon */ case '"': /* hunt for trailing quote */ @@ -2192,7 +2192,7 @@ unsigned char *parse_astring (unsigned char **arg,unsigned long *size, } break; } - if (*del = *t) { /* have a delimiter? */ + if ((*del = *t) != '\0') { /* have a delimiter? */ *t++ = '\0'; /* yes, stomp on it */ *arg = t; /* update argument pointer */ } @@ -2291,7 +2291,7 @@ unsigned char *snarf_list (unsigned char **arg) for (s = t = *arg, i = 0; (*t > ' ') && (*t != '(') && (*t != ')') && (*t != '{') && (*t != '"') && (*t != '\\'); ++t,++i); - if (c = *t) { /* have a delimiter? */ + if ((c = *t) != '\0') { /* have a delimiter? */ *t++ = '\0'; /* stomp on it */ *arg = t; /* update argument pointer */ } @@ -2333,7 +2333,7 @@ STRINGLIST *parse_stringlist (unsigned char **s,int *list) /* must be end of list */ if (c != ')') mail_free_stringlist (&ret); } - if (t = *s) { /* need to reload strtok state? */ + if ((t = *s) != '\0') { /* need to reload strtok state? */ /* end of a list? */ if (*list && (*t == ')') && !t[1]) *list = NIL; else sstate = t; /* otherwise reset strtok state to s */ @@ -2757,9 +2757,9 @@ void fetch_work (char *t,unsigned long uid,fetchfn_t f[],void *fa[]) else if (!strcmp (t,"FULL")) strcpy (t,"(FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)"); else if (!strcmp (t,"FAST")) strcpy (t,"(FLAGS INTERNALDATE RFC822.SIZE)"); - if (list = (*t == '(')) t++; /* skip open paren */ + if ((list = (*t == '(')) != 0) t++; /* skip open paren */ /* parse attribute list */ - if (s = strtok_r (t," ",&sstate)) do { + if ((s = strtok_r (t," ",&sstate)) != NULL) do { if (list && (i = strlen (s)) && (s[i-1] == ')')) { list = NIL; /* done with list */ s[i-1] = '\0'; /* tie off last item */ @@ -3080,7 +3080,7 @@ void fetch_body_part_binary (unsigned long i,void *args) /* what encoding was used? */ if (body) switch (body->encoding) { case ENCBASE64: - if (cst.data = rfc822_base64 (st.data,st.size,&cst.size)) break; + if ((cst.data = rfc822_base64 (st.data,st.size,&cst.size)) != NULL) break; fetch_uid (i,NIL); /* wrote a space, so must do something */ if (lsterr) fs_give ((void **) &lsterr); lsterr = cpystr ("Undecodable BASE64 contents"); @@ -3088,7 +3088,7 @@ void fetch_body_part_binary (unsigned long i,void *args) fs_give ((void **) &tmp); return; case ENCQUOTEDPRINTABLE: - if (cst.data = rfc822_qprint (st.data,st.size,&cst.size)) break; + if ((cst.data = rfc822_qprint (st.data,st.size,&cst.size)) != NULL) break; fetch_uid (i,NIL); /* wrote a space, so must do something */ if (lsterr) fs_give ((void **) &lsterr); lsterr = cpystr ("Undecodable QUOTED-PRINTABLE contents"); @@ -3284,8 +3284,8 @@ void fetch_flags (unsigned long i,void *args) if (elt->flagged) put_flag (&c,"\\Flagged"); if (elt->answered) put_flag (&c,"\\Answered"); if (elt->draft) put_flag (&c,"\\Draft"); - if (u = elt->user_flags) do /* any user flags? */ - if (t = stream->user_flags[find_rightmost_bit (&u)]) put_flag (&c,t); + if ((u = elt->user_flags) != 0L) do /* any user flags? */ + if ((t = stream->user_flags[find_rightmost_bit (&u)]) != NULL) put_flag (&c,t); while (u); /* until no more user flags */ PBOUT (')'); /* end of flags */ elt->spare2 = NIL; /* we've sent the update */ @@ -3478,7 +3478,7 @@ void pbodystructure (BODY *body) /* multipart type? */ if (body->type == TYPEMULTIPART) { /* print each part */ - if (part = body->nested.part) + if ((part = body->nested.part) != NULL) for (; part; part = part->next) pbodystructure (&(part->body)); else pbodystructure (NIL); PBOUT (' '); /* space delimiter */ @@ -3563,7 +3563,7 @@ void pbody (BODY *body) /* multipart type? */ if (body->type == TYPEMULTIPART) { /* print each part */ - if (part = body->nested.part) + if ((part = body->nested.part) != NULL) for (; part; part = part->next) pbody (&(part->body)); else pbody (NIL); PBOUT (' '); /* space delimiter */ @@ -3617,7 +3617,7 @@ void pparam (PARAMETER *param) pstring (param->attribute); PBOUT (' '); pstring (param->value); - if (param = param->next) PBOUT (' '); + if ((param = param->next) != NULL) PBOUT (' '); } while (param); PBOUT (')'); /* end of parameters */ } @@ -3643,7 +3643,7 @@ void paddr (ADDRESS *a) PBOUT (' '); pnstring (a->host); /* domain name of mailbox's host */ PBOUT (')'); /* terminate address */ - } while (a = a->next); /* until end of address */ + } while ((a = a->next) != NULL); /* until end of address */ PBOUT (')'); /* close address list */ } else PSOUT ("NIL"); /* empty address */ @@ -3662,7 +3662,7 @@ void pset (SEARCHSET **set) PBOUT (':'); pnum (cur->last); } - if (cur = cur->next) PBOUT (','); + if ((cur = cur->next) != NULL) PBOUT (','); } mail_free_searchset (set); /* flush set */ } @@ -3802,7 +3802,7 @@ void pastringlist (STRINGLIST *s) do { psizedastring (&s->text); /* output list member */ if (s->next) PBOUT (' '); - } while (s = s->next); + } while ((s = s->next) != NULL); PBOUT (')'); /* terminate list */ } @@ -3819,7 +3819,7 @@ void pnstringorlist (STRINGLIST *s) do { /* output list member */ psizedstring (&s->text,NIL); if (s->next) PBOUT (' '); - } while (s = s->next); + } while ((s = s->next) != NULL); PBOUT (')'); /* terminate list */ } /* and single-element list as string */ @@ -3877,7 +3877,7 @@ void ptext (SIZEDTEXT *txt,STRING *st) { unsigned char c,*s; unsigned long i = txt->size; - if (s = txt->data) while (i && ((PBOUT ((c = *s++) ? c : 0x80) != EOF))) --i; + if ((s = txt->data) != NULL) while (i && ((PBOUT ((c = *s++) ? c : 0x80) != EOF))) --i; else if (st) while (i && (PBOUT ((c = SNX (st)) ? c : 0x80) != EOF)) --i; /* failed to complete? */ if (i) ioerror (stdout,"writing text"); @@ -3894,7 +3894,7 @@ void pthread (THREADNODE *thr) PBOUT ('('); /* open branch */ if (thr->num) { /* first node message number */ pnum (thr->num); - if (t = thr->next) { /* any subsequent nodes? */ + if ((t = thr->next) != NULL) { /* any subsequent nodes? */ PBOUT (' '); while (t) { /* for each subsequent node */ if (t->branch) { /* branches? */ @@ -3947,7 +3947,7 @@ void pcapability (long flag) } if (flag <= 0) { /* want pre-authentication capabilities? */ PSOUT (" SASL-IR LOGIN-REFERRALS"); - if (s = ssl_start_tls (NIL)) fs_give ((void **) &s); + if ((s = ssl_start_tls (NIL)) != NULL) fs_give ((void **) &s); else PSOUT (" STARTTLS"); /* disable plaintext */ if (!(i = !mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL))) @@ -4142,7 +4142,7 @@ long proxycopy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) if (lsterr) fs_give ((void **) &lsterr); /* c-client clobbers sequence, use spare */ for (i = 1,j = 0,set = mail_newsearchset (); i <= nmsgs; i++) - if (mail_elt (stream,i)->spare = mail_elt (stream,i)->sequence) { + if ((mail_elt (stream,i)->spare = mail_elt (stream,i)->sequence) != 0L) { mail_append_set (set,mail_uid (stream,i)); if (!j) md.msgno = (j = i) - 1; } @@ -4197,7 +4197,7 @@ long proxy_append (MAILSTREAM *stream,void *data,char **flags,char **date, if (elt->flagged) strcat (s," \\Flagged"); if (elt->answered) strcat (s," \\Answered"); if (elt->draft) strcat (s," \\Draft"); - if (i = elt->user_flags) do + if ((i = elt->user_flags) != 0L) do if ((t = md->stream->user_flags[find_rightmost_bit (&i)]) && *t && (strlen (t) < ((size_t) (MAILTMPLEN-((s += strlen (s))+2-tmp))))) { *s++ = ' '; /* space delimiter */ @@ -4229,9 +4229,9 @@ long append_msg (MAILSTREAM *stream,void *data,char **flags,char **date, APPENDDATA *ad = (APPENDDATA *) data; unsigned char *arg = ad->arg; /* flush text of previous message */ - if (t = ad->flags) fs_give ((void **) &ad->flags); - if (t = ad->date) fs_give ((void **) &ad->date); - if (t = ad->msg) fs_give ((void **) &ad->msg); + if ((t = ad->flags) != NULL) fs_give ((void **) &ad->flags); + if ((t = ad->date) != NULL) fs_give ((void **) &ad->date); + if ((t = ad->msg) != NULL) fs_give ((void **) &ad->msg); *flags = *date = NIL; /* assume no flags or date */ if (t) { /* have previous message? */ if (!*arg) { /* if least one message, and no more coming */ diff --git a/imap/src/ipopd/ipop2d.c b/imap/src/ipopd/ipop2d.c index 14cbe52f..58d4d2d5 100644 --- a/imap/src/ipopd/ipop2d.c +++ b/imap/src/ipopd/ipop2d.c @@ -296,7 +296,7 @@ short c_helo (char *t,int argc,char *argv[]) pass = cpystr (tmp); if (!(s = strchr (u,':'))) { /* want remote mailbox? */ /* no, delimit user from possible admin */ - if (s = strchr (u,'*')) *s++ = '\0'; + if ((s = strchr (u,'*')) != NULL) *s++ = '\0'; if (server_login (user = cpystr (u),pass,s,argc,argv)) { syslog (LOG_INFO,"%sLogin user=%.80s host=%.80s",s ? "Admin " : "", user,tcp_clienthost ()); @@ -355,7 +355,7 @@ short c_fold (char *t) } #endif /* open mailbox, note # of messages */ - if (j = (stream = mail_open (stream,t,NIL)) ? stream->nmsgs : 0) { + if ((j = (stream = mail_open (stream,t,NIL)) ? stream->nmsgs : 0) != 0L){ sprintf (tmp,"1:%lu",j); /* fetch fast information for all messages */ mail_fetch_fast (stream,tmp,NIL); msg = (unsigned long *) fs_get ((stream->nmsgs + 1) * @@ -429,7 +429,7 @@ short c_retr (char *t) } fputs (status,stdout); /* yes, output message */ fputs ("\015\012",stdout); /* delimit header from text */ - if (t = mail_fetch_text (stream,msg[current],NIL,&i,FT_RETURNSTRINGSTRUCT)) + if ((t = mail_fetch_text (stream,msg[current],NIL,&i,FT_RETURNSTRINGSTRUCT)) != NULL) while (i) { /* blat the text */ if (!(j = fwrite (t,sizeof (char),i,stdout))) return DONE; if (i -= j) t += j; /* advance to incomplete data */ diff --git a/imap/src/ipopd/ipop3d.c b/imap/src/ipopd/ipop3d.c index 41dd96a6..9cb8bffc 100644 --- a/imap/src/ipopd/ipop3d.c +++ b/imap/src/ipopd/ipop3d.c @@ -192,9 +192,9 @@ int main (int argc,char *argv[]) AUTHENTICATOR *auth; PSOUT ("+OK Capability list follows:\015\012"); PSOUT ("TOP\015\012LOGIN-DELAY 180\015\012UIDL\015\012"); - if (s = ssl_start_tls (NIL)) fs_give ((void **) &s); + if ((s = ssl_start_tls (NIL)) != NULL) fs_give ((void **) &s); else PSOUT ("STLS\015\012"); - if (i = !mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL)) + if ((i = !mail_parameters (NIL,GET_DISABLEPLAINTEXT,NIL)) != 0L) PSOUT ("USER\015\012"); /* display secure server authenticators */ for (auth = mail_lookup_auth (1), s = "SASL"; auth; auth = auth->next) @@ -219,7 +219,7 @@ int main (int argc,char *argv[]) if (pass) fs_give ((void **) &pass); s = strtok (t," "); /* get mechanism name */ /* get initial response */ - if (initial = strtok (NIL,"\015\012")) { + if ((initial = strtok (NIL,"\015\012")) != NULL) { if ((*initial == '=') && !initial[1]) ++initial; else if (!*initial) initial = NIL; } @@ -272,7 +272,7 @@ int main (int argc,char *argv[]) else if (!strcmp (s,"RPOP")) PSOUT ("-ERR Nice try, bunkie\015\012"); else if (!strcmp (s,"STLS")) { - if (t = ssl_start_tls (pgmname)) { + if ((t = ssl_start_tls (pgmname)) != NULL) { PSOUT ("-ERR STLS failed: "); PSOUT (t); CRLF; @@ -288,7 +288,7 @@ int main (int argc,char *argv[]) /* skip leading whitespace (bogus clients!) */ while (*t == ' ') ++t; /* remote user name? */ - if (s = strchr (t,':')) { + if ((s = strchr (t,':')) != NULL) { *s++ = '\0'; /* tie off host name */ host = cpystr (t);/* copy host name */ user = cpystr (s);/* copy user name */ @@ -661,7 +661,7 @@ int pass_login (char *t,int argc,char *argv[]) pass = cpystr (t); /* copy password argument */ if (!host) { /* want remote mailbox? */ /* no, delimit user from possible admin */ - if (t = strchr (user,'*')) *t++ ='\0'; + if ((t = strchr (user,'*')) != NULL) *t++ ='\0'; /* attempt the login */ if (server_login (user,pass,t,argc,argv)) { int ret = mbxopen ("INBOX"); @@ -777,7 +777,7 @@ int mbxopen (char *mailbox) goodbye = "-ERR Can't get lock. Mailbox in use\015\012"; else { nmsgs = 0; /* no messages yet */ - if (j = stream->nmsgs) { /* if mailbox non-empty */ + if ((j = stream->nmsgs) != 0L) { /* if mailbox non-empty */ sprintf (tmp,"1:%lu",j); /* fetch fast information for all messages */ mail_fetch_fast (stream,tmp,NIL); } diff --git a/imap/src/mailutil/mailutil.c b/imap/src/mailutil/mailutil.c index cb62290a..2966a59f 100644 --- a/imap/src/mailutil/mailutil.c +++ b/imap/src/mailutil/mailutil.c @@ -284,8 +284,8 @@ int main (int argc,char *argv[]) else if ((i = !strcmp (cmd,"move")) || !strcmp (cmd,"copy")) { if (!src || !dst || merge) printf (usage3,pgm,cmd,usgcpymov,stdsw); - else if (source = mail_open (NIL,src,((i || rwcopyp) ? NIL : OP_READONLY) | - (debugp ? OP_DEBUG : NIL))) { + else if ((source = mail_open (NIL,src,((i || rwcopyp) ? NIL : OP_READONLY) | + (debugp ? OP_DEBUG : NIL))) != NULL) { dest = NIL; /* open destination stream if network */ if ((*dst != '{') || (dest = mail_open (NIL,dst,OP_HALFOPEN | (debugp ? OP_DEBUG : NIL)))) { @@ -295,8 +295,8 @@ int main (int argc,char *argv[]) } else if ((i = !strcmp (cmd,"appenddelete")) || !strcmp (cmd,"append")) { if (!src || !dst || merge) printf (usage3,pgm,cmd,usgappdel,stdsw); - else if (source = mail_open (NIL,src,((i || rwcopyp) ? NIL : OP_READONLY) | - (debugp ? OP_DEBUG : NIL))) { + else if ((source = mail_open (NIL,src,((i || rwcopyp) ? NIL : OP_READONLY) | + (debugp ? OP_DEBUG : NIL))) != NULL) { dest = NIL; /* open destination stream if network */ if ((*dst != '{') || (dest = mail_open (NIL,dst,OP_HALFOPEN | (debugp ? OP_DEBUG : NIL)))) { @@ -376,7 +376,7 @@ int main (int argc,char *argv[]) rewind (f); /* read back mailbox names */ for (retcode = 0; !retcode && (fgets (tmp,MAILTMPLEN-1,f)); ) { - if (t = strchr (tmp+1,'\n')) *t = '\0'; + if ((t = strchr (tmp+1,'\n')) != NULL) *t = '\0'; for (t = mbx,t1 = dest ? dest->mailbox : "",c = NIL; (c != '}') && *t1; *t++ = c= *t1++); for (t1 = dp; *t1; *t++ = *t1++); @@ -384,7 +384,7 @@ int main (int argc,char *argv[]) t1 = source ? (strchr (tmp+1,'}') + 1) : tmp + 1; /* src and mbx have different delimiters? */ if (ddelim && (ddelim != tmp[0])) - while (c = *t1++) { /* swap delimiters then */ + while ((c = *t1++) != '\0') { /* swap delimiters then */ if (c == ddelim) c = tmp[0] ? tmp[0] : 'x'; else if (c == tmp[0]) c = ddelim; *t++ = c; @@ -396,8 +396,8 @@ int main (int argc,char *argv[]) printf ("Copying %s\n => %s\n",tmp+1,mbx); fflush (stdout); } - if (source = mail_open (source,tmp+1,(debugp ? OP_DEBUG : NIL) | - (rwcopyp ? NIL : OP_READONLY))) { + if ((source = mail_open (source,tmp+1,(debugp ? OP_DEBUG : NIL) | + (rwcopyp ? NIL : OP_READONLY))) != NULL) { if (!mbxcopy (source,dest,mbx,T,NIL,merge)) retcode = 1; if (source->dtb->flags & DR_LOCAL) source = mail_close (source); } @@ -595,7 +595,7 @@ int mbxcopy (MAILSTREAM *source,MAILSTREAM *dest,char *dst,int create,int del, fputs ("alternative name: ",stdout); fflush (stdout); fgets (tmp,MAILTMPLEN-1,stdin); - if (s = strchr (tmp,'\n')) *s = '\0'; + if ((s = strchr (tmp,'\n')) != NULL) *s = '\0'; } if (ndst) fs_give ((void **) &ndst); ndst = cpystr (tmp); @@ -624,7 +624,7 @@ int mbxcopy (MAILSTREAM *source,MAILSTREAM *dest,char *dst,int create,int del, char *tail = "\\Deleted)"; char *flags = (char *) fs_get (1 + len + strlen (tail) + 1); s = flags; *s++ = '('; - for (i = 0; i < NUSERFLAGS; ++i) if (t = source->user_flags[i]) { + for (i = 0; i < NUSERFLAGS; ++i) if ((t = source->user_flags[i]) != NULL) { while (*t) *s++ = *t++; *s++ = ' '; } @@ -895,7 +895,7 @@ void mm_login (NETMBX *mb,char *username,char *password,long trial) printf ("%s} username: ",tmp); fgets (username,NETMAXUSER-1,stdin); username[NETMAXUSER-1] = '\0'; - if (s = strchr (username,'\n')) *s = '\0'; + if ((s = strchr (username,'\n')) != NULL) *s = '\0'; s = "password: "; } if(strlen (s = getpass (s)) < MAILTMPLEN) strcpy (password,s); diff --git a/imap/src/mlock/mlock.c b/imap/src/mlock/mlock.c index 1dca40ed..35d6be4d 100644 --- a/imap/src/mlock/mlock.c +++ b/imap/src/mlock/mlock.c @@ -32,6 +32,7 @@ #include <sysexits.h> #include <syslog.h> #include <grp.h> +#include <unistd.h> #include <sys/types.h> #include <sys/file.h> #include <sys/stat.h> @@ -40,6 +41,7 @@ #include <netdb.h> #include <ctype.h> #include <string.h> +#include <time.h> #define LOCKTIMEOUT 5 /* lock timeout in minutes */ #define LOCKPROTECTION 0664 diff --git a/imap/src/mtest/mtest.c b/imap/src/mtest/mtest.c index 8e997d0b..018d1bcd 100644 --- a/imap/src/mtest/mtest.c +++ b/imap/src/mtest/mtest.c @@ -104,7 +104,7 @@ int main () if (pwd) { strcpy (tmp,pwd->pw_gecos); /* dyke out the office and phone poop */ - if (suffix = strchr (tmp,',')) suffix[0] = '\0'; + if ((suffix = strchr (tmp,',')) != NULL) suffix[0] = '\0'; strcpy (personalname,tmp);/* make a permanent copy of it */ } else personalname[0] = '\0'; @@ -125,10 +125,10 @@ int main () puts ("Enter INBOX, mailbox name, or IMAP mailbox as {host}mailbox"); puts ("Known local mailboxes:"); mail_list (NIL,NIL,"%"); - if (s = sm_read (tmpx,&sdb)) { + if ((s = sm_read (tmpx,&sdb)) != NULL) { puts ("Local subscribed mailboxes:"); do (mm_lsub (NIL,NIL,s,NIL)); - while (s = sm_read (tmpx,&sdb)); + while ((s = sm_read (tmpx,&sdb)) != NULL); } puts ("or just hit return to quit"); } @@ -158,7 +158,7 @@ void mm (MAILSTREAM *stream,long debug) while (stream) { prompt ("MTest> ",cmd, sizeof(cmd)); /* prompt user, get command */ /* get argument */ - if (arg = strchr (cmd,' ')) *arg++ = '\0'; + if ((arg = strchr (cmd,' ')) != NULL) *arg++ = '\0'; switch (*ucase (cmd)) { /* dispatch based on command */ case 'B': /* Body command */ if (arg) last = atoi (arg); @@ -198,10 +198,10 @@ void mm (MAILSTREAM *stream,long debug) case 'F': /* Find command */ if (!arg) { arg = "%"; - if (s = sm_read (tmp,&sdb)) { + if ((s = sm_read (tmp,&sdb)) != NULL) { puts ("Local network subscribed mailboxes:"); do if (*s == '{') (mm_lsub (NIL,NIL,s,NIL)); - while (s = sm_read (tmp,&sdb)); + while ((s = sm_read (tmp,&sdb)) != NULL); } } puts ("Subscribed mailboxes:"); @@ -398,7 +398,7 @@ void overview_header (MAILSTREAM *stream,unsigned long uid,OVERVIEW *ov, memcpy (tmp+18,t,(size_t) min (20,(long) strlen (t))); } strcat (tmp," "); - if (i = elt->user_flags) { + if ((i = elt->user_flags) != 0L) { strcat (tmp,"{"); while (i) { strcat (tmp,stream->user_flags[find_rightmost_bit (&i)]); @@ -436,7 +436,7 @@ void header (MAILSTREAM *stream,long msgno) tmp[18] = '\0'; mail_fetchfrom (tmp+18,stream,msgno,(long) 20); strcat (tmp," "); - if (i = cache->user_flags) { + if ((i = cache->user_flags) != 0L) { strcat (tmp,"{"); while (i) { strcat (tmp,stream->user_flags[find_rightmost_bit (&i)]); @@ -473,9 +473,9 @@ void display_body (BODY *body,char *pfx,long i) sprintf (s," %s%ld %s",pfx,++i,body_types[body->type]); if (body->subtype) sprintf (s += strlen (s),"/%s",body->subtype); if (body->description) sprintf (s += strlen (s)," (%s)",body->description); - if (par = body->parameter) do + if ((par = body->parameter) != NULL) do sprintf (s += strlen (s),";%s=%s",par->attribute,par->value); - while (par = par->next); + while ((par = par->next) != NULL); if (body->id) sprintf (s += strlen (s),", id = %s",body->id); switch (body->type) { /* bytes or lines depending upon body type */ case TYPEMESSAGE: /* encapsulated message */ @@ -530,10 +530,10 @@ void status (MAILSTREAM *stream) else s = "IMAP2 (RFC 1064)"; printf ("%s server %s\n",s,imap_host (stream)); if (LEVELIMAP4 (stream)) { - if (i = imap_cap (stream)->auth) { + if ((i = imap_cap (stream)->auth) != 0L) { s = ""; printf ("Mutually-supported SASL mechanisms:"); - while (auth = mail_lookup_auth (find_rightmost_bit (&i) + 1)) { + while ((auth = mail_lookup_auth (find_rightmost_bit (&i) + 1)) != NULL) { printf (" %s",auth->name); if (!strcmp (auth->name,"PLAIN")) s = "\n [LOGIN will not be listed here if PLAIN is supported]"; @@ -579,7 +579,7 @@ void status (MAILSTREAM *stream) putchar ('\n'); } if (LEVELSCAN (stream)) puts (" Mailbox text scan"); - if (i = imap_cap (stream)->extlevel) { + if ((i = imap_cap (stream)->extlevel) != 0L) { printf ("Supported BODYSTRUCTURE extensions:"); switch (i) { case BODYEXTLOC: printf (" location"); @@ -719,7 +719,7 @@ void mm_login (NETMBX *mb,char *user,char *pwd,long trial) printf ("%s} username: ",tmp); fgets (user,NETMAXUSER-1,stdin); user[NETMAXUSER-1] = '\0'; - if (s = strchr (user,'\n')) *s = '\0'; + if ((s = strchr (user,'\n')) != NULL) *s = '\0'; s = "password: "; } if (curusr) fs_give ((void **) &curusr); @@ -810,14 +810,14 @@ void smtptest (long debug) strcpy (msg->date,line); if (msg->to) { puts ("Sending..."); - if (stream = smtp_open (hostlist,debug)) { + if ((stream = smtp_open (hostlist,debug)) != NULL) { if (smtp_mail (stream,"MAIL",msg,body)) puts ("[Ok]"); else printf ("[Failed - %s]\n",stream->reply); } } else { puts ("Posting..."); - if (stream = nntp_open (newslist,debug)) { + if ((stream = nntp_open (newslist,debug)) != NULL) { if (nntp_mail (stream,msg,body)) puts ("[Ok]"); else printf ("[Failed - %s]\n",stream->reply); } diff --git a/imap/src/osdep/unix/dummy.c b/imap/src/osdep/unix/dummy.c index cb3b45bd..07ed4618 100644 --- a/imap/src/osdep/unix/dummy.c +++ b/imap/src/osdep/unix/dummy.c @@ -156,7 +156,7 @@ void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents) if (!pat || !*pat) { /* empty pattern? */ if (dummy_canonicalize (test,ref,"*")) { /* tie off name at root */ - if (s = strchr (test,'/')) *++s = '\0'; + if ((s = strchr (test,'/')) != NULL) *++s = '\0'; else test[0] = '\0'; dummy_listed (stream,'/',test,LATT_NOSELECT,NIL); } @@ -164,13 +164,13 @@ void dummy_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents) /* get canonical form of name */ else if (dummy_canonicalize (test,ref,pat)) { /* found any wildcards? */ - if (s = strpbrk (test,"%*")) { + if ((s = strpbrk (test,"%*")) != NULL) { /* yes, copy name up to that point */ strncpy (file,test,i = s - test); file[i] = '\0'; /* tie off */ } else strcpy (file,test); /* use just that name then */ - if (s = strrchr (file,'/')){/* find directory name */ + if ((s = strrchr (file,'/')) != NULL){/* find directory name */ *++s = '\0'; /* found, tie off at that point */ s = file; } @@ -228,7 +228,7 @@ void dummy_lsub (MAILSTREAM *stream,char *ref,char *pat) } } /* until no more subscriptions */ - while (s = sm_read (tmpx,&sdb)); + while ((s = sm_read (tmpx,&sdb)) != NULL); } @@ -277,7 +277,7 @@ void dummy_list_work (MAILSTREAM *stream,char *dir,char *pat,char *contents, size_t len = 0; /* punt if bogus name */ if (!mailboxdir (tmp,dir,NIL)) return; - if (dp = opendir (tmp)) { /* do nothing if can't open directory */ + if ((dp = opendir (tmp)) != NULL) { /* do nothing if can't open directory */ /* see if a non-namespace directory format */ for (drivers = (DRIVER *) mail_parameters (NIL,GET_DRIVERS,NIL), dt = NIL; dir && !dt && drivers; drivers = drivers->next) @@ -289,7 +289,7 @@ void dummy_list_work (MAILSTREAM *stream,char *dir,char *pat,char *contents, dummy_listed (stream,'/',dir,dt ? NIL : LATT_NOSELECT,contents); /* scan directory, ignore . and .. */ - if (!dir || dir[(len = strlen (dir)) - 1] == '/') while (d = readdir (dp)) + if (!dir || dir[(len = strlen (dir)) - 1] == '/') while ((d = readdir (dp)) != NULL) if ((!(dt && (*dt) (d->d_name))) && ((d->d_name[0] != '.') || (((long) mail_parameters (NIL,GET_HIDEDOTFILES,NIL)) ? NIL : @@ -480,7 +480,7 @@ long dummy_create_path (MAILSTREAM *stream,char *path,long dirmode) int wantdir = t && !t[1]; int mask = umask (0); if (wantdir) *t = '\0'; /* flush trailing delimiter for directory */ - if (s = strrchr (path,'/')) { /* found superior to this name? */ + if ((s = strrchr (path,'/')) != NULL) { /* found superior to this name? */ c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -798,7 +798,7 @@ long dummy_canonicalize (char *tmp,char *ref,char *pat) else return NIL; /* unknown namespace */ } /* count wildcards */ - for (i = 0, s = tmp; *s; *s++) if ((*s == '*') || (*s == '%')) ++i; + for (i = 0, s = tmp; *s; s++) if ((*s == '*') || (*s == '%')) ++i; if (i > MAXWILDCARDS) { /* ridiculous wildcarding? */ MM_LOG ("Excessive wildcards in LIST/LSUB",ERROR); return NIL; diff --git a/imap/src/osdep/unix/env_unix.c b/imap/src/osdep/unix/env_unix.c index d1bb1f02..89e50921 100644 --- a/imap/src/osdep/unix/env_unix.c +++ b/imap/src/osdep/unix/env_unix.c @@ -514,7 +514,7 @@ static void do_date (char *date,char *prefix,char *fmt,int suffix) * -1 local time is 1 day behind UTC, offset -24 hours * -36x local time is January 1, UTC is December 31, offset +24 hours */ - if (julian = t->tm_yday -julian) + if ((julian = t->tm_yday -julian) != 0) zone += ((julian < 0) == (abs (julian) == 1)) ? -24*60 : 24*60; if (prefix) { /* want day of week? */ sprintf (date,prefix,days[t->tm_wday]); @@ -672,14 +672,14 @@ static struct passwd *valpwd (char *user,char *pwd,int argc,char *argv[]) struct passwd *pw; struct passwd *ret = NIL; if (auth_md5.server) { /* using CRAM-MD5 authentication? */ - if (s = auth_md5_pwd (user)) { + if ((s = auth_md5_pwd (user)) != NULL) { if (!strcmp (s,pwd) || ((*pwd == ' ') && pwd[1] && !strcmp (s,pwd+1))) ret = pwuser (user); /* validated, get passwd entry for user */ memset (s,0,strlen (s)); /* erase sensitive information */ fs_give ((void **) &s); } } - else if (pw = pwuser (user)) {/* can get user? */ + else if ((pw = pwuser (user)) != NULL) {/* can get user? */ s = cpystr (pw->pw_name); /* copy returned name in case we need it */ if (*pwd && !(ret = checkpw (pw,pwd,argc,argv)) && (*pwd == ' ') && pwd[1] && (ret = pwuser (s))) @@ -1257,7 +1257,7 @@ long dotlock_lock (char *file,DOTLOCK *base,int fd) MM_NOCRITICAL (NIL); /* no longer critical */ /* find directory/file delimiter */ - if (s = strrchr (base->lock,'/')) { + if ((s = strrchr (base->lock,'/')) != NULL) { *s = '\0'; /* tie off at directory */ sprintf(tmp, /* generate default message */ "Mailbox vulnerable - directory %.80s must have 1777 protection", @@ -1588,7 +1588,7 @@ void dorc (char *file,long flag) if (!compare_cstring (s,"set new-mailbox-format") || !compare_cstring (s,"set new-folder-format")) { if (!compare_cstring (k,"same-as-inbox")) { - if (d = mail_valid (NIL,"INBOX",NIL)) { + if ((d = mail_valid (NIL,"INBOX",NIL)) != NULL) { if (!compare_cstring (d->name,"mbox")) d = (DRIVER *) mail_parameters (NIL,GET_DRIVER, (void *) "unix"); @@ -1601,7 +1601,7 @@ void dorc (char *file,long flag) else { /* canonicalize mbox to unix */ if (!compare_cstring (k,"mbox")) k = "unix"; /* see if a driver name */ - if (d = (DRIVER *) mail_parameters (NIL,GET_DRIVER,(void *) k)) + if ((d = (DRIVER *) mail_parameters (NIL,GET_DRIVER,(void *) k)) != NULL) createProto = (*d->open) (NIL); else { /* duh... */ sprintf (tmpx,"Unknown new mailbox format in %s: %s", diff --git a/imap/src/osdep/unix/fdstring.c b/imap/src/osdep/unix/fdstring.c index 7a491f7d..207e4d0b 100644 --- a/imap/src/osdep/unix/fdstring.c +++ b/imap/src/osdep/unix/fdstring.c @@ -91,7 +91,7 @@ static void fd_string_setpos (STRING *s,unsigned long i) s->offset = i; /* set new offset */ s->curpos = s->chunk; /* reset position */ /* set size of data */ - if (s->cursize = min (s->chunksize,SIZE (s))) { + if ((s->cursize = min (s->chunksize,SIZE (s))) != 0L) { /* move to that position in the file */ lseek ((long) s->data,s->data1 + s->offset,L_SET); read ((long) s->data,s->curpos,(size_t) s->cursize); diff --git a/imap/src/osdep/unix/mbx.c b/imap/src/osdep/unix/mbx.c index dc902b20..18c4fa20 100644 --- a/imap/src/osdep/unix/mbx.c +++ b/imap/src/osdep/unix/mbx.c @@ -477,7 +477,7 @@ long mbx_rename (MAILSTREAM *stream,char *old,char *newname) if (newname) { /* want rename? */ /* found superior to destination name? */ - if (s = strrchr (tmp,'/')) { + if ((s = strrchr (tmp,'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* superior name doesn't exist, create it */ @@ -822,11 +822,11 @@ long mbx_ping (MAILSTREAM *stream) /* reparse header if not flagchecking */ if (!LOCAL->flagcheck) ret = mbx_parse (stream); /* sweep mailbox for changed message status */ - else if (ret = mbx_parse (stream)) { + else if ((ret = mbx_parse (stream)) != 0L) { unsigned long recent = 0; LOCAL->filetime = sbuf.st_mtime; for (i = 1; i <= stream->nmsgs; ) - if (elt = mbx_elt (stream,i,LOCAL->expok)) { + if ((elt = mbx_elt (stream,i,LOCAL->expok)) != NULL) { if (elt->recent) ++recent; ++i; } @@ -885,14 +885,14 @@ long mbx_expunge (MAILSTREAM *stream,char *sequence,long options) { long ret; unsigned long nexp,reclaimed; - if (ret = sequence ? ((options & EX_UID) ? + if ((ret = sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) { + mail_sequence (stream,sequence)) : LONGT) != 0L) { if (!mbx_ping (stream)); /* do nothing if stream dead */ else if (stream->rdonly) /* won't do on readonly files! */ MM_LOG ("Expunge ignored on readonly mailbox",WARN); /* if expunged any messages */ - else if (nexp = mbx_rewrite (stream,&reclaimed,sequence ? -1 : 1)) { + else if ((nexp = mbx_rewrite (stream,&reclaimed,sequence ? -1 : 1)) != 0L){ sprintf (LOCAL->buf,"Expunged %lu messages",nexp); MM_LOG (LOCAL->buf,(long) NIL); } @@ -935,7 +935,7 @@ void mbx_snarf (MAILSTREAM *stream) hdr = cpystr (mail_fetchheader_full (sysibx,i,NIL,&hdrlen,NIL)); txt = mail_fetchtext_full (sysibx,i,&txtlen,FT_PEEK); /* if have a message */ - if (j = hdrlen + txtlen) { + if ((j = hdrlen + txtlen) != 0L){ /* build header line */ mail_date (LOCAL->buf,elt = mail_elt (sysibx,i)); sprintf (LOCAL->buf + strlen (LOCAL->buf), @@ -1032,7 +1032,7 @@ long mbx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) mail_date(LOCAL->buf,elt);/* build target header */ /* get target keyword mask */ for (j = elt->user_flags, k = 0; j; ) - if (s = stream->user_flags[find_rightmost_bit (&j)]) + if ((s = stream->user_flags[find_rightmost_bit (&j)]) != NULL) for (m = 0; (m < NUSERFLAGS) && (t = dstream->user_flags[m]); m++) if (!compare_cstring (s,t) && (k |= 1 << m)) break; sprintf (LOCAL->buf+strlen(LOCAL->buf),",%lu;%08lx%04x-%08lx\015\012", @@ -1041,7 +1041,7 @@ long mbx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) (fFLAGGED * elt->flagged) + (fANSWERED * elt->answered) + (fDRAFT * elt->draft)),cu ? ++dstream->uid_last : 0); /* write target header */ - if (ret = (write (fd,LOCAL->buf,strlen (LOCAL->buf)) > 0)) { + if ((ret = (write (fd,LOCAL->buf,strlen (LOCAL->buf)) > 0)) != 0L) { for (k = elt->rfc822_size; ret && (j = min (k,LOCAL->buflen)); k -= j){ read (LOCAL->fd,LOCAL->buf,j); ret = write (fd,LOCAL->buf,j) >= 0; @@ -1641,7 +1641,7 @@ unsigned long mbx_hdrpos (MAILSTREAM *stream,unsigned long msgno, elt->private.special.text.size; if (hdr) *hdr = NIL; /* assume no header returned */ /* is header size known? */ - if (*size = elt->private.msg.header.text.size) return ret; + if ((*size = elt->private.msg.header.text.size) != 0L) return ret; /* paranoia check */ if (LOCAL->buflen < (HDRBUFLEN + SLOP)) fatal ("LOCAL->buf smaller than HDRBUFLEN"); @@ -1733,7 +1733,7 @@ unsigned long mbx_rewrite (MAILSTREAM *stream,unsigned long *reclaimed, MM_CRITICAL (stream); /* go critical */ for (i = 1,delta = 0,pos = ppos = HDRSIZE; i <= stream->nmsgs; ) { /* note if message not at predicted location */ - if (m = (elt = mbx_elt (stream,i,NIL))->private.special.offset - ppos) { + if ((m = (elt = mbx_elt (stream,i,NIL))->private.special.offset - ppos) != 0L) { ppos = elt->private.special.offset; *reclaimed += m; /* note reclaimed message space */ delta += m; /* and as expunge delta */ @@ -1773,7 +1773,7 @@ unsigned long mbx_rewrite (MAILSTREAM *stream,unsigned long *reclaimed, } } /* deltaed file size match position? */ - if (m = (LOCAL->filesize -= delta) - pos) { + if ((m = (LOCAL->filesize -= delta) - pos) != 0L) { *reclaimed += m; /* probably an fEXPUNGED msg */ LOCAL->filesize = pos; /* set correct size */ } @@ -1792,7 +1792,7 @@ unsigned long mbx_rewrite (MAILSTREAM *stream,unsigned long *reclaimed, (*bn) (BLOCK_NONE,NIL); /* do hide-expunge when shared */ if (flags) for (i = 1; i <= stream->nmsgs; ) { - if (elt = mbx_elt (stream,i,T)) { + if ((elt = mbx_elt (stream,i,T)) != NULL) { /* make the message invisible */ if (elt->deleted && ((flags > 0) || elt->sequence)) { mbx_update_status (stream,elt->msgno,LONGT); diff --git a/imap/src/osdep/unix/mh.c b/imap/src/osdep/unix/mh.c index 005000d6..ac71b6ba 100644 --- a/imap/src/osdep/unix/mh.c +++ b/imap/src/osdep/unix/mh.c @@ -251,7 +251,7 @@ char *mh_path (char *tmp) /* parse profile file */ for (s = strtok_r (t,"\r\n",&r); s && *s; s = strtok_r (NIL,"\r\n",&r)) { /* found space in line? */ - if (v = strpbrk (s," \t")) { + if ((v = strpbrk (s," \t")) != NULL) { *v++ = '\0'; /* tie off, is keyword "Path:"? */ if (!compare_cstring (s,"Path:")) { /* skip whitespace */ @@ -324,7 +324,7 @@ long mh_dirfmttest (char *s) if (strcmp (s,MHSEQUENCE) && strcmp (s,MHSEQUENCES)) { if (*s == MHCOMMA) ++s; /* else comma + all numeric name */ /* success if all-numeric */ - while (c = *s++) if (!isdigit (c)) return NIL; + while ((c = *s++) != '\0') if (!isdigit (c)) return NIL; } return LONGT; } @@ -343,7 +343,7 @@ void mh_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents) if (!pat || !*pat) { /* empty pattern? */ if (mh_canonicalize (test,ref,"*")) { /* tie off name at root */ - if (s = strchr (test,'/')) *++s = '\0'; + if ((s = strchr (test,'/')) != NULL) *++s = '\0'; else test[0] = '\0'; mm_list (stream,'/',test,LATT_NOSELECT); } @@ -356,14 +356,14 @@ void mh_scan (MAILSTREAM *stream,char *ref,char *pat,char *contents) } if (test[3] == '/') { /* looking down levels? */ /* yes, found any wildcards? */ - if (s = strpbrk (test,"%*")) { + if ((s = strpbrk (test,"%*")) != NULL) { /* yes, copy name up to that point */ strncpy (file,test+4,i = s - (test+4)); file[i] = '\0'; /* tie off */ } else strcpy (file,test+4);/* use just that name then */ /* find directory name */ - if (s = strrchr (file,'/')) { + if ((s = strrchr (file,'/')) != NULL) { *s = '\0'; /* found, tie off at that point */ s = file; } @@ -401,7 +401,7 @@ void mh_lsub (MAILSTREAM *stream,char *ref,char *pat) /* get canonical form of name */ if (mh_canonicalize (test,ref,pat) && (s = sm_read (tmp,&sdb))) { do if (pmatch_full (s,test,'/')) mm_lsub (stream,'/',s,NIL); - while (s = sm_read (tmp,&sdb)); /* until no more subscriptions */ + while ((s = sm_read (tmp,&sdb)) != NULL); /* until no more subscriptions */ } } @@ -425,8 +425,8 @@ void mh_list_work (MAILSTREAM *stream,char *dir,char *pat,long level) if (!mh_file (curdir,name)) return; cp = curdir + strlen (curdir);/* end of directory name */ np = name + strlen (name); /* end of MH name */ - if (dp = opendir (curdir)) { /* open directory */ - while (d = readdir (dp)) /* scan, ignore . and numeric names */ + if ((dp = opendir (curdir)) != NULL) { /* open directory */ + while ((d = readdir (dp)) != NULL) /* scan, ignore . and numeric names */ if ((d->d_name[0] != '.') && !mh_select (d)) { strcpy (cp,d->d_name); /* make directory name */ if (!stat (curdir,&sbuf) && ((sbuf.st_mode & S_IFMT) == S_IFDIR)) { @@ -510,10 +510,10 @@ long mh_delete (MAILSTREAM *stream,char *mailbox) } /* get name of directory */ i = strlen (mh_file (tmp,mailbox)); - if (dirp = opendir (tmp)) { /* open directory */ + if ((dirp = opendir (tmp)) != NULL) { /* open directory */ tmp[i++] = '/'; /* now apply trailing delimiter */ /* massacre all mh owned files */ - while (d = readdir (dirp)) if (mh_dirfmttest (d->d_name)) { + while ((d = readdir (dirp)) != NULL) if (mh_dirfmttest (d->d_name)) { strcpy (tmp + i,d->d_name); unlink (tmp); /* sayonara */ } @@ -550,7 +550,7 @@ long mh_rename (MAILSTREAM *stream,char *old,char *newname) newname); /* success if can rename the directory */ else { /* found superior to destination name? */ - if (s = strrchr (mh_file (tmp1,newname),'/')) { + if ((s = strrchr (mh_file (tmp1,newname),'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -734,7 +734,7 @@ void mh_load_message (MAILSTREAM *stream,unsigned long msgno,long flags) switch (c = SNX (&bs)) { case '\015': /* unlikely carriage return */ *t++ = c; - if ((CHR (&bs) == '\012')) { + if (CHR (&bs) == '\012') { *t++ = SNX (&bs); i++; } @@ -760,7 +760,7 @@ void mh_load_message (MAILSTREAM *stream,unsigned long msgno,long flags) switch (c = SNX (&bs)) { case '\015': /* unlikely carriage return */ *t++ = c; - if ((CHR (&bs) == '\012')) { + if (CHR (&bs) == '\012') { *t++ = SNX (&bs); i++; } @@ -883,7 +883,7 @@ long mh_ping (MAILSTREAM *stream) fs_give ((void **) &names[i]); } /* free directory */ - if (s = (void *) names) fs_give ((void **) &s); + if ((s = (void *) names) != NULL) fs_give ((void **) &s); } /* if INBOX, snarf from system INBOX */ @@ -934,7 +934,7 @@ long mh_ping (MAILSTREAM *stream) unlink (LOCAL->buf);/* flush this file */ } sprintf (tmp,"Message copy to MH mailbox failed: %.80s", - s,strerror (errno)); + strerror (errno)); mm_log (tmp,ERROR); r = 0; /* stop the snarf in its tracks */ } @@ -977,9 +977,9 @@ long mh_expunge (MAILSTREAM *stream,char *sequence,long options) unsigned long i = 1; unsigned long n = 0; unsigned long recent = stream->recent; - if (ret = sequence ? ((options & EX_UID) ? + if ((ret = sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) { + mail_sequence (stream,sequence)) : LONGT) != 0L) { mm_critical (stream); /* go critical */ while (i <= stream->nmsgs) {/* for each message */ elt = mail_elt (stream,i);/* if deleted, need to trash it */ @@ -1132,7 +1132,7 @@ long mh_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data) fs_give ((void **) &names[i]); } else last = 0; /* no messages here yet */ - if (s = (void *) names) fs_give ((void **) &s); + if ((s = (void *) names) != NULL) fs_give ((void **) &s); mm_critical (stream); /* go critical */ do { @@ -1195,7 +1195,7 @@ int mh_select (struct direct *name) { char c; char *s = name->d_name; - while (c = *s++) if (!isdigit (c)) return NIL; + while ((c = *s++) != '\0') if (!isdigit (c)) return NIL; return T; } @@ -1258,7 +1258,7 @@ long mh_canonicalize (char *pattern,char *ref,char *pat) else strcpy (pattern,pat); /* just have basic name */ if (mh_isvalid (pattern,tmp,T)) { /* count wildcards */ - for (i = 0, s = pattern; *s; *s++) if ((*s == '*') || (*s == '%')) ++i; + for (i = 0, s = pattern; *s; s++) if ((*s == '*') || (*s == '%')) ++i; /* success if not too many */ if (i <= MAXWILDCARDS) return LONGT; mm_log ("Excessive wildcards in LIST/LSUB",ERROR); diff --git a/imap/src/osdep/unix/mix.c b/imap/src/osdep/unix/mix.c index 63009bb2..c53cabc0 100644 --- a/imap/src/osdep/unix/mix.c +++ b/imap/src/osdep/unix/mix.c @@ -331,7 +331,7 @@ long mix_scan_contents (char *name,char *contents,unsigned long csiz, fs_give ((void **) &names[i]); } /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); return ret; } @@ -475,10 +475,10 @@ long mix_delete (MAILSTREAM *stream,char *mailbox) close (fd); /* close descriptor on deleted metadata */ /* get directory name */ *(s = strrchr (tmp,'/')) = '\0'; - if (dirp = opendir (tmp)) { /* open directory */ + if ((dirp = opendir (tmp)) != NULL) { /* open directory */ *s++ = '/'; /* restore delimiter */ /* massacre messages */ - while (d = readdir (dirp)) if (mix_dirfmttest (d->d_name)) { + while ((d = readdir (dirp)) != NULL) if (mix_dirfmttest (d->d_name)) { strcpy (s,d->d_name); /* make path */ unlink (tmp); /* sayonara */ } @@ -526,7 +526,7 @@ long mix_rename (MAILSTREAM *stream,char *old,char *newname) /* easy if not INBOX */ if (compare_cstring (old,"INBOX")) { /* found superior to destination name? */ - if (s = strrchr (tmp1,'/')) { + if ((s = strrchr (tmp1,'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -564,7 +564,7 @@ long mix_rename (MAILSTREAM *stream,char *old,char *newname) fs_give ((void **) &names[i]); } /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); if (lasterror) errno = lasterror; else { close (fd); /* close descriptor on metadata */ @@ -631,7 +631,7 @@ MAILSTREAM *mix_open (MAILSTREAM *stream) stream->sequence++; /* bump sequence number */ /* parse mailbox */ stream->nmsgs = stream->recent = 0; - if (silent = stream->silent) LOCAL->internal = T; + if ((silent = stream->silent) != 0) LOCAL->internal = T; stream->silent = T; if (mix_ping (stream)) { /* do initial ping */ /* try burping in case we are exclusive */ @@ -749,7 +749,7 @@ char *mix_header (MAILSTREAM *stream,unsigned long msgno,unsigned long *length, else { /* document the problem */ LOCAL->buf[100] = '\0'; /* tie off buffer at no more than 100 octets */ /* or at newline, whichever is first */ - if (s = strpbrk (LOCAL->buf,"\015\012")) *s = '\0'; + if ((s = strpbrk (LOCAL->buf,"\015\012")) != NULL) *s = '\0'; sprintf (tmp,"Error reading mix message header, uid=%lx, s=%.0lx, h=%s", elt->private.uid,elt->rfc822_size,LOCAL->buf); MM_LOG (tmp,ERROR); @@ -960,7 +960,7 @@ long mix_ping (MAILSTREAM *stream) flags[0] = '('; strcat (flags,")"); INIT (&msg,mail_string,message,msglen); - if (snarfok = mail_append_full (stream,"INBOX",flags,date,&msg)) { + if ((snarfok = mail_append_full (stream,"INBOX",flags,date,&msg)) != 0L) { char sequence[15]; sprintf (sequence,"%lu",i); mail_flag (sysibx,sequence,"\\Deleted",ST_SET); @@ -985,8 +985,8 @@ long mix_ping (MAILSTREAM *stream) /* expunging OK if global flag set */ if (mail_parameters (NIL,GET_EXPUNGEATPING,NIL)) LOCAL->expok = T; /* process metadata/index/status */ - if (statf = mix_parse (stream,&idxf,LONGT, - (LOCAL->internal ? NIL : LONGT))) { + if ((statf = mix_parse (stream,&idxf,LONGT, + (LOCAL->internal ? NIL : LONGT))) != NULL) { fclose (statf); /* just close the status file */ ret = LONGT; /* declare success */ } @@ -1033,8 +1033,8 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options) mail_uid_sequence (stream,sequence) : mail_sequence (stream,sequence))) || stream->rdonly); /* read index and open status exclusive */ - else if (statf = mix_parse (stream,&idxf,LONGT, - LOCAL->internal ? NIL : LONGT)) { + else if ((statf = mix_parse (stream,&idxf,LONGT, + LOCAL->internal ? NIL : LONGT)) != NULL) { /* expunge unless just burping */ if (!burponly) for (i = 1; i <= stream->nmsgs;) { elt = mail_elt (stream,i);/* need to expunge this message? */ @@ -1111,7 +1111,7 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options) } else MM_LOG ("No mix message files found during expunge",WARN); /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); } /* either way, re-acquire shared lock */ @@ -1120,7 +1120,7 @@ long mix_expunge (MAILSTREAM *stream,char *sequence,long options) /* Do this step even if ret is NIL (meaning some burp problem)! */ if (nexp || reclaimed) { /* rewrite index and status if changed */ LOCAL->indexseq = mix_modseq (LOCAL->indexseq); - if (ret = mix_index_update (stream,idxf,NIL)) { + if ((ret = mix_index_update (stream,idxf,NIL)) != 0L){ LOCAL->statusseq = mix_modseq (LOCAL->statusseq); /* set failure if update fails */ ret = mix_status_update (stream,statf,NIL); @@ -1237,7 +1237,7 @@ long mix_burp (MAILSTREAM *stream,MIXBURP *burp,unsigned long *reclaimed) /* if matches range then no burp needed! */ if (burp->set.last == sbuf.st_size) ret = LONGT; /* just need to remove cruft at end */ - else if (ret = !truncate (LOCAL->buf,burp->set.last)) + else if ((ret = !truncate (LOCAL->buf,burp->set.last)) != 0L) *reclaimed += sbuf.st_size - burp->set.last; else { sprintf (LOCAL->buf,truncerr,burp->name,strerror (errno)); @@ -1341,7 +1341,7 @@ long mix_burp_check (SEARCHSET *set,size_t size,char *file) file,size,set->last); MM_LOG (tmp,ERROR); return NIL; /* don't burp this file at all */ - } while (set = set->next); + } while ((set = set->next) != NULL); return LONGT; } @@ -1379,11 +1379,11 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) else if (!(ret = ((options & CP_UID) ? mail_uid_sequence (stream,sequence) : mail_sequence (stream,sequence)))); /* acquire stream to append */ - else if (ret = ((astream = mail_open (NIL,mailbox,OP_SILENT)) && + else if ((ret = ((astream = mail_open (NIL,mailbox,OP_SILENT)) && !astream->rdonly && (((MIXLOCAL *) astream->local)->expok = T) && (statf = mix_parse (astream,&idxf,LONGT,NIL))) ? - LONGT : NIL) { + LONGT : NIL) != 0L) { int fd; unsigned long i; MESSAGECACHE *elt; @@ -1405,7 +1405,7 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) if ((elt = mail_elt (stream,i))->sequence) newsize += hdrsize + elt->rfc822_size; /* open data file */ - if (msgf = mix_data_open (astream,&fd,&size,newsize)) { + if ((msgf = mix_data_open (astream,&fd,&size,newsize)) != NULL) { char *t; unsigned long j,uid,uidv; copyuid_t cu = (copyuid_t) mail_parameters (NIL,GET_COPYUID,NIL); @@ -1434,7 +1434,7 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) INIT (&st,fd_string,&d,elt->rfc822_size); /* init flag string */ tmp[0] = tmp[1] = '\0'; - if (j = elt->user_flags) do + if ((j = elt->user_flags) != 0L) do if ((t = stream->user_flags[find_rightmost_bit (&j)]) && *t) strcat (strcat (tmp," "),t); while (j); @@ -1457,8 +1457,8 @@ long mix_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) fclose (msgf); /* all good, close the msg file now */ /* write new metadata, index, and status */ local->metaseq = local->indexseq = local->statusseq = seq; - if (ret = (mix_meta_update (astream) && - mix_index_update (astream,idxf,LONGT))) { + if ((ret = (mix_meta_update (astream) && + mix_index_update (astream,idxf,LONGT))) != 0L){ /* success, delete if doing a move */ if (options & CP_MOVE) for (i = 1; i <= stream->nmsgs; i++) @@ -1521,8 +1521,8 @@ long mix_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data) if (!stream) stream = user_flags (&mixproto); if (!ret) switch (errno) { /* if not valid mailbox */ case ENOENT: /* no such file? */ - if (ret = compare_cstring (mailbox,"INBOX") ? - NIL : mix_create (NIL,"INBOX")) + if ((ret = compare_cstring (mailbox,"INBOX") ? + NIL : mix_create (NIL,"INBOX")) != 0L) break; MM_NOTIFY (stream,"[TRYCREATE] Must create mailbox before append",NIL); break; @@ -1538,11 +1538,11 @@ long mix_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data) FILE *idxf = NIL; FILE *msgf = NIL; FILE *statf = NIL; - if (ret = ((astream = mail_open (NIL,mailbox,OP_SILENT)) && + if ((ret = ((astream = mail_open (NIL,mailbox,OP_SILENT)) && !astream->rdonly && (((MIXLOCAL *) astream->local)->expok = T) && (statf = mix_parse (astream,&idxf,LONGT,NIL))) ? - LONGT : NIL) { + LONGT : NIL) != 0l) { int fd; unsigned long size,hdrsize; MESSAGECACHE elt; @@ -1558,7 +1558,7 @@ long mix_append (MAILSTREAM *stream,char *mailbox,append_t af,void *data) MM_CRITICAL (astream); /* go critical */ astream->silent = T; /* no events here */ /* open data file */ - if (msgf = mix_data_open (astream,&fd,&size,hdrsize + SIZE (message))) { + if ((msgf = mix_data_open (astream,&fd,&size,hdrsize + SIZE (message))) != NULL){ appenduid_t au = (appenduid_t) mail_parameters (NIL,GET_APPENDUID,NIL); SEARCHSET *dst = au ? mail_newsearchset () : NIL; while (ret && message) {/* while good to go and have messages */ @@ -1747,14 +1747,14 @@ FILE *mix_parse (MAILSTREAM *stream,FILE **idxf,long iflags,long sflags) } /* slurp metadata */ - else if (s = mix_meta_slurp (stream,&i)) { + else if ((s = mix_meta_slurp (stream,&i)) != NULL) { unsigned long j = 0; /* non-zero if UIDVALIDITY/UIDLAST changed */ if (i != LOCAL->metaseq) { /* metadata changed? */ char *t,*k; LOCAL->metaseq = i; /* note new metadata sequence */ while (s && *s) { /* parse entire metadata file */ /* locate end of line */ - if (s = strstr (t = s,"\015\012")) { + if ((s = strstr (t = s,"\015\012")) != NULL) { *s = '\0'; /* tie off line */ s += 2; /* skip past CRLF */ switch (*t++) { /* parse line */ @@ -1783,7 +1783,7 @@ FILE *mix_parse (MAILSTREAM *stream,FILE **idxf,long iflags,long sflags) break; case 'K': /* new keyword list */ for (i = 0; t && *t && (i < NUSERFLAGS); ++i) { - if (t = strchr (k = t,' ')) *t++ = '\0'; + if ((t = strchr (k = t,' ')) != NULL) *t++ = '\0'; /* make sure keyword non-empty */ if (*k && (strlen (k) <= MAXUSERFLAG)) { /* in case value changes (shouldn't happen) */ @@ -2455,7 +2455,7 @@ FILE *mix_data_open (MAILSTREAM *stream,int *fd,long *size, } if (*fd >= 0) { /* have a data file? */ /* yes, get stdio and set position */ - if (msgf = fdopen (*fd,"r+b")) fseek (msgf,*size,SEEK_SET); + if ((msgf = fdopen (*fd,"r+b")) != NULL)fseek (msgf,*size,SEEK_SET); else close (*fd); /* fdopen() failed? */ } return msgf; /* return results */ @@ -2519,7 +2519,7 @@ FILE *mix_sortcache_open (MAILSTREAM *stream) /* ignore expansion values */ if (*s++ == ':') { - if (i = mail_msgno (stream,uid)) { + if ((i = mail_msgno (stream,uid)) != 0L) { sc = (SORTCACHE *) (*mc) (stream,i,CH_SORTCACHE); sc->size = (elt = mail_elt (stream,i))->rfc822_size; sc->date = sentdate; @@ -2698,7 +2698,7 @@ long mix_sortcache_update (MAILSTREAM *stream,FILE **sortcache) SORTCACHE *s = (SORTCACHE *) (*mc) (stream,i,CH_SORTCACHE); STRINGLIST *sl; s->dirty = NIL; /* no longer dirty */ - if (sl = s->references) /* count length of references */ + if ((sl = s->references) != NULL) /* count length of references */ for (j = 1; sl && sl->text.data; sl = sl->next) j += 10 + sl->text.size; else j = 0; /* no references yet */ @@ -2753,7 +2753,7 @@ char *mix_read_record (FILE *f,char *buf,unsigned long buflen,char *type) /* ensure string tied off */ buf[buflen-2] = buf[buflen-1] = '\0'; while (fgets (buf,buflen-1,f)) { - if (s = strchr (buf,'\012')) { + if ((s = strchr (buf,'\012')) != NULL) { if ((s != buf) && (s[-1] == '\015')) --s; *s = '\0'; /* tie off buffer */ if (s != buf) return buf; /* return if non-empty buffer */ diff --git a/imap/src/osdep/unix/mmdf.c b/imap/src/osdep/unix/mmdf.c index e962434e..994c34a3 100644 --- a/imap/src/osdep/unix/mmdf.c +++ b/imap/src/osdep/unix/mmdf.c @@ -537,12 +537,13 @@ long mmdf_rename (MAILSTREAM *stream,char *old,char *newname) MM_CRITICAL (stream); /* get the c-client lock */ if (!dummy_file (file,old) || (newname && (!((s = mailboxfile (tmp,newname)) && *s) || - ((s = strrchr (tmp,'/')) && !s[1])))) - sprintf (tmp,newname ? - "Can't rename mailbox %.80s to %.80s: invalid name" : - "Can't delete mailbox %.80s: invalid name", - old,newname); - /* lock out other c-clients */ + ((s = strrchr (tmp,'/')) && !s[1])))){ + if(newname) sprintf (tmp, + "Can't rename mailbox %.80s to %.80s: invalid name", + old,newname); + else + sprintf (tmp, "Can't delete mailbox %.80s: invalid name", old); + } /* lock out other c-clients */ else if ((ld = lockname (lock,file,LOCK_EX|LOCK_NB,&i)) < 0) sprintf (tmp,"Mailbox %.80s is in use by another process",old); @@ -554,7 +555,7 @@ long mmdf_rename (MAILSTREAM *stream,char *old,char *newname) else { if (newname) { /* want rename? */ /* found superior to destination name? */ - if (s = strrchr (s,'/')) { + if ((s = strrchr (s,'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -981,9 +982,9 @@ long mmdf_expunge (MAILSTREAM *stream,char *sequence,long options) unsigned long i; DOTLOCK lock; char *msg = NIL; - if (ret = (sequence ? ((options & EX_UID) ? + if ((ret = (sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) && + mail_sequence (stream,sequence)) : LONGT) != 0L) && LOCAL && (LOCAL->ld >= 0) && !stream->lock && mmdf_parse (stream,&lock,LOCK_EX)) { /* check expunged messages if not dirty */ @@ -1391,10 +1392,10 @@ int mmdf_append_msgs (MAILSTREAM *stream,FILE *sf,FILE *df,SEARCHSET *set) if (i < (j = strlen (tmp))) fatal ("mmdf_append_msgs overrun"); i -= j; /* number of bytes left */ /* squish out ^A and CRs (note copies NUL) */ - for (x = tmp; x = strpbrk (x,"\01\r"); --j) memmove (x,x+1,j-(x-tmp)); + for (x = tmp; (x = strpbrk (x,"\01\r")) != NULL; --j) memmove (x,x+1,j-(x-tmp)); if (!j) continue; /* do nothing if line emptied */ /* start of line? */ - if ((c == '\n')) switch (tmp[0]) { + if (c == '\n') switch (tmp[0]) { case 'S': case 's': /* possible "Status:" */ if (hdrp && (j > 6) && ((tmp[1] == 't') || (tmp[1] == 'T')) && ((tmp[2] == 'a') || (tmp[2] == 'A')) && @@ -1609,7 +1610,7 @@ int mmdf_parse (MAILSTREAM *stream,DOTLOCK *lock,int op) } /* new data? */ - else if (i = sbuf.st_size - LOCAL->filesize) { + else if ((i = sbuf.st_size - LOCAL->filesize) != 0L) { d.fd = LOCAL->fd; /* yes, set up file descriptor */ d.pos = LOCAL->filesize; /* get to that position in the file */ d.chunk = LOCAL->buf; /* initial buffer chunk */ @@ -1931,7 +1932,7 @@ int mmdf_parse (MAILSTREAM *stream,DOTLOCK *lock,int op) char err[MAILTMPLEN]; sprintf (err,"Discarding bogus continuation in msg %lu: %.80s", elt->msgno,(char *) s); - if (u = strpbrk (err,"\r\n")) *u = '\0'; + if ((u = strpbrk (err,"\r\n")) != NULL) *u = '\0'; MM_LOG (err,WARN); break; /* different case or something */ } @@ -2175,7 +2176,7 @@ unsigned long mmdf_xstatus (MAILSTREAM *stream,char *status,MESSAGECACHE *elt, while (n /= 10); /* pop UID last digits from stack */ while (t > stack) *s++ = *--t; - for (n = 0; n < NUSERFLAGS; ++n) if (t = stream->user_flags[n]) + for (n = 0; n < NUSERFLAGS; ++n) if ((t = stream->user_flags[n]) != NULL) for (*s++ = ' '; *t; *s++ = *t++); *s++ = '\n'; pad += 30; /* increased padding if have IMAPbase */ @@ -2197,7 +2198,7 @@ unsigned long mmdf_xstatus (MAILSTREAM *stream,char *status,MESSAGECACHE *elt, if (sticky) { /* only do this if UIDs sticky */ *s++ = 'X'; *s++ = '-'; *s++ = 'K'; *s++ = 'e'; *s++ = 'y'; *s++ = 'w'; *s++ = 'o'; *s++ = 'r'; *s++ = 'd'; *s++ = 's'; *s++ = ':'; - if (n = elt->user_flags) do { + if ((n = elt->user_flags) != 0L) do { *s++ = ' '; for (t = stream->user_flags[find_rightmost_bit (&n)]; *t; *s++ = *t++); } while (n); @@ -2261,7 +2262,7 @@ long mmdf_rewrite (MAILSTREAM *stream,unsigned long *nexp,DOTLOCK *lock, size = mmdf_pseudo (stream,LOCAL->buf); } /* extend the file as necessary */ - if (ret = mmdf_extend (stream,size)) { + if ((ret = mmdf_extend (stream,size)) != 0L){ /* Set up buffered I/O file structure * curpos current position being written through buffering * filepos current position being written physically to the disk @@ -2454,7 +2455,7 @@ void mmdf_write (MMDFFILE *f,char *buf,unsigned long size) if (buf) { /* doing buffered write? */ i = f->bufpos - f->buf; /* yes, get size of current buffer data */ /* yes, have space in current buffer chunk? */ - if (j = i ? ((f->buflen - i) % OVERFLOWBUFLEN) : f->buflen) { + if ((j = i ? ((f->buflen - i) % OVERFLOWBUFLEN) : f->buflen) != 0L) { /* yes, fill up buffer as much as we can */ memcpy (f->bufpos,buf,k = min (j,size)); f->bufpos += k; /* new buffer position */ @@ -2470,7 +2471,7 @@ void mmdf_write (MMDFFILE *f,char *buf,unsigned long size) * chunks that will fit in unprotected space. */ /* any unprotected space we can write to? */ - if (j = min (i,f->protect - f->filepos)) { + if ((j = min (i,f->protect - f->filepos)) != 0L) { /* yes, filepos not at chunk boundary? */ if ((k = f->filepos % OVERFLOWBUFLEN) && ((k = OVERFLOWBUFLEN - k) < j)) j -= k; /* yes, and can write out partial chunk */ diff --git a/imap/src/osdep/unix/mtx.c b/imap/src/osdep/unix/mtx.c index 8e6f76e8..4346eceb 100644 --- a/imap/src/osdep/unix/mtx.c +++ b/imap/src/osdep/unix/mtx.c @@ -287,10 +287,11 @@ long mtx_rename (MAILSTREAM *stream,char *old,char *newname) if (!mtx_file (file,old) || (newname && (!((s = mailboxfile (tmp,newname)) && *s) || ((s = strrchr (tmp,'/')) && !s[1])))) { - sprintf (tmp,newname ? - "Can't rename mailbox %.80s to %.80s: invalid name" : - "Can't delete mailbox %.80s: invalid name", - old,newname); + if(newname) + sprintf (tmp, + "Can't rename mailbox %.80s to %.80s: invalid name", old,newname); + else + sprintf (tmp, "Can't delete mailbox %.80s: invalid name", old); MM_LOG (tmp,ERROR); return NIL; } @@ -314,7 +315,7 @@ long mtx_rename (MAILSTREAM *stream,char *old,char *newname) } if (newname) { /* want rename? */ - if (s = strrchr (tmp,'/')) {/* found superior to destination name? */ + if ((s = strrchr (tmp,'/')) != NULL) {/* found superior to destination name? */ c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -680,7 +681,7 @@ void mtx_snarf (MAILSTREAM *stream) hdr = cpystr (mail_fetchheader_full (sysibx,i,NIL,&hdrlen,NIL)); txt = mail_fetchtext_full (sysibx,i,&txtlen,FT_PEEK); /* if have a message */ - if (j = hdrlen + txtlen) { + if ((j = hdrlen + txtlen) != 0L) { /* calculate header line */ mail_date (LOCAL->buf,elt = mail_elt (sysibx,i)); sprintf (LOCAL->buf + strlen (LOCAL->buf), diff --git a/imap/src/osdep/unix/mx.c b/imap/src/osdep/unix/mx.c index 45495279..10d56b0a 100644 --- a/imap/src/osdep/unix/mx.c +++ b/imap/src/osdep/unix/mx.c @@ -239,7 +239,7 @@ long mx_dirfmttest (char *name) int c; /* success if index name or all-numberic */ if (strcmp (name,MXINDEXNAME+1)) - while (c = *name++) if (!isdigit (c)) return NIL; + while ((c = *name++) != '\0') if (!isdigit (c)) return NIL; return LONGT; } @@ -286,7 +286,7 @@ long mx_scan_contents (char *name,char *contents,unsigned long csiz, fs_give ((void **) &names[i]); } /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); return ret; } @@ -392,10 +392,10 @@ long mx_delete (MAILSTREAM *stream,char *mailbox) mailbox,strerror (errno)); else { /* get directory name */ *(s = strrchr (tmp,'/')) = '\0'; - if (dirp = opendir (tmp)) { /* open directory */ + if ((dirp = opendir (tmp)) != NULL) { /* open directory */ *s++ = '/'; /* restore delimiter */ /* massacre messages */ - while (d = readdir (dirp)) if (mx_select (d)) { + while ((d = readdir (dirp)) != NULL) if (mx_select (d)) { strcpy (s,d->d_name); /* make path */ unlink (tmp); /* sayonara */ } @@ -438,7 +438,7 @@ long mx_rename (MAILSTREAM *stream,char *old,char *newname) /* easy if not INBOX */ if (compare_cstring (old,"INBOX")) { /* found superior to destination name? */ - if (s = strrchr (mx_file (tmp1,newname),'/')) { + if ((s = strrchr (mx_file (tmp1,newname),'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -466,7 +466,7 @@ long mx_rename (MAILSTREAM *stream,char *old,char *newname) fs_give ((void **) &names[i]); } /* free directory list */ - if (a = (void *) names) fs_give ((void **) &a); + if ((a = (void *) names) != NULL) fs_give ((void **) &a); if (lasterror || mx_rename_work (tmp,srcl,tmp1,dstl,MXINDEXNAME+1)) errno = lasterror; else return mx_create (NIL,"INBOX"); @@ -749,7 +749,7 @@ long mx_ping (MAILSTREAM *stream) fs_give ((void **) &names[i]); } /* free directory */ - if (s = (void *) names) fs_give ((void **) &s); + if ((s = (void *) names) != NULL) fs_give ((void **) &s); } stream->nmsgs = nmsgs; /* don't upset mail_uid() */ @@ -801,7 +801,7 @@ long mx_ping (MAILSTREAM *stream) unlink (LOCAL->buf);/* flush this file */ } sprintf (tmp,"Message copy to MX mailbox failed: %.80s", - s,strerror (errno)); + strerror (errno)); MM_LOG (tmp,ERROR); r = 0; /* stop the snarf in its tracks */ } @@ -844,9 +844,9 @@ long mx_expunge (MAILSTREAM *stream,char *sequence,long options) unsigned long i = 1; unsigned long n = 0; unsigned long recent = stream->recent; - if (ret = (sequence ? ((options & EX_UID) ? + if ((ret = (sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) && + mail_sequence (stream,sequence)) : LONGT) != 0L) && mx_lockindex (stream)) { /* lock the index */ MM_CRITICAL (stream); /* go critical */ while (i <= stream->nmsgs) {/* for each message */ @@ -936,8 +936,8 @@ long mx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) SEARCHSET *dest = cu ? mail_newsearchset () : NIL; for (i = 1,uid = uidv = 0; ret && (i <= stream->nmsgs); i++) if ((elt = mail_elt (stream,i))->sequence) { - if (ret = ((fd = open (mx_fast_work (stream,elt),O_RDONLY,NIL)) - >= 0)) { + if ((ret = ((fd = open (mx_fast_work (stream,elt),O_RDONLY,NIL)) + >= 0)) != 0L) { fstat (fd,&sbuf); /* get size of message */ d.fd = fd; /* set up file descriptor */ d.pos = 0; /* start of file */ @@ -946,8 +946,8 @@ long mx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) INIT (&st,fd_string,&d,sbuf.st_size); /* init flag string */ tmp[0] = tmp[1] = '\0'; - if (j = elt->user_flags) do - if (t = stream->user_flags[find_rightmost_bit (&j)]) + if ((j = elt->user_flags) != 0L) do + if ((t = stream->user_flags[find_rightmost_bit (&j)]) != NULL) strcat (strcat (tmp," "),t); while (j); if (elt->seen) strcat (tmp," \\Seen"); @@ -957,7 +957,7 @@ long mx_copy (MAILSTREAM *stream,char *sequence,char *mailbox,long options) if (elt->draft) strcat (tmp," \\Draft"); tmp[0] = '('; /* open list */ strcat (tmp,")"); /* close list */ - if (ret = mx_append_msg (astream,tmp,elt,&st,dest)) { + if ((ret = mx_append_msg (astream,tmp,elt,&st,dest)) != 0L) { /* add to source set if needed */ if (source) mail_append_set (source,mail_uid (stream,i)); /* delete if doing a move */ @@ -1114,7 +1114,7 @@ int mx_select (struct direct *name) { char c; char *s = name->d_name; - while (c = *s++) if (!isdigit (c)) return NIL; + while ((c = *s++) != '\0') if (!isdigit (c)) return NIL; return T; } @@ -1186,7 +1186,7 @@ long mx_lockindex (MAILSTREAM *stream) break; case 'K': /* keyword */ /* find end of keyword */ - if (s = strchr (t = ++s,'\n')) { + if ((s = strchr (t = ++s,'\n')) != NULL) { *s++ = '\0'; /* tie off keyword */ /* copy keyword */ if ((k < NUSERFLAGS) && !stream->user_flags[k] && diff --git a/imap/src/osdep/unix/news.c b/imap/src/osdep/unix/news.c index 4cf5bb70..1af24273 100644 --- a/imap/src/osdep/unix/news.c +++ b/imap/src/osdep/unix/news.c @@ -215,7 +215,7 @@ void news_list (MAILSTREAM *stream,char *ref,char *pat) if (!pat || !*pat) { /* empty pattern? */ if (news_canonicalize (ref,"*",pattern)) { /* tie off name at root */ - if (s = strchr (pattern,'.')) *++s = '\0'; + if ((s = strchr (pattern,'.')) != NULL) *++s = '\0'; else pattern[0] = '\0'; mm_list (stream,'.',pattern,LATT_NOSELECT); } @@ -231,7 +231,7 @@ void news_list (MAILSTREAM *stream,char *ref,char *pat) strcpy (name,"#news."); /* write initial prefix */ i = strlen (pattern); /* length of pattern */ if (pattern[--i] != '%') i = 0; - if (t = strtok_r (s,"\n",&r)) do if (u = strchr (t,' ')) { + if ((t = strtok_r (s,"\n",&r)) != NULL) do if ((u = strchr (t,' ')) != NULL) { *u = '\0'; /* tie off at end of name */ strcpy (name + 6,t); /* make full form of name */ if (pmatch_full (name,pattern,'.')) mm_list (stream,'.',name,NIL); @@ -240,7 +240,7 @@ void news_list (MAILSTREAM *stream,char *ref,char *pat) if (pmatch_full (name,pattern,'.')) mm_list (stream,'.',name,LATT_NOSELECT); } - } while (t = strtok_r (NIL,"\n",&r)); + } while ((t = strtok_r (NIL,"\n",&r)) != NULL); fs_give ((void **) &s); } } @@ -283,7 +283,7 @@ long news_canonicalize (char *ref,char *pat,char *pattern) if ((pattern[0] == '#') && (pattern[1] == 'n') && (pattern[2] == 'e') && (pattern[3] == 'w') && (pattern[4] == 's') && (pattern[5] == '.') && !strchr (pattern,'/')) { /* count wildcards */ - for (i = 0, s = pattern; *s; *s++) if ((*s == '*') || (*s == '%')) ++i; + for (i = 0, s = pattern; *s; s++) if ((*s == '*') || (*s == '%')) ++i; /* success if not too many */ if (i <= MAXWILDCARDS) return LONGT; MM_LOG ("Excessive wildcards in LIST/LSUB",ERROR); @@ -365,7 +365,7 @@ MAILSTREAM *news_open (MAILSTREAM *stream) /* build directory name */ sprintf (s = tmp,"%s/%s",(char *) mail_parameters (NIL,GET_NEWSSPOOL,NIL), stream->mailbox + 6); - while (s = strchr (s,'.')) *s = '/'; + while ((s = strchr (s,'.')) != NULL) *s = '/'; /* scan directory */ if ((nmsgs = scandir (tmp,&names,news_select,news_numsort)) >= 0) { mail_exists (stream,nmsgs); /* notify upper level that messages exist */ @@ -406,7 +406,7 @@ int news_select (struct direct *name) { char c; char *s = name->d_name; - while (c = *s++) if (!isdigit (c)) return NIL; + while ((c = *s++) != '\0') if (!isdigit (c)) return NIL; return T; } @@ -566,7 +566,7 @@ void news_load_message (MAILSTREAM *stream,unsigned long msgno,long flags) switch (c = SNX (&bs)) { case '\015': /* unlikely carriage return */ *t++ = c; - if ((CHR (&bs) == '\012')) *t++ = SNX (&bs); + if (CHR (&bs) == '\012') *t++ = SNX (&bs); break; case '\012': /* line feed? */ *t++ = '\015'; @@ -586,7 +586,7 @@ void news_load_message (MAILSTREAM *stream,unsigned long msgno,long flags) switch (c = SNX (&bs)) { case '\015': /* unlikely carriage return */ *t++ = c; - if ((CHR (&bs) == '\012')) *t++ = SNX (&bs); + if (CHR (&bs) == '\012') *t++ = SNX (&bs); break; case '\012': /* line feed? */ *t++ = '\015'; diff --git a/imap/src/osdep/unix/nl_unix.c b/imap/src/osdep/unix/nl_unix.c index b2d5616a..5ae96b08 100644 --- a/imap/src/osdep/unix/nl_unix.c +++ b/imap/src/osdep/unix/nl_unix.c @@ -46,7 +46,7 @@ unsigned long strcrlfcpy (unsigned char **dst,unsigned long *dstl, if (i > *dstl) fs_give ((void **) dst); } /* make a new buffer if needed */ - if (!*dst) *dst = (char *) fs_get ((*dstl = i) + 1); + if (!*dst) *dst = (unsigned char *) fs_get ((*dstl = i) + 1); d = *dst; /* destination string */ if (srcl) do { /* main copy loop */ if ((c = *src++) < '\016') { diff --git a/imap/src/osdep/unix/phile.c b/imap/src/osdep/unix/phile.c index ce72d0a9..85aa8cbb 100644 --- a/imap/src/osdep/unix/phile.c +++ b/imap/src/osdep/unix/phile.c @@ -289,7 +289,7 @@ MAILSTREAM *phile_open (MAILSTREAM *stream) t = localtime(&sbuf.st_mtime);/* get local time */ /* calculate time delta */ i = t->tm_hour * 60 + t->tm_min - i; - if (k = t->tm_yday - k) i += ((k < 0) == (abs (k) == 1)) ? -24*60 : 24*60; + if ((k = t->tm_yday - k) != 0) i += ((k < 0) == (abs (k) == 1)) ? -24*60 : 24*60; k = abs (i); /* time from UTC either way */ elt->hours = t->tm_hour; elt->minutes = t->tm_min; elt->seconds = t->tm_sec; elt->day = t->tm_mday; elt->month = t->tm_mon + 1; @@ -306,7 +306,7 @@ MAILSTREAM *phile_open (MAILSTREAM *stream) /* fill in From field from file owner */ LOCAL->env->from = mail_newaddr (); - if (pw = getpwuid (sbuf.st_uid)) strcpy (tmp,pw->pw_name); + if ((pw = getpwuid (sbuf.st_uid)) != NULL) strcpy (tmp,pw->pw_name); else sprintf (tmp,"User-Number-%ld",(long) sbuf.st_uid); LOCAL->env->from->mailbox = cpystr (tmp); LOCAL->env->from->host = cpystr (mylocalhost ()); @@ -318,7 +318,7 @@ MAILSTREAM *phile_open (MAILSTREAM *stream) buf->data[buf->size] = '\0'; close (fd); /* close the file */ /* analyze data type */ - if (i = phile_type (buf->data,buf->size,&j)) { + if ((i = phile_type (buf->data,buf->size,&j)) != 0){ LOCAL->body->type = TYPETEXT; LOCAL->body->subtype = cpystr ("PLAIN"); if (!(i & PTYPECRTEXT)) { /* change Internet newline format as needed */ diff --git a/imap/src/osdep/unix/tcp_unix.c b/imap/src/osdep/unix/tcp_unix.c index 4fe8194d..339c968c 100644 --- a/imap/src/osdep/unix/tcp_unix.c +++ b/imap/src/osdep/unix/tcp_unix.c @@ -176,7 +176,7 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port) if (host[0] == '[' && host[(strlen (host))-1] == ']') { strcpy (tmp,host+1); /* yes, copy number part */ tmp[(strlen (tmp))-1] = '\0'; - if (adr = ip_stringtoaddr (tmp,&adrlen,&family)) { + if ((adr = ip_stringtoaddr (tmp,&adrlen,&family)) != NULL) { (*bn) (BLOCK_TCPOPEN,NIL); /* get an open socket for this system */ sock = tcp_socket_open (family,adr,adrlen,port,tmp,ctrp, @@ -223,7 +223,7 @@ TCPSTREAM *tcp_open (char *host,char *service,unsigned long port) /* init sockets */ stream->tcpsi = stream->tcpso = sock; /* stash in the snuck-in byte */ - if (stream->ictr = ctr) *(stream->iptr = stream->ibuf) = tmp[0]; + if ((stream->ictr = ctr) != 0) *(stream->iptr = stream->ibuf) = tmp[0]; stream->host = hostname; /* copy official host name */ if (tcpdebug) mm_log ("Stream open and ready for read",TCPDEBUG); } @@ -371,7 +371,7 @@ TCPSTREAM *tcp_aopen (NETMBX *mb,char *service,char *usrbuf) strcpy (host,mb->host+1); /* yes, copy without brackets */ host[i-1] = '\0'; /* validate domain literal */ - if (adr = ip_stringtoaddr (host,&len,&i)) fs_give ((void **) &adr); + if ((adr = ip_stringtoaddr (host,&len,&i)) != NULL) fs_give ((void **) &adr); else { sprintf (tmp,"Bad format domain-literal: %.80s",host); mm_log (tmp,ERROR); @@ -550,7 +550,7 @@ long tcp_getbuffer (TCPSTREAM *stream,unsigned long size,char *s) /* make sure socket still alive */ if (stream->tcpsi < 0) return NIL; /* can transfer bytes from buffer? */ - if (n = min (size,stream->ictr)) { + if ((n = min (size,stream->ictr)) != 0L) { memcpy (s,stream->iptr,n); /* yes, slurp as much as we can from it */ s += n; /* update pointer */ stream->iptr +=n; @@ -871,7 +871,7 @@ char *tcp_clienthost () if ((s = getenv (t = "SSH_CLIENT")) || (s = getenv (t = "KRB5REMOTEADDR")) || (s = getenv (t = "SSH2_CLIENT"))) { - if (v = strchr (s,' ')) *v = '\0'; + if ((v = strchr (s,' ')) != NULL) *v = '\0'; sprintf (v = tmp,"%.80s=%.80s",t,s); } else v = "UNKNOWN"; @@ -1000,7 +1000,7 @@ char *tcp_name (struct sockaddr *sadr,long flag) (*bn) (BLOCK_DNSLOOKUP,NIL);/* quell alarms */ data = (*bn) (BLOCK_SENSITIVE,NIL); /* translate address to name */ - if (t = tcp_name_valid (ip_sockaddrtoname (sadr,buf))) { + if ((t = tcp_name_valid (ip_sockaddrtoname (sadr,buf))) != NULL) { /* produce verbose form if needed */ if (flag) sprintf (ret = tmp,"%s %s",t,adr); else ret = t; diff --git a/imap/src/osdep/unix/tenex.c b/imap/src/osdep/unix/tenex.c index eee61fba..8815fee1 100644 --- a/imap/src/osdep/unix/tenex.c +++ b/imap/src/osdep/unix/tenex.c @@ -294,10 +294,13 @@ long tenex_rename (MAILSTREAM *stream,char *old,char *newname) if (!tenex_file (file,old) || (newname && (!((s = mailboxfile (tmp,newname)) && *s) || ((s = strrchr (tmp,'/')) && !s[1])))) { - sprintf (tmp,newname ? - "Can't rename mailbox %.80s to %.80s: invalid name" : - "Can't delete mailbox %.80s: invalid name", + if(newname) + sprintf (tmp, + "Can't rename mailbox %.80s to %.80s: invalid name", old,newname); + else + sprintf (tmp, + "Can't delete mailbox %.80s: invalid name", old); MM_LOG (tmp,ERROR); return NIL; } @@ -321,7 +324,7 @@ long tenex_rename (MAILSTREAM *stream,char *old,char *newname) } if (newname) { /* want rename? */ - if (s = strrchr (tmp,'/')) {/* found superior to destination name? */ + if ((s = strrchr (tmp,'/')) != NULL) {/* found superior to destination name? */ c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -769,7 +772,7 @@ void tenex_snarf (MAILSTREAM *stream) hdr = cpystr (mail_fetchheader_full(sysibx,i,NIL,&hdrlen,FT_INTERNAL)); txt = mail_fetchtext_full (sysibx,i,&txtlen,FT_INTERNAL|FT_PEEK); /* if have a message */ - if (j = hdrlen + txtlen) { + if ((j = hdrlen + txtlen) != 0L) { /* calculate header line */ mail_date (LOCAL->buf,elt = mail_elt (sysibx,i)); sprintf (LOCAL->buf + strlen (LOCAL->buf), diff --git a/imap/src/osdep/unix/unix.c b/imap/src/osdep/unix/unix.c index be3c437b..8bca508c 100644 --- a/imap/src/osdep/unix/unix.c +++ b/imap/src/osdep/unix/unix.c @@ -415,7 +415,7 @@ long unix_rename (MAILSTREAM *stream,char *old,char *newname) else { if (newname) { /* want rename? */ /* found superior to destination name? */ - if (s = strrchr (s,'/')) { + if ((s = strrchr (s,'/')) != NULL) { c = *++s; /* remember first character of inferior */ *s = '\0'; /* tie off to get just superior */ /* name doesn't exist, create it */ @@ -842,9 +842,9 @@ long unix_expunge (MAILSTREAM *stream,char *sequence,long options) DOTLOCK lock; char *msg = NIL; /* parse and lock mailbox */ - if (ret = (sequence ? ((options & EX_UID) ? + if ((ret = (sequence ? ((options & EX_UID) ? mail_uid_sequence (stream,sequence) : - mail_sequence (stream,sequence)) : LONGT) && + mail_sequence (stream,sequence)) : LONGT) != 0L) && LOCAL && (LOCAL->ld >= 0) && !stream->lock && unix_parse (stream,&lock,LOCK_EX)) { /* check expunged messages if not dirty */ @@ -1254,10 +1254,10 @@ int unix_append_msgs (MAILSTREAM *stream,FILE *sf,FILE *df,SEARCHSET *set) if (i < (j = strlen (tmp))) fatal ("unix_append_msgs overrun"); i -= j; /* number of bytes left */ /* squish out CRs (note also copies NUL) */ - for (x = tmp; x = strchr (x,'\r'); --j) memmove (x,x+1,j-(x-tmp)); + for (x = tmp; (x = strchr (x,'\r')) != NULL; --j) memmove (x,x+1,j-(x-tmp)); if (!j) continue; /* do nothing if line emptied */ /* start of line? */ - if ((c == '\n')) switch (tmp[0]) { + if (c == '\n') switch (tmp[0]) { case 'F': /* possible "From " (case counts here) */ if ((j > 4) && (tmp[0] == 'F') && (tmp[1] == 'r') && (tmp[2] == 'o') && (tmp[3] == 'm') && (tmp[4] == ' ')) { @@ -1480,7 +1480,7 @@ int unix_parse (MAILSTREAM *stream,DOTLOCK *lock,int op) } /* new data? */ - else if (i = sbuf.st_size - LOCAL->filesize) { + else if ((i = sbuf.st_size - LOCAL->filesize) != 0L) { d.fd = LOCAL->fd; /* yes, set up file descriptor */ d.pos = LOCAL->filesize; /* get to that position in the file */ d.chunk = LOCAL->buf; /* initial buffer chunk */ @@ -1767,7 +1767,7 @@ int unix_parse (MAILSTREAM *stream,DOTLOCK *lock,int op) char err[MAILTMPLEN]; sprintf (err,"Discarding bogus continuation in msg %lu: %.80s", elt->msgno,(char *) s); - if (u = strpbrk (err,"\r\n")) *u = '\0'; + if ((u = strpbrk (err,"\r\n")) != NULL) *u = '\0'; MM_LOG (err,WARN); break; /* different case or something */ } @@ -2012,7 +2012,7 @@ unsigned long unix_xstatus (MAILSTREAM *stream,char *status,MESSAGECACHE *elt, while (n /= 10); /* pop UID last digits from stack */ while (t > stack) *s++ = *--t; - for (n = 0; n < NUSERFLAGS; ++n) if (t = stream->user_flags[n]) + for (n = 0; n < NUSERFLAGS; ++n) if ((t = stream->user_flags[n]) != NULL) for (*s++ = ' '; *t; *s++ = *t++); *s++ = '\n'; pad += 30; /* increased padding if have IMAPbase */ @@ -2034,7 +2034,7 @@ unsigned long unix_xstatus (MAILSTREAM *stream,char *status,MESSAGECACHE *elt, if (sticky) { /* only do this if UIDs sticky */ *s++ = 'X'; *s++ = '-'; *s++ = 'K'; *s++ = 'e'; *s++ = 'y'; *s++ = 'w'; *s++ = 'o'; *s++ = 'r'; *s++ = 'd'; *s++ = 's'; *s++ = ':'; - if (n = elt->user_flags) do { + if ((n = elt->user_flags) != 0L) do { *s++ = ' '; for (t = stream->user_flags[find_rightmost_bit (&n)]; *t; *s++ = *t++); } while (n); @@ -2098,7 +2098,7 @@ long unix_rewrite (MAILSTREAM *stream,unsigned long *nexp,DOTLOCK *lock, size = unix_pseudo (stream,LOCAL->buf); } /* extend the file as necessary */ - if (ret = unix_extend (stream,size)) { + if ((ret = unix_extend (stream,size)) != 0L) { /* Set up buffered I/O file structure * curpos current position being written through buffering * filepos current position being written physically to the disk @@ -2308,7 +2308,7 @@ void unix_write (UNIXFILE *f,char *buf,unsigned long size) if (buf) { /* doing buffered write? */ i = f->bufpos - f->buf; /* yes, get size of current buffer data */ /* yes, have space in current buffer chunk? */ - if (j = i ? ((f->buflen - i) % OVERFLOWBUFLEN) : f->buflen) { + if ((j = i ? ((f->buflen - i) % OVERFLOWBUFLEN) : f->buflen) != 0L) { /* yes, fill up buffer as much as we can */ memcpy (f->bufpos,buf,k = min (j,size)); f->bufpos += k; /* new buffer position */ @@ -2324,7 +2324,7 @@ void unix_write (UNIXFILE *f,char *buf,unsigned long size) * chunks that will fit in unprotected space. */ /* any unprotected space we can write to? */ - if (j = min (i,f->protect - f->filepos)) { + if ((j = min (i,f->protect - f->filepos)) != 0L) { /* yes, filepos not at chunk boundary? */ if ((k = f->filepos % OVERFLOWBUFLEN) && ((k = OVERFLOWBUFLEN - k) < j)) j -= k; /* yes, and can write out partial chunk */ diff --git a/imap/src/tmail/tmail.c b/imap/src/tmail/tmail.c index 923a98a9..273db40a 100644 --- a/imap/src/tmail/tmail.c +++ b/imap/src/tmail/tmail.c @@ -26,6 +26,7 @@ #include <stdio.h> #include <pwd.h> #include <errno.h> +#include <ctype.h> extern int errno; /* just in case */ #include <sysexits.h> #include <sys/file.h> @@ -115,7 +116,7 @@ void file_string_setpos (STRING *s,unsigned long i) s->offset = i; /* set new offset */ s->curpos = s->chunk; /* reset position */ /* set size of data */ - if (s->cursize = min (s->chunksize,SIZE (s))) { + if ((s->cursize = min (s->chunksize,SIZE (s))) != 0L) { /* move to that position in the file */ fseek ((FILE *) s->data,s->offset,SEEK_SET); fread (s->curpos,sizeof (char),(unsigned int) s->cursize,(FILE *) s->data); @@ -600,7 +601,7 @@ int fail (char *string,int code) char *getusername (char *s,char **t) { - if (*t = strchr (s,'+')) { /* have a mailbox specifier? */ + if ((*t = strchr (s,'+')) != NULL) { /* have a mailbox specifier? */ *(*t)++ = '\0'; /* yes, tie off user name */ /* forbid overlong name */ if (strlen (*t) > NETMAXMBX) return NIL; |