On Tue, Feb 24, 2026 at 09:05:51PM +0800, Kevin J. McCarthy wrote:
> On Tue, Feb 24, 2026 at 01:41:26PM +0100, Rene Kita wrote:
> > On Tue, Feb 24, 2026 at 07:23:26PM +0800, Kevin J. McCarthy wrote:
> > 
> > This explains why it went so smooth with Arch. m-(
> > 
> > Running the build on Arch I get multiple errors of this kind:
> > browser.c:548:17: error: initialization discards 'const' qualifier from
> > pointer target type [-Werror=discarded-qualifiers]
> >  548 |       char *c = strrchr (d, '/');
> >      |                 ^~~~~~~
> > 
> > This is in function:
> > static int examine_directory (MUTTMENU *menu, struct browser_state *state,
> >                           const char *d, const char *prefix).
> > 
> > AFAIU, strrchr is defined as: char * strrchr(const char *s, int c).
> > 
> > *c is changed later in that function, so we can't make it const. Any
> > ideas what's the best way forward from here?
> 
> Ah, that was my mistake from 7 years ago!  I changed the parameter type when
> I was converting to buffers and the compiler didn't flag anything, so I
> failed to notice d was sneakily being modified.
> 
> The "d" parameters buffers all come from the pool, so they won't be NULL.  I
> think the best thing to do is change the parameter type back to char *d and
> just directly pass the parameter->data.  But let me take a closer look
> tomorrow and fix it up.

I silenced all warnings on Arch by casting just to get a list of places
where the error did occur. So the following is not meant as a solution,
but as a list of other places we might have the same problem:

diff --git a/browser.c b/browser.c
index 9ff9fc60..2dba3e96 100644
--- a/browser.c
+++ b/browser.c
@@ -545,7 +545,7 @@ static int examine_directory (MUTTMENU *menu, struct 
browser_state *state,
     if (errno == ENOENT)
     {
       /* The last used directory is deleted, try to use the parent dir. */
-      char *c = strrchr (d, '/');
+      char *c = (char *)strrchr (d, '/');

       if (c && (c > d))
       {
diff --git a/mh.c b/mh.c
index 4c4c9695..978c619a 100644
--- a/mh.c
+++ b/mh.c
@@ -690,7 +690,7 @@ static void maildir_parse_flags (HEADER * h, const char 
*path)
   h->read = 0;
   h->replied = 0;

-  if ((p = strrchr (path, ':')) != NULL && mutt_strncmp (p + 1, "2,", 2) == 0)
+  if ((p = (char *)strrchr (path, ':')) != NULL && mutt_strncmp (p + 1, "2,", 
2) == 0)
   {
     p += 3;

@@ -2119,7 +2119,7 @@ static void maildir_canon_filename (BUFFER *dest, const 
char *src)
 {
   char *t, *u;

-  if ((t = strrchr (src, '/')))
+  if ((t = (char *)strrchr (src, '/')))
     src = t + 1;

   mutt_buffer_strcpy (dest, src);

diff --git a/muttlib.c b/muttlib.c
index 18f3ebf0..7c4870df 100644
--- a/muttlib.c
+++ b/muttlib.c
@@ -510,7 +510,7 @@ void _mutt_buffer_expand_path (BUFFER *src, int flags)
         else
         {
           struct passwd *pw;
-          if ((t = strchr (s + 1, '/')))
+          if ((t = (char *)strchr (s + 1, '/')))
             *t = 0;

           if ((pw = getpwnam (s + 1)))

diff --git a/parse.c b/parse.c
index 141947f4..8bc49efc 100644
--- a/parse.c
+++ b/parse.c
@@ -831,7 +831,7 @@ static const char *uncomment_timezone (char *buf, size_t 
buflen, const char *tz)
   if (*tz != '(')
     return tz; /* no need to do anything */
   tz = skip_email_wsp(tz + 1);
-  if ((p = strpbrk (tz, " )")) == NULL)
+  if ((p = (char *)strpbrk (tz, " )")) == NULL)
     return tz;
   len = p - tz;
   if (len > buflen - 1)
@@ -1001,7 +1001,7 @@ time_t mutt_parse_date (const char *s, HEADER *h)
         {
           struct tz_t *tz;

-          tz = bsearch (ptz, TimeZones, sizeof TimeZones/sizeof (struct tz_t),
+          tz = (struct tz_t *)bsearch (ptz, TimeZones, sizeof TimeZones/sizeof 
(struct tz_t),
                         sizeof (struct tz_t),
                         (int (*)(const void *, const void *)) ascii_strcasecmp
                         /* This is safe to do: A pointer to a struct equals

diff --git a/rfc1524.c b/rfc1524.c
index 273614b1..fff0f7e0 100644
--- a/rfc1524.c
+++ b/rfc1524.c
@@ -230,7 +230,7 @@ static int rfc1524_mailcap_parse (BODY *a,
    */

   /* find length of basetype */
-  if ((ch = strchr (type, '/')) == NULL)
+  if ((ch = (char *)strchr (type, '/')) == NULL)
     return FALSE;
   btlen = ch - type;

@@ -509,10 +509,10 @@ void mutt_rfc1524_expand_filename (const char 
*nametemplate,
   /* first, ignore leading path components.
    */

-  if (nametemplate && (s = strrchr (nametemplate, '/')))
+  if (nametemplate && (s = (char *)strrchr (nametemplate, '/')))
     nametemplate = s + 1;

-  if (oldfile && (s = strrchr (oldfile, '/')))
+  if (oldfile && (s = (char *)strrchr (oldfile, '/')))
     oldfile = s + 1;

   if (!nametemplate)

diff --git a/sendlib.c b/sendlib.c
index f0e34d99..9012cffa 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -2129,7 +2129,7 @@ static int write_one_header (FILE *fp, int pfxw, int max, 
int wraplen,
   }
   else
   {
-    t = strchr (start, ':');
+    t = (char *)strchr (start, ':');
     if (!t || t >= end)
     {
       muttdbg(1, "mwoh: warning: header not in 'key: value' format!");

diff --git a/url.c b/url.c
index c1578f42..cdf365b3 100644
--- a/url.c
+++ b/url.c
@@ -81,7 +81,7 @@ url_scheme_t url_check_scheme (const char *s)
   char *t;
   int i;

-  if (!s || !(t = strchr (s, ':')))
+  if (!s || !(t = (char *)strchr (s, ':')))
     return U_UNKNOWN;
   if ((size_t)(t - s) >= sizeof (sbuf) - 1)
     return U_UNKNOWN;
@@ -301,7 +301,7 @@ int url_parse_mailto (ENVELOPE *e, char **body, const char 
*src)

   LIST *last = NULL;

-  if (!(t = strchr (src, ':')))
+  if (!(t = (char *)strchr (src, ':')))
     return -1;

   /* copy string for safe use of strtok() */


Reply via email to