]> granicus.if.org Git - neomutt/commitdiff
Review of "Bring consistency among sizes"
authorPietro Cerutti <gahr@gahr.ch>
Wed, 13 Dec 2017 13:17:52 +0000 (13:17 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 13 Dec 2017 15:21:30 +0000 (15:21 +0000)
Issue #928

12 files changed:
address.c
browser.c
conn/ssl.c
curs_main.c
imap/message.c
keymap.c
mutt_address.c
muttlib.c
parse.c
protos.h
url.c
version.c

index 74f1d12186945179331fa930ff6df4c863a0812e..c3cd6427d0888adac6afacae95a69a0901bfc174 100644 (file)
--- a/address.c
+++ b/address.c
@@ -848,7 +848,7 @@ bool mutt_addr_valid_msgid(const char *msgid)
     return false;
 
   /* TODO: complete parser */
-  for (unsigned int i = 0; i < l; i++)
+  for (size_t i = 0; i < l; i++)
     if ((unsigned char) msgid[i] > 127)
       return false;
 
index a76cc95ddd135bc84ec058fcd795d4371d10eebf..faac9dc2714e57bbc03bed2492ab5e48bd60acd0 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -114,7 +114,7 @@ static char LastDir[_POSIX_PATH_MAX] = "";
  */
 static void destroy_state(struct BrowserState *state)
 {
-  for (int c = 0; c < state->entrylen; c++)
+  for (size_t c = 0; c < state->entrylen; c++)
   {
     FREE(&((state->entry)[c].name));
     FREE(&((state->entry)[c].desc));
index 26e1387bffb19d143c3f22a01a3ec20e5858cb5d..79e006b4b6319e0d09fefed0427fd23fa282b1be 100644 (file)
@@ -438,7 +438,7 @@ static void x509_fingerprint(char *s, int l, X509 *cert, const EVP_MD *(*hashfun
   }
   else
   {
-    for (int i = 0; i < (int) n; i++)
+    for (unsigned int i = 0; i < n; i++)
     {
       char ch[8];
       snprintf(ch, 8, "%02X%s", md[i], (i % 2 ? " " : ""));
@@ -1008,7 +1008,7 @@ static int interactive_check_cert(X509 *cert, int idx, size_t len, SSL *ssl, int
   snprintf(menu->dialog[row++], SHORT_STRING, _("MD5 Fingerprint: %s"), buf);
 
   snprintf(title, sizeof(title),
-           _("SSL Certificate check (certificate %d of %d in chain)"), len - idx, len);
+           _("SSL Certificate check (certificate %zu of %zu in chain)"), len - idx, len);
   menu->title = title;
 
 /* The leaf/host certificate can't be skipped. */
index 4654f9c02f0d5f62317be5df5adf17753d277e69..7a6e98efcea0d2cd7fe75725444546b9427cefd6 100644 (file)
@@ -700,10 +700,10 @@ int index_color(int index_no)
  */
 void mutt_draw_statusline(int cols, const char *buf, int buflen)
 {
-  int i = 0;
-  int offset = 0;
+  size_t i = 0;
+  size_t offset = 0;
   bool found = false;
-  int chunks = 0;
+  size_t chunks = 0;
   size_t len = 0;
 
   struct Syntax
@@ -785,7 +785,7 @@ void mutt_draw_statusline(int cols, const char *buf, int buflen)
     if (len <= syntax[i].last)
       goto dsl_finish; /* no more room */
 
-    int next;
+    size_t next;
     if ((i + 1) == chunks)
     {
       next = len;
index eba1dce51809d79bc275d4f7b1d954a25edd046f..b6bf35b8923f5df22fb47d9f852e19299874ead9 100644 (file)
@@ -473,7 +473,7 @@ static void flush_buffer(char *buf, size_t *len, struct Connection *conn)
  */
 static void alloc_msn_index(struct ImapData *idata, size_t msn_count)
 {
-  unsigned int new_size;
+  size_t new_size;
 
   if (msn_count <= idata->msn_index_size)
     return;
index 3ff760853bd5384dcbae2355f2ba60175d8837f7..8efee03e3a01abb8763472daf46c119fcea982a0 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -183,9 +183,10 @@ static int parse_keycode(const char *s)
   return result;
 }
 
-static int parsekeys(const char *str, keycode_t *d, int max)
+static size_t parsekeys(const char *str, keycode_t *d, size_t max)
 {
-  int n, len = max;
+  int n;
+  size_t len = max;
   char buf[SHORT_STRING];
   char c;
   char *s = NULL, *t = NULL;
@@ -246,7 +247,7 @@ int km_bind_err(char *s, int menu, int op, char *macro, char *descr, struct Buff
   struct Keymap *map = NULL, *tmp = NULL, *last = NULL, *next = NULL;
   keycode_t buf[MAX_SEQ];
   size_t len;
-  int pos = 0, lastpos = 0;
+  size_t pos = 0, lastpos = 0;
 
   len = parsekeys(s, buf, MAX_SEQ);
 
index 2bef2095b8b225d8456f0433905a22764f33c179..0be18f79efdd040c76b89418c7c415ce8d49c1d7 100644 (file)
@@ -148,7 +148,7 @@ done:
  *
  * Note: it is assumed that `buf' is nul terminated!
  */
-int rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int display)
+size_t rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int display)
 {
   char *pbuf = buf;
   size_t len = mutt_str_strlen(buf);
@@ -158,7 +158,7 @@ int rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int dis
   if (len > 0)
   {
     if (len > buflen)
-      return pbuf - buf; /* safety check for bogus arguments */
+      return 0; /* safety check for bogus arguments */
 
     pbuf += len;
     buflen -= len;
index 70ece002a7cca0a8640ea909288e1893abcff580..159015a47f8376c848ecf6d8e32c6290ae1410f6 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -602,7 +602,7 @@ void mutt_pretty_mailbox(char *s, size_t buflen)
   }
 }
 
-void mutt_pretty_size(char *s, size_t len, LOFF_T n)
+void mutt_pretty_size(char *s, size_t len, size_t n)
 {
   if (n == 0)
     mutt_str_strfcpy(s, "0K", len);
@@ -1410,6 +1410,10 @@ FILE *mutt_open_read(const char *path, pid_t *thepid)
   struct stat s;
 
   size_t len = mutt_str_strlen(path);
+  if (len == 0)
+  {
+    return NULL;
+  }
 
   if (path[len - 1] == '|')
   {
diff --git a/parse.c b/parse.c
index 9d6b2267f62eec5f1eebbbc11b47e766f0f6f58c..0b28d37f2a904d004b4c525bd2b6575548120431 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -583,11 +583,9 @@ struct Body *mutt_parse_multipart(FILE *fp, const char *boundary, LOFF_T end_off
 #ifdef SUN_ATTACHMENT
   int lines;
 #endif
-  size_t blen, len;
-  int crlf = 0;
+  size_t blen, len, crlf;
   char buffer[LONG_STRING];
   struct Body *head = NULL, *last = NULL, *new = NULL;
-  int i;
   bool final = false; /* did we see the ending boundary? */
 
   if (!boundary)
@@ -617,7 +615,7 @@ struct Body *mutt_parse_multipart(FILE *fp, const char *boundary, LOFF_T end_off
       }
 
       /* Remove any trailing whitespace, up to the length of the boundary */
-      for (i = len - 1; ISSPACE(buffer[i]) && i >= blen + 2; i--)
+      for (size_t i = len - 1; ISSPACE(buffer[i]) && i >= blen + 2; i--)
         buffer[i] = 0;
 
       /* Check for the end boundary */
index 2fd1ef2c68ca2c8e24e01f1297a57b83ec26bf12..f0877e394a3a4875441294904f629f39efc86e99 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -208,7 +208,7 @@ void mutt_perror_debug(const char *s);
 void mutt_prepare_envelope(struct Envelope *env, int final);
 void mutt_unprepare_envelope(struct Envelope *env);
 void mutt_pretty_mailbox(char *s, size_t buflen);
-void mutt_pretty_size(char *s, size_t len, LOFF_T n);
+void mutt_pretty_size(char *s, size_t len, size_t n);
 void mutt_pipe_message(struct Header *h);
 void mutt_print_message(struct Header *h);
 void mutt_query_exit(void);
@@ -373,7 +373,7 @@ int wcscasecmp(const wchar_t *a, const wchar_t *b);
 bool message_is_tagged(struct Context *ctx, int index);
 bool message_is_visible(struct Context *ctx, int index);
 
-int rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int display);
+size_t rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int display);
 void rfc822_write_address_single(char *buf, size_t buflen, struct Address *addr, int display);
 
 #endif /* _MUTT_PROTOS_H */
diff --git a/url.c b/url.c
index 58f73bdb8a7c840abc6bb3e214c6e38ca486b3fc..c2eee6895eb20e86e079c7f67ec4f825d0f29d96 100644 (file)
--- a/url.c
+++ b/url.c
@@ -295,7 +295,8 @@ int url_tostring(struct Url *u, char *dest, size_t len, int flags)
   {
     if (!(flags & U_PATH))
       mutt_str_strcat(dest, len, "//");
-    len -= (l = strlen(dest));
+    l = strlen(dest);
+    len -= l;
     dest += l;
 
     if (u->user && (u->user[0] || !(flags & U_PATH)))
@@ -312,7 +313,8 @@ int url_tostring(struct Url *u, char *dest, size_t len, int flags)
       else
         snprintf(dest, len, "%s@", str);
 
-      len -= (l = strlen(dest));
+      l = strlen(dest);
+      len -= l;
       dest += l;
     }
 
@@ -321,7 +323,8 @@ int url_tostring(struct Url *u, char *dest, size_t len, int flags)
     else
       snprintf(dest, len, "%s", u->host);
 
-    len -= (l = strlen(dest));
+    l = strlen(dest);
+    len -= l;
     dest += l;
 
     if (u->port)
index 49b27d9b5b3d702cc41720a92564ef144f995c6a..6d38c398d8755b03e850174b469e2f8d7840dbc7 100644 (file)
--- a/version.c
+++ b/version.c
@@ -295,8 +295,7 @@ static struct CompileOptions comp_opts[] = {
  */
 static void print_compile_options(struct CompileOptions *co)
 {
-  size_t len;
-  int used = 2;
+  size_t len, used = 2;
   bool tty = stdout ? isatty(fileno(stdout)) : false;
 
   printf("  ");