From cac1491258e026b8c8459b2ad408a6bf2e8a03bc Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 4 Nov 2006 01:43:36 +0100 Subject: [PATCH] [PATCH] Fix compilations warnings Signed-off-by: Julien Danjou Signed-off-by: Pierre Habouzit --- account.c | 2 ++ attach.c | 2 +- browser.c | 45 ++++++++++++++++++++++++++++++++++++--------- buffy.c | 13 +++++++------ charset.c | 9 +++++---- color.c | 6 +++--- compose.c | 13 +++++++------ compose.h | 2 +- copy.c | 8 ++++---- mutt_menu.h | 2 +- 10 files changed, 67 insertions(+), 35 deletions(-) diff --git a/account.c b/account.c index 92cacbb..d87c3e3 100644 --- a/account.c +++ b/account.c @@ -28,7 +28,9 @@ int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * a2) { const char* user = NONULL (Username); +#ifdef USE_IMAP const char* login = NONULL (Username); +#endif if (a1->type != a2->type) return 0; diff --git a/attach.c b/attach.c index 5f588b7..3323af6 100644 --- a/attach.c +++ b/attach.c @@ -322,7 +322,7 @@ void mutt_check_lookup_list (BODY * b, char *type, int len) ascii_strncasecmp (type, t->data, i) == 0) || ascii_strcasecmp (type, t->data) == 0) { - BODY tmp = { 0 }; + BODY tmp; int n; if ((n = mutt_lookup_mime_type (&tmp, b->filename)) != TYPEOTHER) { diff --git a/browser.c b/browser.c index d91d0ef..233a7c1 100644 --- a/browser.c +++ b/browser.c @@ -78,7 +78,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) { - int c; + unsigned int c; for (c = 0; c < state->entrylen; c++) { p_delete(&((state->entry)[c].name)); @@ -423,9 +423,15 @@ static const char *newsgroup_format_str (char *dest, size_t destlen, char op, } #endif /* USE_NNTP */ +#ifdef USE_NNTP static void add_folder (MUTTMENU * m, struct browser_state *state, const char *name, const struct stat *s, void *data, int new) +#else +static void add_folder (MUTTMENU * m, struct browser_state *state, + const char *name, const struct stat *s, + int new) +#endif { if (state->entrylen == state->entrymax) { /* need to allocate more space */ @@ -489,7 +495,11 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, continue; if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not)) continue; +#ifdef USE_NNTP add_folder (menu, state, data->group, NULL, data, data->new); +#else + add_folder (menu, state, data->group, NULL, data->new); +#endif } sidebar_draw (CurrentMenu); } @@ -549,7 +559,11 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state, continue; i = buffy_lookup (buffer); +#ifdef USE_NNTP add_folder (menu, state, de->d_name, &s, NULL, i >= 0 ? ((BUFFY*) Incoming->data[i])->new : 0); +#else + add_folder (menu, state, de->d_name, &s, i >= 0 ? ((BUFFY*) Incoming->data[i])->new : 0); +#endif } closedir (dp); } @@ -586,7 +600,7 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) else #endif { - int i = 0; + unsigned int i = 0; BUFFY* tmp; if (!Incoming) @@ -600,13 +614,21 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) tmp->magic = mx_get_magic (tmp->path); #ifdef USE_IMAP if (tmp->magic == M_IMAP) { +#ifdef USE_NNTP add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); +#else + add_folder (menu, state, tmp->path, NULL, tmp->new); +#endif continue; } #endif #ifdef USE_POP if (tmp->magic == M_POP) { +#ifdef USE_NNTP add_folder (menu, state, tmp->path, NULL, NULL, tmp->new); +#else + add_folder (menu, state, tmp->path, NULL, tmp->new); +#endif continue; } #endif @@ -626,7 +648,11 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state) m_strcpy(buffer, sizeof(buffer), NONULL(tmp->path)); mutt_pretty_mailbox (buffer); +#ifdef USE_NNTP add_folder (menu, state, buffer, &s, NULL, tmp->new); +#else + add_folder (menu, state, buffer, &s, tmp->new); +#endif } } browser_sort (state); @@ -779,7 +805,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, for (i = m_strlen(f) - 1; i > 0 && f[i] != '/'; i--); if (i > 0) { if (f[0] == '/') { - i = MIN(sizeof(LastDir) - 1, i); + i = MIN(ssizeof(LastDir) - 1, i); m_strcpy(LastDir, sizeof(LastDir), f); } else { @@ -993,12 +1019,13 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, if (multiple) { char **tfiles; - int i, j; + int j; + unsigned int h; if (menu->tagged) { *numfiles = menu->tagged; tfiles = p_new(char *, *numfiles); - for (i = 0, j = 0; i < state.entrylen; i++) { + for (h = 0, j = 0; h < state.entrylen; i++) { struct folder_file ff = state.entry[i]; char full[_POSIX_PATH_MAX]; @@ -1128,7 +1155,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, #endif { /* add '/' at the end of the directory name if not already there */ - int len = m_strlen(LastDir); + size_t len = m_strlen(LastDir); if (len && LastDir[len - 1] != '/' && sizeof (buf) > len) buf[len] = '/'; @@ -1354,11 +1381,11 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, } else { BODY *b; - char buf[_POSIX_PATH_MAX]; + char nbuf[_POSIX_PATH_MAX]; - mutt_concat_path(buf, sizeof(buf), LastDir, + mutt_concat_path(nbuf, sizeof(nbuf), LastDir, state.entry[menu->current].name); - b = mutt_make_file_attach (buf); + b = mutt_make_file_attach (nbuf); if (b != NULL) { mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0); mutt_free_body (&b); diff --git a/buffy.c b/buffy.c index 96ae2fa..ff316cc 100644 --- a/buffy.c +++ b/buffy.c @@ -176,7 +176,7 @@ static void buffy_free (BUFFY** p) { } int buffy_lookup (const char* path) { - int i = 0; + unsigned int i = 0; if (list_empty(Incoming) || !path || !*path) return (-1); for (i = 0; i < Incoming->length; i++) { @@ -187,7 +187,7 @@ int buffy_lookup (const char* path) { } int buffy_parse_mailboxes (BUFFER * path, BUFFER * s, unsigned long data, - BUFFER * err) + BUFFER * err __attribute__ ((unused))) { BUFFY* tmp; char buf[_POSIX_PATH_MAX]; @@ -273,7 +273,8 @@ int buffy_check (int force) struct stat contex_sb; time_t now, last1; CONTEXT *ctx; - int i = 0, local = 0, count = 0; + unsigned int i = 0; + int local = 0, count = 0; #ifdef USE_IMAP time_t last2; @@ -438,7 +439,6 @@ int buffy_check (int force) BuffyCount++; if (count) { DIR *dp; - struct dirent *de; if ((dp = opendir (path)) == NULL) break; @@ -506,7 +506,7 @@ int buffy_list (void) int pos; int first; int have_unnotified = BuffyNotify; - int i = 0; + unsigned int i = 0; pos = 0; first = 1; @@ -570,7 +570,8 @@ int buffy_notify (void) */ void buffy_next (char *s, size_t slen) { - int i = 0, c = 0, l = 0; + unsigned int l = 0; + int c = 0, i = 0; if (list_empty(Incoming)) return; diff --git a/charset.c b/charset.c index 761be88..9826ef4 100644 --- a/charset.c +++ b/charset.c @@ -336,7 +336,7 @@ size_t mutt_iconv (iconv_t cd, const char **inbuf, size_t * inbytesleft, outrepl = "?"; my_iconv(cd, 0, 0, &ob, &obl); if (obl) { - int n = m_strlen(outrepl); + size_t n = m_strlen(outrepl); if (n > obl) { outrepl = "?"; @@ -448,7 +448,7 @@ FGETCONV *fgetconv_open (FILE * file, const char *from, const char *to, fc->inrepls = mutt_is_utf8 (to) ? repls : repls + 1; } else - fc = p_new(struct fgetconv_not, 1); + fc = p_new(struct fgetconv_s, 1); fc->file = file; fc->cd = cd; return (FGETCONV *) fc; @@ -556,7 +556,8 @@ static size_t convert_string (const char *f, size_t flen, { iconv_t cd; char *buf, *ob; - size_t obl, n; + size_t obl; + ssize_t n; int e; cd = mutt_iconv_open (to, from, 0); @@ -565,7 +566,7 @@ static size_t convert_string (const char *f, size_t flen, obl = 4 * flen + 1; ob = buf = xmalloc(obl); n = my_iconv(cd, &f, &flen, &ob, &obl); - if (n == (size_t) (-1) || my_iconv(cd, 0, 0, &ob, &obl) == (size_t) (-1)) { + if (n < 0 || my_iconv(cd, 0, 0, &ob, &obl) < 0) { e = errno; p_delete(&buf); iconv_close (cd); diff --git a/color.c b/color.c index 17af49a..4166468 100644 --- a/color.c +++ b/color.c @@ -351,7 +351,7 @@ int mutt_parse_unmono (BUFFER * buf, BUFFER * s, unsigned long data, } static int -_mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data, +_mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data __attribute__ ((unused)), BUFFER * err, short parse_uncolor) { int object = 0, do_cache = 0; @@ -734,7 +734,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err, #ifdef HAVE_COLOR -int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data, +int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data __attribute__ ((unused)), BUFFER * err) { int dry_run = 0; @@ -747,7 +747,7 @@ int mutt_parse_color (BUFFER * buff, BUFFER * s, unsigned long data, #endif -int mutt_parse_mono (BUFFER * buff, BUFFER * s, unsigned long data, +int mutt_parse_mono (BUFFER * buff, BUFFER * s, unsigned long data __attribute__ ((unused)), BUFFER * err) { int dry_run = 0; diff --git a/compose.c b/compose.c index 3401388..508c151 100644 --- a/compose.c +++ b/compose.c @@ -134,7 +134,8 @@ static struct mapping_t ComposeNewsHelp[] = { }; #endif -static void snd_entry (char *b, size_t blen, MUTTMENU * menu, int num) { + +static void snd_entry (char *b, ssize_t blen, MUTTMENU * menu, int num) { int w=(COLS-SW)>blen?blen:COLS-SW; mutt_FormatString (b, w, NONULL (AttachFormat), mutt_attach_fmt, (unsigned long) (((ATTACHPTR **) menu->data)[num]), @@ -501,7 +502,7 @@ static const char *compose_format_str (char *buf, size_t buflen, char op, return (src); } -static void compose_status_line (char *buf, size_t buflen, MUTTMENU * menu, +static void compose_status_line (char *buf, ssize_t buflen, MUTTMENU * menu, const char *p) { int w=(COLS-SW)>buflen?buflen:(COLS-SW); @@ -527,7 +528,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ ATTACHPTR **idx = NULL; short idxlen = 0; short idxmax = 0; - int i, close = 0; + int i, closed = 0; int r = -1; /* return value */ int op = 0; int loop = 1; @@ -712,7 +713,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ (op == OP_COMPOSE_EDIT_HEADERS || (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS)))) { const char *tag = NULL; - char *err = NULL; + const char *err = NULL; mutt_env_to_local (msg->env); mutt_edit_headers (NONULL (Editor), msg->content->filename, msg, @@ -906,7 +907,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ set_option (OPTATTACHMSG); mutt_message _("Tag the messages you want to attach!"); - close = mutt_index_menu (); + closed = mutt_index_menu (); unset_option (OPTATTACHMSG); if (!Context) { @@ -940,7 +941,7 @@ int mutt_compose_menu (HEADER * msg, /* structure for new message */ } menu->redraw |= REDRAW_FULL; - if (close == OP_QUIT) + if (closed == OP_QUIT) mx_close_mailbox (Context, NULL); else mx_fastclose_mailbox (Context); diff --git a/compose.h b/compose.h index aae4557..d8ff82d 100644 --- a/compose.h +++ b/compose.h @@ -1 +1 @@ -static void compose_status_line(char *buf, size_t buflen, MUTTMENU * menu,const char *p); +static void compose_status_line(char *buf, ssize_t buflen, MUTTMENU * menu,const char *p); diff --git a/copy.c b/copy.c index 399a65b..504a1e2 100644 --- a/copy.c +++ b/copy.c @@ -444,7 +444,7 @@ mutt_copy_header (FILE * in, HEADER * h, FILE * out, int flags, } if (flags & CH_UPDATE_LEN && (flags & CH_NOLEN) == 0) { - fprintf (out, "Content-Length: %zd\n", h->content->length); + fprintf (out, "Content-Length: %lld\n", h->content->length); if (h->lines != 0 || h->content->length == 0) fprintf (out, "Lines: %d\n", h->lines); } @@ -548,7 +548,7 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body, if (mutt_copy_header (fpin, hdr, fpout, chflags | CH_NOLEN | CH_NONEWLINE, NULL)) return -1; - fprintf (fpout, "Content-Length: %zd\n", new_length); + fprintf (fpout, "Content-Length: %lld\n", new_length); if (new_lines <= 0) new_lines = 0; else @@ -718,7 +718,7 @@ mutt_copy_message (FILE * fpout, CONTEXT * src, HEADER * hdr, int flags, */ int -_mutt_append_message (CONTEXT * dest, FILE * fpin, CONTEXT * src, +_mutt_append_message (CONTEXT * dest, FILE * fpin, CONTEXT * src __attribute__ ((unused)), HEADER * hdr, BODY * body, int flags, int chflags) { char buf[STRING]; MESSAGE *msg; @@ -777,7 +777,7 @@ static int copy_delete_attach (BODY * b, FILE * fpin, FILE * fpout, if (part->deleted) { fprintf (fpout, "Content-Type: message/external-body; access-type=x-mutt-deleted;\n" - "\texpiration=%s; length=%zd\n" + "\texpiration=%s; length=%lld\n" "\n", date + 5, part->length); if (ferror (fpout)) return -1; diff --git a/mutt_menu.h b/mutt_menu.h index 1c9e2be..41204a6 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -50,7 +50,7 @@ typedef struct menu_t { char *keys; /* keys used in the prompt */ /* callback to generate an index line for the requested element */ - void (*make_entry) (char *, size_t, struct menu_t *, int); + void (*make_entry) (char *, ssize_t, struct menu_t *, int); /* how to search the menu */ int (*search) (struct menu_t *, regex_t * re, int n); -- 2.20.1