Clean up the confusing use of a variable 'i' in inc.c.
The case where it was being used as 'an error occurred
which means we should not truncate the mailspool' is now
called 'incerr' and merged with the equivalent 'p' variable
used in the POP-specific code. Cases where it was being
used as a random temporary are still called 'i' but now
declared with a much more restricted scope.
This fixes a compilation warning for some compilers.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
{
int chgflag = 1, trnflag = 1;
int noisy = 1, width = 0;
{
int chgflag = 1, trnflag = 1;
int noisy = 1, width = 0;
- int i, hghnum = 0, msgnum = 0;
+ int hghnum = 0, msgnum = 0;
+ int incerr = 0; /* <0 if inc hits an error which means it should not truncate mailspool */
char *cp, *maildir = NULL, *folder = NULL;
char *format = NULL, *form = NULL;
char *host = NULL, *port = NULL, *user = NULL, *proxy = NULL;
char *cp, *maildir = NULL, *folder = NULL;
char *format = NULL, *form = NULL;
char *host = NULL, *port = NULL, *user = NULL, *proxy = NULL;
char *maildir_copy = NULL; /* copy of mail directory because the static gets overwritten */
#ifdef POP
char *maildir_copy = NULL; /* copy of mail directory because the static gets overwritten */
#ifdef POP
- int nmsgs, nbytes, p = 0;
char *pass = NULL;
char *MAILHOST_env_variable;
#endif
char *pass = NULL;
char *MAILHOST_env_variable;
#endif
DROPGROUPPRIVS();
if (audfile) {
DROPGROUPPRIVS();
if (audfile) {
if ((i = stat (audfile, &st)) == NOTOK)
advise (NULL, "Creating Receive-Audit: %s", audfile);
if ((aud = fopen (audfile, "a")) == NULL)
if ((i = stat (audfile, &st)) == NOTOK)
advise (NULL, "Creating Receive-Audit: %s", audfile);
if ((aud = fopen (audfile, "a")) == NULL)
#ifdef MHE
if (context_find ("mhe")) {
#ifdef MHE
if (context_find ("mhe")) {
cp = concat (maildir, "/++", NULL);
i = stat (cp, &st);
if ((mhe = fopen (cp, "a")) == NULL)
cp = concat (maildir, "/++", NULL);
i = stat (cp, &st);
if ((mhe = fopen (cp, "a")) == NULL)
* Get the mail from a POP server
*/
if (inc_type == INC_POP) {
* Get the mail from a POP server
*/
if (inc_type == INC_POP) {
if (packfile) {
packfile = path (packfile, TFILE);
if (stat (packfile, &st) == NOTOK) {
if (packfile) {
packfile = path (packfile, TFILE);
if (stat (packfile, &st) == NOTOK) {
adios (cp, "write error on");
fseek (pf, 0L, SEEK_SET);
}
adios (cp, "write error on");
fseek (pf, 0L, SEEK_SET);
}
- switch (p = scan (pf, msgnum, 0, nfs, width,
+ switch (incerr = scan (pf, msgnum, 0, nfs, width,
packfile ? 0 : msgnum == mp->hghmsg + 1 && chgflag,
1, NULL, stop - start, noisy)) {
case SCNEOF:
packfile ? 0 : msgnum == mp->hghmsg + 1 && chgflag,
1, NULL, stop - start, noisy)) {
case SCNEOF:
if (inc_type == INC_FILE) {
m_unknown (in); /* the MAGIC invocation... */
hghnum = msgnum = mp->hghmsg;
if (inc_type == INC_FILE) {
m_unknown (in); /* the MAGIC invocation... */
hghnum = msgnum = mp->hghmsg;
/*
* Check if we need to allocate more space for message status.
* If so, then add space for an additional 100 messages.
/*
* Check if we need to allocate more space for message status.
* If so, then add space for an additional 100 messages.
if (msgnum >= mp->hghoff
&& !(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) {
advise (NULL, "unable to allocate folder storage");
if (msgnum >= mp->hghoff
&& !(mp = folder_realloc (mp, mp->lowoff, mp->hghoff + 100))) {
advise (NULL, "unable to allocate folder storage");
newmsg = folder_addmsg(mp, tmpfilenam);
#endif
/* create scanline for new message */
newmsg = folder_addmsg(mp, tmpfilenam);
#endif
/* create scanline for new message */
- switch (i = scan (in, msgnum + 1, msgnum + 1, nfs, width,
+ switch (incerr = scan (in, msgnum + 1, msgnum + 1, nfs, width,
msgnum == hghnum && chgflag, 1, NULL, 0L, noisy)) {
case SCNFAT:
case SCNEOF:
msgnum == hghnum && chgflag, 1, NULL, 0L, noisy)) {
case SCNFAT:
case SCNEOF:
- advise (NULL, "BUG in %s, scan() botch (%d)", invo_name, i);
+ advise (NULL, "BUG in %s, scan() botch (%d)", invo_name, incerr);
mp->msgflags |= SEQMOD;
continue;
}
mp->msgflags |= SEQMOD;
continue;
}
+ /* If we get here there was some sort of error from scan(),
+ * so stop processing anything more from the spool.
+ */
-#ifdef POP
- if (p < 0) { /* error */
-#else
- if (i < 0) { /* error */
-#endif
+ if (incerr < 0) { /* error */
if (locked) {
GETGROUPPRIVS(); /* Be sure we can unlock mail file */
(void) lkfclose (in, newmail); in = NULL;
if (locked) {
GETGROUPPRIVS(); /* Be sure we can unlock mail file */
(void) lkfclose (in, newmail); in = NULL;
if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime)
advise (NULL, "new messages have arrived!\007");
else {
if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime)
advise (NULL, "new messages have arrived!\007");
else {
- if ((i = creat (newmail, 0600)) != NOTOK)
- close (i);
+ int newfd;
+ if ((newfd = creat (newmail, 0600)) != NOTOK)
+ close (newfd);
else
admonish (newmail, "error zero'ing");
unlink(map_name(newmail));
else
admonish (newmail, "error zero'ing");
unlink(map_name(newmail));