[PATCH] Fix more const warnings on Arch linux with the latest glibc.

"Kevin J. McCarthy" <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <[email protected]>
See 19434821 for more details.

These are in the IMAP code, which was accidentally skipped in the
previous testing.

imap_get_literal_count() is always passed a modifiable buf parameter,
(which the callers are also modifying):.  Since the function is, in
fact, sneakily modifying buf, change the signature to reflect reality.

Split off a different constc variable for the case inside
imap_parse_path() that was calling strchr on a const char * "path"
argument.
---
 imap/imap_private.h | 2 +-
 imap/util.c         | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/imap/imap_private.h b/imap/imap_private.h
index 32cd7259..7cceb011 100644
--- a/imap/imap_private.h
+++ b/imap/imap_private.h
@@ -315,7 +315,7 @@ void imap_free_idata (IMAP_DATA** idata);
 char* imap_fix_path (IMAP_DATA* idata, const char* mailbox, char* path,
                      size_t plen);
 void imap_cachepath(IMAP_DATA *idata, const char *mailbox, BUFFER *dest);
-int imap_get_literal_count (const char* buf, unsigned int* bytes);
+int imap_get_literal_count (char* buf, unsigned int* bytes);
 char* imap_get_qualifier (char* buf);
 int imap_mxcmp (const char* mx1, const char* mx2);
 char* imap_next_word (char* s);
diff --git a/imap/util.c b/imap/util.c
index 87ecf4db..681713a5 100644
--- a/imap/util.c
+++ b/imap/util.c
@@ -315,6 +315,7 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
   char tmp[128];
   ciss_url_t url;
   char *c;
+  const char *constc;
   int n;
 
   if (!ImapPort)
@@ -365,12 +366,12 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx)
     if (sscanf (path, "{%127[^}]}", tmp) != 1)
       return -1;
 
-    c = strchr (path, '}');
-    if (!c)
+    constc = strchr (path, '}');
+    if (!constc)
       return -1;
     else
       /* walk past closing '}' */
-      mx->mbox = safe_strdup (c+1);
+      mx->mbox = safe_strdup (constc+1);
 
     if ((c = strrchr (tmp, '@')))
     {
@@ -607,7 +608,7 @@ void imap_cachepath (IMAP_DATA *idata, const char *mailbox, BUFFER *dest)
 
 /* imap_get_literal_count: write number of bytes in an IMAP literal into
  *   bytes, return 0 on success, -1 on failure. */
-int imap_get_literal_count(const char *buf, unsigned int *bytes)
+int imap_get_literal_count(char *buf, unsigned int *bytes)
 {
   char *pc;
   char *pn;
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.