From: David Levine Date: Sat, 14 Jan 2012 20:49:57 +0000 (-0600) Subject: Changed types and added casts so that build is clean with gcc -Wsign-compare. X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=13ae9ba066e6b8c114daa6714895a56816465f49;p=mmh Changed types and added casts so that build is clean with gcc -Wsign-compare. --- diff --git a/mts/smtp/hosts.c b/mts/smtp/hosts.c index 94287b5..29ac6d8 100644 --- a/mts/smtp/hosts.c +++ b/mts/smtp/hosts.c @@ -43,7 +43,7 @@ OfficialName (char *name) char **r; struct host *h; - for (p = name, q = site; *p && (q - site < sizeof(site) - 1); p++, q++) + for (p = name, q = site; *p && (q - site < (int)sizeof(site) - 1); p++, q++) *q = isupper (*p) ? tolower (*p) : *p; *q = '\0'; q = site; diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index a99d9aa..7d1350e 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -312,7 +312,7 @@ adrsprintf (char *username, char *domain) "%s%s", username, extension); if (snprintf_return < 0 || - snprintf_return >= sizeof(username_with_extension)) + snprintf_return >= (int) sizeof(username_with_extension)) adios(NULL, "snprintf() error writing username (%d chars) and" " $USERNAME_EXTENSION (%d chars) to array of BUFSIZ (%d)" " chars", @@ -329,7 +329,7 @@ adrsprintf (char *username, char *domain) snprintf_return = snprintf (addr, sizeof(addr), "%s@%s", username, domain); - if (snprintf_return < 0 || snprintf_return >= sizeof(addr)) + if (snprintf_return < 0 || snprintf_return >= (int) sizeof(addr)) adios(NULL, "snprintf() error writing username (%d chars), domain (%d" " chars), and 1 separator char to array of BUFSIZ (%d) chars", strlen(username), strlen(domain), BUFSIZ); diff --git a/sbr/fdcompare.c b/sbr/fdcompare.c index 38174e0..db4838f 100644 --- a/sbr/fdcompare.c +++ b/sbr/fdcompare.c @@ -23,12 +23,12 @@ fdcompare (int fd1, int fd2) && n1 == n2) { c1 = b1; c2 = b2; - for (i = n1 < sizeof(b1) ? n1 : sizeof(b1); i--;) + for (i = n1 < (int) sizeof(b1) ? n1 : (int) sizeof(b1); i--;) if (*c1++ != *c2++) { resp = 0; goto leave; } - if (n1 < sizeof(b1)) + if (n1 < (int) sizeof(b1)) goto leave; } resp = 0; diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index f643421..b4e8bcb 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -316,7 +316,7 @@ int fmt_compile(char *fstring, struct format **fmt) { register char *cp; - int i; + size_t i; if (format_string) free (format_string); diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 574eeb3..de20013 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -508,13 +508,13 @@ fmt_scan (struct format *format, char *scanl, int width, int *dat) ljust++; } - if (!ljust && i > 0 && strlen(str) > i) + if (!ljust && i > 0 && (int) strlen(str) > i) str[i] = '\0'; xp = str; xp += strlen(str) - 1; while (xp > str && isspace(*xp)) *xp-- = '\0'; - if (ljust && i > 0 && strlen(str) > i) + if (ljust && i > 0 && (int) strlen(str) > i) str += strlen(str) - i; } break; diff --git a/sbr/m_convert.c b/sbr/m_convert.c index 1696190..c88747f 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -263,10 +263,10 @@ m_conv (struct msgs *mp, char *str, int call) #ifdef LOCALE /* doesn't enforce lower case */ for (bp = buf; (isalpha(*cp) || *cp == '.') - && (bp - buf < sizeof(buf) - 1); ) + && (bp - buf < (int) sizeof(buf) - 1); ) #else for (bp = buf; ((*cp >= 'a' && *cp <= 'z') || *cp == '.') - && (bp - buf < sizeof(buf) - 1); ) + && (bp - buf < (int) sizeof(buf) - 1); ) #endif /* LOCALE */ { *bp++ = *cp++; diff --git a/sbr/pidstatus.c b/sbr/pidstatus.c index b7aad79..fab90d5 100644 --- a/sbr/pidstatus.c +++ b/sbr/pidstatus.c @@ -50,7 +50,8 @@ pidstatus (int status, FILE *fp, char *cp) if (cp) fprintf (fp, "%s: ", cp); fprintf (fp, "signal %d", signum); - if (signum >= 0 && signum < sizeof(sigmsg) && sigmsg[signum] != NULL) + if (signum >= 0 && signum < (int) sizeof(sigmsg) && + sigmsg[signum] != NULL) fprintf (fp, " (%s%s)\n", sigmsg[signum], WCOREDUMP(status) ? ", core dumped" : ""); else diff --git a/sbr/seq_add.c b/sbr/seq_add.c index 68fa724..0bdcfdf 100644 --- a/sbr/seq_add.c +++ b/sbr/seq_add.c @@ -25,7 +25,8 @@ int seq_addsel (struct msgs *mp, char *cp, int public, int zero) { - int i, msgnum, new_seq = 1; + unsigned int i; + int msgnum, new_seq = 1; if (!seq_nameok (cp)) return 0; @@ -117,7 +118,8 @@ seq_addsel (struct msgs *mp, char *cp, int public, int zero) int seq_addmsg (struct msgs *mp, char *cp, int msgnum, int public, int zero) { - int i, j, new_seq = 1; + unsigned int i; + int j, new_seq = 1; if (!seq_nameok (cp)) return 0; diff --git a/sbr/seq_del.c b/sbr/seq_del.c index eb41ec4..8c353f3 100644 --- a/sbr/seq_del.c +++ b/sbr/seq_del.c @@ -25,7 +25,8 @@ int seq_delsel (struct msgs *mp, char *cp, int public, int zero) { - int i, msgnum, new_seq = 1; + unsigned int i; + int msgnum, new_seq = 1; if (!seq_nameok (cp)) return 0; diff --git a/sbr/seq_read.c b/sbr/seq_read.c index e349121..985c61e 100644 --- a/sbr/seq_read.c +++ b/sbr/seq_read.c @@ -158,7 +158,8 @@ seq_private (struct msgs *mp) static int seq_init (struct msgs *mp, char *name, char *field) { - int i, j, k, is_current; + unsigned int i; + int j, k, is_current; char *cp, **ap; /* diff --git a/uip/aliasbr.c b/uip/aliasbr.c index 50a2cd5..b2e51f5 100644 --- a/uip/aliasbr.c +++ b/uip/aliasbr.c @@ -409,7 +409,7 @@ addall (struct aka *ak) Everyone = EVERYONE; for (hm = homehead; hm; hm = hm->h_next) - if (hm->h_uid > Everyone + if ((int) hm->h_uid > Everyone && (noshell || strcmp (hm->h_shell, NoShell))) add_aka (ak, hm->h_name); @@ -556,7 +556,9 @@ seek_home (char *name) * The only place where there might be problems. * This assumes that ALL usernames are kept in lowercase. */ - for (c = name, c1 = lname; *c && (c1 - lname < sizeof(lname) - 1); c++, c1++) { + for (c = name, c1 = lname; + *c && (c1 - lname < (int) sizeof(lname) - 1); + c++, c1++) { if (isalpha(*c) && isupper(*c)) *c1 = tolower (*c); else diff --git a/uip/annosbr.c b/uip/annosbr.c index 87e9580..5b9fff4 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -183,7 +183,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, int datesw, in int length; /* length of field name */ int n; /* number of bytes written */ - mode = fstat (fd, &st) != NOTOK ? (st.st_mode & 0777) : m_gmprot (); + mode = fstat (fd, &st) != NOTOK ? (int) (st.st_mode & 0777) : m_gmprot (); strncpy (tmpfil, m_mktemp2(file, "annotate", NULL, &tmp), sizeof(tmpfil)); chmod (tmpfil, mode); diff --git a/uip/burst.c b/uip/burst.c index fa3ac73..89aeac2 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -267,7 +267,8 @@ burst (struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, if ((in = fopen (msgnam = m_name (msgnum), "r")) == NULL) adios (msgnam, "unable to read message"); - mode = fstat (fileno(in), &st) != NOTOK ? (st.st_mode & 0777) : m_gmprot(); + mode = + fstat (fileno(in), &st) != NOTOK ? (int) (st.st_mode & 0777) : m_gmprot(); mp = *mpp; /* diff --git a/uip/dropsbr.c b/uip/dropsbr.c index 11ceba8..7771b6b 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -140,13 +140,12 @@ mbx_chk_mbox (int fd) static int mbx_chk_mmdf (int fd) { - size_t count; + ssize_t count; char ldelim[BUFSIZ]; count = strlen (mmdlm2); - /* casting -count to off_t, seem to break FreeBSD 2.2.6 */ - if (lseek (fd, (long) (-count), SEEK_END) == (off_t) NOTOK) + if (lseek (fd, -count, SEEK_END) == (off_t) NOTOK) return NOTOK; if (read (fd, ldelim, count) != count) return NOTOK; @@ -518,7 +517,8 @@ map_read (char *file, long pos, struct drop **drops, int noisy) memcpy((char *) dp, (char *) mp, sizeof(*dp)); lseek (md, (off_t) sizeof(*mp), SEEK_SET); - if ((i = read (md, (char *) (dp + 1), msgp * sizeof(*dp))) < sizeof(*dp)) { + if ((i = read (md, (char *) (dp + 1), msgp * sizeof(*dp))) < + (int) sizeof(*dp)) { i = 0; free ((char *) dp); } else { @@ -651,7 +651,7 @@ map_open (char *file, int md) mode_t mode; struct stat st; - mode = fstat (md, &st) != NOTOK ? (mode_t) (st.st_mode & 0777) : m_gmprot (); + mode = fstat (md, &st) != NOTOK ? (int) (st.st_mode & 0777) : m_gmprot (); return mbx_open (file, OTHER_FORMAT, st.st_uid, st.st_gid, mode); } @@ -659,7 +659,7 @@ map_open (char *file, int md) int map_chk (char *file, int fd, struct drop *dp, long pos, int noisy) { - long count; + ssize_t count; struct drop d, tmpd; register struct drop *dl; @@ -700,7 +700,7 @@ map_chk (char *file, int fd, struct drop *dp, long pos, int noisy) } dl = &d; - count = (long) strlen (mmdlm2); + count = strlen (mmdlm2); lseek (fd, (off_t) (dp->d_id * sizeof(*dp)), SEEK_SET); if (read (fd, (char *) dl, sizeof(*dl)) != sizeof(*dl) || (ntohl(dl->d_stop) != dp->d_stop diff --git a/uip/flist.c b/uip/flist.c index e3da709..d46f7ba 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -74,7 +74,7 @@ static struct Folder *orders = NULL; static int nOrders = 0; static int nOrdersAlloced = 0; static struct Folder *folders = NULL; -static int nFolders = 0; +static unsigned int nFolders = 0; static int nFoldersAlloced = 0; /* info on folders to search */ @@ -84,7 +84,7 @@ static int maxfolders; /* info on sequences to search for */ static char *sequencesToDo[NUMATTRS]; -static int numsequences; +static unsigned int numsequences; static int all = FALSE; /* scan all folders in top level? */ static int alphaOrder = FALSE; /* want alphabetical order only */ @@ -464,7 +464,8 @@ BuildFolderListRecurse(char *dirName, struct stat *s, int searchdepth) int AddFolder(char *name, int force) { - int i, msgnum, nonzero; + unsigned int i; + int msgnum, nonzero; int seqnum[NUMATTRS], nSeq[NUMATTRS]; struct Folder *f; struct msgs *mp; @@ -534,8 +535,8 @@ void PrintFolders(void) { char tmpname[BUFSIZ]; - int i, j, len, has_private = 0; - int maxfolderlen = 0, maxseqlen = 0; + unsigned int i, j, len, has_private = 0; + unsigned int maxfolderlen = 0, maxseqlen = 0; int maxnum = 0, maxseq = 0; if (!Total) { diff --git a/uip/forw.c b/uip/forw.c index 8b5e008..112b083 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -500,8 +500,9 @@ mhl_draft (int out, char *digest, int volume, int issue, * handle about 995 messages (because vec is fixed size), * but that should be plenty. */ - for (msgnum = mp->lowsel; msgnum <= mp->hghsel && i < sizeof(vec) - 1; - msgnum++) + for (msgnum = mp->lowsel; + msgnum <= mp->hghsel && i < (int) sizeof(vec) - 1; + msgnum++) if (is_selected (mp, msgnum)) vec[i++] = getcpy (m_name (msgnum)); vec[i] = NULL; diff --git a/uip/mark.c b/uip/mark.c index dd09b48..6ffc2b1 100644 --- a/uip/mark.c +++ b/uip/mark.c @@ -49,8 +49,8 @@ int main (int argc, char **argv) { int addsw = 0, deletesw = 0, debugsw = 0; - int listsw = 0, publicsw = -1, zerosw = 0; - int seqp = 0, msgnum; + int listsw = 0, publicsw = -1, zerosw = 0, msgnum; + unsigned int seqp = 0; char *cp, *maildir, *folder = NULL, buf[BUFSIZ]; char **argp, **arguments; char *seqs[NUMATTRS + 1]; diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index 68a265d..16325bf 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -218,13 +218,13 @@ static int mhldebug = 0; static int ontty = NOTTY; static int row; -static int column; +static unsigned int column; static int lm; static int llim; static int ovoff; static int term; -static int wid; +static unsigned int wid; static char *ovtxt; @@ -1275,9 +1275,9 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag) if (cchdr) { if (flag == TWOCOMP) count = (c1->c_cwidth >= 0) ? c1->c_cwidth - : strlen (c2->c_name) + 2; + : (int) strlen (c2->c_name) + 2; else - count = (c1->c_cwidth >= 0) ? c1->c_cwidth + count = (c1->c_cwidth >= 0) ? (size_t) c1->c_cwidth : strlen (c1->c_text ? c1->c_text : c1->c_name) + 2; } count += c1->c_offset; diff --git a/uip/mhmail.c b/uip/mhmail.c index 990776c..f5e5384 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -44,7 +44,8 @@ int main (int argc, char **argv) { pid_t child_id; - int status, i, iscc = 0, nvec; + int status, iscc = 0, nvec; + size_t i; int queued = 0, resent = 0, somebody; char *cp, *tolist = NULL, *cclist = NULL, *subject = NULL; char *from = NULL, *body = NULL, **argp, **arguments; diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index 2651452..72e7bd4 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -430,7 +430,7 @@ writeBase64 (CT ct, FILE *out) int writeBase64aux (FILE *in, FILE *out) { - int cc, n; + unsigned int cc, n; char inbuf[3]; n = BPERLIN; diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 44371f1..6f511f3 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -469,7 +469,8 @@ raw: } } - if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) { + if (buflen <= 0 || + (ct->c_termproc && (size_t) buflen <= strlen(ct->c_termproc))) { /* content_error would provide a more useful error message * here, except that if we got overrun, it probably would * too. @@ -984,7 +985,8 @@ raw: } } - if (buflen <= 0 || (ct->c_termproc && buflen <= strlen(ct->c_termproc))) { + if (buflen <= 0 || + (ct->c_termproc && (size_t) buflen <= strlen(ct->c_termproc))) { /* content_error would provide a more useful error message * here, except that if we got overrun, it probably would * too. diff --git a/uip/mshcmds.c b/uip/mshcmds.c index b46f753..cec475e 100644 --- a/uip/mshcmds.c +++ b/uip/mshcmds.c @@ -1126,7 +1126,8 @@ void markcmd (char **args) { int addsw = 0, deletesw = 0, debugsw = 0; - int listsw = 0, zerosw = 0, seqp = 0; + int listsw = 0, zerosw = 0; + size_t seqp = 0; int msgp = 0, msgnum; char *cp, buf[BUFSIZ]; char *seqs[NUMATTRS + 1], *msgs[MAXARGS]; @@ -1635,7 +1636,8 @@ static struct swit pickswit[] = { void pickcmd (char **args) { - int zerosw = 1, msgp = 0, seqp = 0; + int zerosw = 1, msgp = 0; + size_t seqp = 0; int vecp = 0, hi, lo, msgnum; char *cp, buf[BUFSIZ], *msgs[MAXARGS]; char *seqs[NUMATTRS], *vec[MAXARGS]; diff --git a/uip/pick.c b/uip/pick.c index 24e6862..bd17c45 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -71,7 +71,8 @@ static void putzero_done (int) NORETURN; int main (int argc, char **argv) { - int publicsw = -1, zerosw = 1, seqp = 0, vecp = 0; + int publicsw = -1, zerosw = 1, vecp = 0; + size_t seqp = 0; int lo, hi, msgnum; char *maildir, *folder = NULL, buf[100]; char *cp, **argp, **arguments; diff --git a/uip/rcvstore.c b/uip/rcvstore.c index 3131076..57091b4 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -53,7 +53,8 @@ main (int argc, char **argv) { int publicsw = -1, zerosw = 0; int create = 1, unseensw = 1; - int fd, msgnum, seqp = 0; + int fd, msgnum; + size_t seqp = 0; char *cp, *maildir, *folder = NULL, buf[BUFSIZ]; char **argp, **arguments, *seqs[NUMATTRS+1]; struct msgs *mp; diff --git a/uip/sortm.c b/uip/sortm.c index cfad3d3..9e8da9f 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -45,7 +45,7 @@ static struct smsg *smsgs; int nmsgs; char *subjsort = (char *) 0; /* sort on subject if != 0 */ -unsigned long datelimit = 0; +time_t datelimit = 0; int submajor = 0; /* if true, sort on subject-major */ int verbose;