From ac813896ca32d850febc2d95065ac4fa040f11f9 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 13 Nov 2006 11:20:19 +0100 Subject: [PATCH] a whole lot of size_t -> ssize_t. remove old cruft too. Signed-off-by: Pierre Habouzit --- base64.c | 4 +- browser.c | 20 ++--- browser.h | 4 +- charset.c | 52 +++++------ charset.h | 6 +- commands.c | 2 +- complete.c | 6 +- compose.c | 8 +- editmsg.c | 2 +- from.c | 6 +- hcache.c | 4 +- hdrline.c | 12 +-- headers.c | 2 +- help.c | 20 ++--- hook.c | 12 +-- imap/browse.c | 4 +- imap/imap.c | 4 +- imap/imap_private.h | 2 +- imap/message.c | 14 +-- imap/message.h | 4 +- imap/utf7.c | 4 +- imap/util.c | 4 +- init.c | 144 +++++++++++++++---------------- lib-crypt/crypt-gpgme.c | 70 +++++++-------- lib-crypt/pgp.c | 2 +- lib-crypt/pgpinvoke.c | 15 ++-- lib-crypt/pgpkey.c | 31 +++---- lib-crypt/pgppacket.c | 2 +- lib-crypt/smime.c | 59 ++++++------- lib-lib/buffer.c | 4 +- lib-lib/buffer.h | 4 +- lib-lib/file.c | 10 +-- lib-lib/file.h | 4 +- lib-sys/mutt_socket.c | 6 +- lib-sys/mutt_socket.h | 10 +-- lib-sys/mutt_ssl_gnutls.c | 18 ++-- lib-ui/curs_lib.c | 43 +++++---- main.c | 36 ++++---- mh.c | 4 +- mutt_sasl.c | 8 +- mutt_sasl.h | 4 +- muttlib.c | 32 +++---- mx.c | 14 +-- nntp/newsrc.c | 52 +++++------ nntp/nntp.c | 10 +-- nntp/nntp.h | 8 +- pattern.c | 2 +- pop/pop.c | 30 +++---- pop/pop.h | 2 +- pop/pop_auth.c | 12 +-- pop/pop_lib.c | 28 +++--- postpone.c | 2 +- protos.h | 177 ++++++++------------------------------ query.c | 12 +-- recvattach.c | 4 +- recvattach.h | 2 +- rfc1524.c | 23 ++--- rfc1524.h | 2 +- sendlib.c | 70 +++++++-------- 59 files changed, 512 insertions(+), 640 deletions(-) diff --git a/base64.c b/base64.c index 0b72009..a5e6cf3 100644 --- a/base64.c +++ b/base64.c @@ -48,8 +48,8 @@ #include "mutt.h" /* raw bytes to null-terminated base 64 string */ -void mutt_to_base64 (unsigned char *out, const unsigned char *in, size_t len, - size_t olen) +void mutt_to_base64 (unsigned char *out, const unsigned char *in, ssize_t len, + ssize_t olen) { while (len >= 3 && olen > 10) { *out++ = __m_b64chars[in[0] >> 2]; diff --git a/browser.c b/browser.c index c6ee31b..69351d0 100644 --- a/browser.c +++ b/browser.c @@ -77,7 +77,7 @@ static char LastDirBackup[_POSIX_PATH_MAX] = ""; /* Frees up the memory allocated for the local-global variables. */ static void destroy_state (struct browser_state *state) { - unsigned int c; + int c; for (c = 0; c < state->entrylen; c++) { p_delete(&((state->entry)[c].name)); @@ -160,7 +160,7 @@ static int link_is_dir (const char *folder, const char *path) return 0; } -static const char *folder_format_str (char *dest, size_t destlen, char op, +static const char *folder_format_str (char *dest, ssize_t destlen, char op, const char *src, const char *fmt, const char *ifstring, const char *elsestring, @@ -324,7 +324,7 @@ static const char *folder_format_str (char *dest, size_t destlen, char op, } #ifdef USE_NNTP -static const char *newsgroup_format_str (char *dest, size_t destlen, char op, +static const char *newsgroup_format_str (char *dest, ssize_t destlen, char op, const char *src, const char *fmt, const char *ifstring, const char *elsestring, @@ -653,7 +653,7 @@ static int select_file_search (MUTTMENU * menu, regex_t * re, int n) (re, ((struct folder_file *) menu->data)[n].name, 0, NULL, 0)); } -static void folder_entry (char *s, size_t slen, MUTTMENU * menu, int num) +static void folder_entry (char *s, ssize_t slen, MUTTMENU * menu, int num) { FOLDER folder; @@ -671,7 +671,7 @@ static void folder_entry (char *s, size_t slen, MUTTMENU * menu, int num) } static void init_menu (struct browser_state *state, MUTTMENU * menu, - char *title, size_t titlelen, int buffy) + char *title, ssize_t titlelen, int buffy) { char path[_POSIX_PATH_MAX]; @@ -729,7 +729,7 @@ static int file_tag (MUTTMENU * menu, int n, int m) return ff->tagged - ot; } -void _mutt_select_file (char *f, size_t flen, int flags, char ***files, +void _mutt_select_file (char *f, ssize_t flen, int flags, char ***files, int *numfiles) { char buf[_POSIX_PATH_MAX]; @@ -918,7 +918,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, url_parse_ciss (&url, state.entry[menu->current].name); if (url.path && (state.entry[menu->current].delim != '\0') && - (n < sizeof (LastDir))) { + (n < ssizeof (LastDir))) { LastDir[n] = '\0'; LastDir[n - 1] = state.entry[menu->current].delim; } @@ -981,7 +981,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (multiple) { char **tfiles; int j; - unsigned int h; + int h; if (menu->tagged) { *numfiles = menu->tagged; @@ -1112,9 +1112,9 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (!state.imap_browse) { /* add '/' at the end of the directory name if not already there */ - size_t len = m_strlen(LastDir); + ssize_t len = m_strlen(LastDir); - if (len && LastDir[len - 1] != '/' && sizeof (buf) > len) + if (len && LastDir[len - 1] != '/' && ssizeof(buf) > len) buf[len] = '/'; } diff --git a/browser.h b/browser.h index 5edd06f..91764b6 100644 --- a/browser.h +++ b/browser.h @@ -37,8 +37,8 @@ struct folder_file { struct browser_state { struct folder_file *entry; - unsigned int entrylen; /* number of real entries */ - unsigned int entrymax; /* max entry */ + int entrylen; /* number of real entries */ + int entrymax; /* max entry */ short imap_browse; char *folder; unsigned noselect:1; diff --git a/charset.c b/charset.c index 08c4b0f..0652ffc 100644 --- a/charset.c +++ b/charset.c @@ -212,9 +212,9 @@ void mutt_set_langinfo_charset (void) #endif -void mutt_canonical_charset (char *dest, size_t dlen, const char *name) +void mutt_canonical_charset (char *dest, ssize_t dlen, const char *name) { - size_t i; + ssize_t i; char *p; char scratch[LONG_STRING]; @@ -297,19 +297,19 @@ iconv_t mutt_iconv_open (const char *tocode, const char *fromcode, int flags) * if you're supplying an outrepl, the target charset should be. */ -size_t mutt_iconv (iconv_t cd, const char **inbuf, size_t * inbytesleft, - char **outbuf, size_t * outbytesleft, +ssize_t mutt_iconv(iconv_t cd, const char **inbuf, ssize_t *inbytesleft, + char **outbuf, ssize_t *outbytesleft, const char **inrepls, const char *outrepl) { - size_t ret = 0, ret1; + ssize_t ret = 0, ret1; const char *ib = *inbuf; - size_t ibl = *inbytesleft; + ssize_t ibl = *inbytesleft; char *ob = *outbuf; - size_t obl = *outbytesleft; + ssize_t obl = *outbytesleft; for (;;) { ret1 = my_iconv(cd, &ib, &ibl, &ob, &obl); - if (ret1 != (size_t) - 1) + if (ret1 != -1) ret += ret1; if (ibl && obl && errno == EILSEQ) { if (inrepls) { @@ -318,9 +318,9 @@ size_t mutt_iconv (iconv_t cd, const char **inbuf, size_t * inbytesleft, for (t = inrepls; *t; t++) { const char *ib1 = *t; - size_t ibl1 = m_strlen(*t); + ssize_t ibl1 = m_strlen(*t); char *ob1 = ob; - size_t obl1 = obl; + ssize_t obl1 = obl; my_iconv(cd, &ib1, &ibl1, &ob1, &obl1); if (!ibl1) { @@ -338,7 +338,7 @@ size_t mutt_iconv (iconv_t cd, const char **inbuf, size_t * inbytesleft, outrepl = "?"; my_iconv(cd, 0, 0, &ob, &obl); if (obl) { - size_t n = m_strlen(outrepl); + ssize_t n = m_strlen(outrepl); if (n > obl) { outrepl = "?"; @@ -378,7 +378,7 @@ int mutt_convert_string (char **ps, const char *from, const char *to, int len; const char *ib; char *buf, *ob; - size_t ibl, obl; + ssize_t ibl, obl; const char **inrepls = NULL; const char *outrepl = NULL; @@ -421,7 +421,7 @@ struct fgetconv_s { char *p; char *ob; char *ib; - size_t ibl; + ssize_t ibl; const char **inrepls; }; @@ -454,10 +454,10 @@ FGETCONV *fgetconv_open (FILE * file, const char *from, const char *to, return (FGETCONV *) fc; } -char *fgetconvs (char *buf, size_t l, FGETCONV * _fc) +char *fgetconvs (char *buf, ssize_t l, FGETCONV * _fc) { int c; - size_t r; + ssize_t r; for (r = 0; r + 1 < l;) { if ((c = fgetconv (_fc)) == EOF) @@ -490,7 +490,7 @@ int fgetconv (FGETCONV * _fc) /* Try to convert some more */ fc->p = fc->ob = fc->bufo; if (fc->ibl) { - size_t obl = sizeof (fc->bufo); + ssize_t obl = ssizeof(fc->bufo); my_iconv(fc->cd, (const char **) &fc->ib, &fc->ibl, &fc->ob, &obl); if (fc->p < fc->ob) @@ -514,7 +514,7 @@ int fgetconv (FGETCONV * _fc) /* Try harder this time to convert some */ if (fc->ibl) { - size_t obl = sizeof (fc->bufo); + ssize_t obl = ssizeof(fc->bufo); mutt_iconv (fc->cd, (const char **) &fc->ib, &fc->ibl, &fc->ob, &obl, fc->inrepls, 0); @@ -550,19 +550,19 @@ const char *mutt_get_first_charset (const char *charset) return fcharset; } -static size_t convert_string (const char *f, size_t flen, +static ssize_t convert_string (const char *f, ssize_t flen, const char *from, const char *to, - char **t, size_t * tlen) + char **t, ssize_t * tlen) { iconv_t cd; char *buf, *ob; - size_t obl; + ssize_t obl; ssize_t n; int e; cd = mutt_iconv_open (to, from, 0); if (cd == (iconv_t) (-1)) - return (size_t) (-1); + return -1; obl = 4 * flen + 1; ob = buf = xmalloc(obl); n = my_iconv(cd, &f, &flen, &ob, &obl); @@ -571,7 +571,7 @@ static size_t convert_string (const char *f, size_t flen, p_delete(&buf); iconv_close (cd); errno = e; - return (size_t) (-1); + return -1; } *ob = '\0'; @@ -592,9 +592,9 @@ int mutt_convert_nonmime_string (char **ps) char *u = *ps; char *s = NULL; char *fromcode; - size_t m, n; - size_t ulen = m_strlen(*ps); - size_t slen; + ssize_t m, n; + ssize_t ulen = m_strlen(*ps); + ssize_t slen; if (!u || !*u) return 0; @@ -606,7 +606,7 @@ int mutt_convert_nonmime_string (char **ps) fromcode = p_dupstr(c, n); m = convert_string (u, ulen, fromcode, Charset, &s, &slen); p_delete(&fromcode); - if (m != (size_t) (-1)) { + if (m != -1) { p_delete(ps); *ps = s; return 0; diff --git a/charset.h b/charset.h index 738cd73..fd85199 100644 --- a/charset.h +++ b/charset.h @@ -41,14 +41,14 @@ const char *mutt_get_first_charset (const char *); int mutt_convert_nonmime_string (char **); iconv_t mutt_iconv_open (const char *, const char *, int); -size_t mutt_iconv (iconv_t, const char **, size_t *, char **, size_t *, - const char **, const char *); +ssize_t mutt_iconv (iconv_t, const char **, ssize_t *, char **, ssize_t *, + const char **, const char *); typedef void *FGETCONV; FGETCONV *fgetconv_open (FILE *, const char *, const char *, int); int fgetconv (FGETCONV *); -char *fgetconvs (char *, size_t, FGETCONV *); +char *fgetconvs (char *, ssize_t, FGETCONV *); void fgetconv_close (FGETCONV **); void mutt_set_langinfo_charset (void); diff --git a/commands.c b/commands.c index dc0a6f4..01ea639 100644 --- a/commands.c +++ b/commands.c @@ -242,7 +242,7 @@ void ci_bounce_message (HEADER * h, int *redraw) char prompt[SHORT_STRING]; char buf[HUGE_STRING] = { 0 }; address_t *adr = NULL; - char *err = NULL; + const char *err = NULL; int rc; if (h) diff --git a/complete.c b/complete.c index e1815c7..40af1a6 100644 --- a/complete.c +++ b/complete.c @@ -33,13 +33,13 @@ * * return 0 if ok, -1 if no matches */ -int mutt_complete (char *s, size_t slen) +int mutt_complete (char *s, ssize_t slen) { char *p; DIR *dirp = NULL; struct dirent *de; int i, init = 0; - size_t len; + ssize_t len; char dirpart[_POSIX_PATH_MAX], exp_dirpart[_POSIX_PATH_MAX]; char filepart[_POSIX_PATH_MAX]; @@ -140,7 +140,7 @@ int mutt_complete (char *s, size_t slen) } else { *p = 0; - len = (size_t) (p - s); + len = p - s; memcpy(dirpart, s, len); dirpart[len] = 0; p++; diff --git a/compose.c b/compose.c index 2e96e7d..4bf5cf1 100644 --- a/compose.c +++ b/compose.c @@ -313,7 +313,7 @@ static void draw_envelope (HEADER * msg, char *fcc) static int edit_address_list (int line, address_t ** addr) { char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */ - char *err = NULL; + const char *err = NULL; mutt_addrlist_to_local (*addr); rfc822_write_address (buf, sizeof (buf), *addr, 0); @@ -400,7 +400,7 @@ static void update_idx (MUTTMENU * menu, ATTACHPTR ** idx, short idxlen) static unsigned long cum_attachs_size (MUTTMENU * menu) { - size_t s; + ssize_t s; unsigned short i; ATTACHPTR **idx = menu->data; CONTENT *info; @@ -442,7 +442,7 @@ static unsigned long cum_attachs_size (MUTTMENU * menu) * help when modifying this function. */ -static const char *compose_format_str (char *buf, size_t buflen, char op, +static const char *compose_format_str (char *buf, ssize_t buflen, char op, const char *src, const char *prefix, const char *ifstring, const char *elsestring, @@ -508,7 +508,7 @@ static void compose_status_line (char *buf, ssize_t buflen, MUTTMENU * menu, */ int mutt_compose_menu (HEADER * msg, /* structure for new message */ char *fcc, /* where to save a copy of the message */ - size_t fcclen, HEADER * cur) + ssize_t fcclen, HEADER * cur) { /* current message */ char helpstr[SHORT_STRING]; char buf[LONG_STRING]; diff --git a/editmsg.c b/editmsg.c index cb6616f..f511749 100644 --- a/editmsg.c +++ b/editmsg.c @@ -55,7 +55,7 @@ static int edit_one_message (CONTEXT * ctx, HEADER * cur) struct stat sb; time_t mtime = 0; - size_t size = 0; + ssize_t size = 0; mutt_mktemp (tmp); diff --git a/from.c b/from.c index eafdfe6..a53944a 100644 --- a/from.c +++ b/from.c @@ -57,7 +57,7 @@ static int is_day_name (const char *s) * From [ ]