From d5b5e6e4813b7fd77dc1664df4304537f3002cf3 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Tue, 27 Mar 2012 10:09:19 +0200 Subject: [PATCH] Changed types and added casts so that build is clean with gcc -Wsign-compare. Pulled in from nmh. Thanks to David Levine. --- sbr/fmt_compile.c | 2 +- sbr/fmt_scan.c | 4 ++-- sbr/m_convert.c | 2 +- sbr/pidstatus.c | 3 ++- sbr/seq_add.c | 6 ++++-- sbr/seq_del.c | 3 ++- sbr/seq_read.c | 3 ++- uip/aliasbr.c | 2 +- uip/anno.c | 2 +- uip/burst.c | 2 +- uip/comp.c | 2 +- uip/dist.c | 2 +- uip/dropsbr.c | 2 +- uip/flist.c | 11 ++++++----- uip/forw.c | 2 +- uip/mark.c | 4 ++-- uip/mhl.c | 12 ++++++------ uip/mhmail.c | 3 ++- uip/mhoutsbr.c | 2 +- uip/mhshowsbr.c | 7 ++++--- uip/pick.c | 3 ++- uip/rcvstore.c | 3 ++- uip/sortm.c | 2 +- 23 files changed, 47 insertions(+), 37 deletions(-) diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index 435740e..dd0b52a 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -302,7 +302,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 94285a6..5103dbd 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -475,13 +475,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 734bdb5..85d4e58 100644 --- a/sbr/m_convert.c +++ b/sbr/m_convert.c @@ -272,7 +272,7 @@ m_conv(struct msgs *mp, char *str, int call) return BADNUM; } - for (bp = buf; isalpha(*cp) && (bp - buf < sizeof(buf) - 1); ) { + for (bp = buf; isalpha(*cp) && (bp - buf < (int)sizeof(buf) - 1); ) { *bp++ = *cp++; } *bp++ = '\0'; diff --git a/sbr/pidstatus.c b/sbr/pidstatus.c index 5886ffc..c4e1e75 100644 --- a/sbr/pidstatus.c +++ b/sbr/pidstatus.c @@ -49,7 +49,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 b122809..7fa7558 100644 --- a/sbr/seq_add.c +++ b/sbr/seq_add.c @@ -24,7 +24,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; @@ -116,7 +117,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 e342d1c..5555f11 100644 --- a/sbr/seq_del.c +++ b/sbr/seq_del.c @@ -24,7 +24,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 5707dae..bfecaf0 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 6a68c51..8b32826 100644 --- a/uip/aliasbr.c +++ b/uip/aliasbr.c @@ -525,7 +525,7 @@ 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); + for (c = name, c1 = lname; *c && (c1 - lname < (int)sizeof(lname) - 1); c++, c1++) { if (isalpha(*c) && isupper(*c)) *c1 = tolower(*c); diff --git a/uip/anno.c b/uip/anno.c index d03c99c..b1d8667 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -429,7 +429,7 @@ annosbr(int fd, char *file, char *comp, char *text, int datesw, int delete, int length; 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)); diff --git a/uip/burst.c b/uip/burst.c index fdc78f4..d0d06b6 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -260,7 +260,7 @@ burst(struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, adios(msgnam, "unable to read message"); mode = fstat(fileno(in), &st) != NOTOK ? - (st.st_mode & 0777) : m_gmprot(); + (int)(st.st_mode & 0777) : m_gmprot(); mp = *mpp; /* diff --git a/uip/comp.c b/uip/comp.c index a9d2543..87953ad 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -169,7 +169,7 @@ main(int argc, char **argv) if ((out = creat(drft, m_gmprot())) == NOTOK) { adios(drft, "unable to create"); } - if (write(out, fmtstr, strlen(fmtstr)) != strlen(fmtstr)) { + if (write(out, fmtstr, strlen(fmtstr)) != (int)strlen(fmtstr)) { adios(drft, "error writing"); } close(out); diff --git a/uip/dist.c b/uip/dist.c index 4eba2eb..dabfec7 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -127,7 +127,7 @@ main(int argc, char **argv) adios(drft, "unable to create"); fmtstr = new_fs(form, distcomps); - if (write(out, fmtstr, strlen(fmtstr)) != strlen(fmtstr)) { + if (write(out, fmtstr, strlen(fmtstr)) != (int)strlen(fmtstr)) { adios(drft, "error writing"); } close(out); diff --git a/uip/dropsbr.c b/uip/dropsbr.c index 124e5ab..3c3e105 100644 --- a/uip/dropsbr.c +++ b/uip/dropsbr.c @@ -169,7 +169,7 @@ mbox_copy(int to, int from) if (i != 0 && strncmp(buffer, "From ", 5) == 0) { write(to, ">", 1); } - if (write(to, buffer, strlen(buffer)) != strlen(buffer)) { + if (write(to, buffer, strlen(buffer)) != (int)strlen(buffer)) { fclose(fp); return NOTOK; } diff --git a/uip/flist.c b/uip/flist.c index c69055a..9302a8a 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -71,7 +71,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 */ @@ -81,7 +81,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 */ @@ -457,7 +457,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; @@ -529,8 +530,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 e79e395..53b0968 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -238,7 +238,7 @@ main(int argc, char **argv) close(in); } else { fmtstr = new_fs(form, forwcomps); - if (write(out, fmtstr, strlen(fmtstr)) != strlen(fmtstr)) { + if (write(out, fmtstr, strlen(fmtstr)) != (int)strlen(fmtstr)) { adios(drft, "error writing"); } } diff --git a/uip/mark.c b/uip/mark.c index 79763ff..1917e84 100644 --- a/uip/mark.c +++ b/uip/mark.c @@ -48,8 +48,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/mhl.c b/uip/mhl.c index 321c5f9..c78619e 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -178,12 +178,12 @@ static int mhldebug = 0; #define NOTTY 0 static int ontty = NOTTY; -static int column; +static unsigned int column; static int lm; static int ovoff; static int term; -static int wid; +static unsigned int wid; static char *ovtxt; @@ -1082,11 +1082,11 @@ putcomp(struct mcomp *c1, struct mcomp *c2, int flag) count = 0; if (cchdr) { if (flag == TWOCOMP) - count = (c1->c_cwidth >= 0) ? - c1->c_cwidth : strlen(c2->c_name) + 2; + count = (c1->c_cwidth >= 0) ? c1->c_cwidth : + (int)strlen(c2->c_name) + 2; else - count = (c1->c_cwidth >= 0) ? - c1->c_cwidth : strlen(c1->c_text ? + 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 6a77d50..2ab9cfd 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -45,7 +45,8 @@ int main(int argc, char **argv) { pid_t child_id; - int status, i, iscc = 0, nvec; + int status, iscc = 0, nvec; + unsigned int 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 f82cc6c..130b4e5 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -429,7 +429,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 ea9f72e..d3ddb94 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -449,7 +449,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 @@ -948,8 +949,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 diff --git a/uip/pick.c b/uip/pick.c index 896c37b..3fb853c 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -81,7 +81,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; + unsigned int 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 04b62d8..fc98b4a 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -51,7 +51,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 125991c..6ba8a9c 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -44,7 +44,7 @@ static struct smsg *smsgs; int nmsgs; char *subjsort = NULL; /* sort on subject if != 0 */ -unsigned long datelimit = 0; +time_t datelimit = 0; int submajor = 0; /* if true, sort on subject-major */ int verbose; -- 1.7.10.4