On 2026-02-25T17:57:24+0800, Kevin J. McCarthy wrote:
> The latest version changes string search functions, such as strchr()

BTW, you may want to say "the latest version [of libc]"?

> and strrchr(), so that the return type is the same type as the string
> passed in.
> 
> This helped us catch a real bug in browser.c (3a8dfafc), and also
> turned up some variable type issues, fixed here.
> 
> Thanks to Rene Kita for the work on the Arch sr.ht build files which
> turned up the bugs, and for an initial patch showing where the warning
> were, which this commit is based upon.
> 
> Also thanks to Alejandro Colomar for quickly explaining what was going
> on and helping debug the issues.
> ---
>  mh.c      |  6 ++++--
>  muttlib.c |  3 ++-
>  parse.c   |  5 +++--
>  rfc1524.c |  7 ++++---
>  sendlib.c |  3 ++-
>  url.c     | 10 ++++++----
>  6 files changed, 21 insertions(+), 13 deletions(-)
> 
> diff --git a/mh.c b/mh.c
> index 4c4c9695..40115db2 100644
> --- a/mh.c
> +++ b/mh.c
> @@ -684,7 +684,8 @@ static void maildir_free_maildir (struct maildir **md)
>  
>  static void maildir_parse_flags (HEADER * h, const char *path)
>  {
> -  char *p, *q = NULL;
> +  const char *p;
> +  char *q = NULL;
>  
>    h->flagged = 0;
>    h->read = 0;
> @@ -2117,7 +2118,8 @@ err:
>  
>  static void maildir_canon_filename (BUFFER *dest, const char *src)
>  {
> -  char *t, *u;
> +  const char *t;
> +  char *u;
>  
>    if ((t = strrchr (src, '/')))
>      src = t + 1;
> diff --git a/muttlib.c b/muttlib.c
> index 18f3ebf0..4c20e8c5 100644
> --- a/muttlib.c
> +++ b/muttlib.c
> @@ -510,7 +510,8 @@ void _mutt_buffer_expand_path (BUFFER *src, int flags)
>          else
>          {
>            struct passwd *pw;
> -          if ((t = strchr (s + 1, '/')))
> +          /* NB: this is temporarily modifying src but is restoring it below 
> */
> +          if ((t = strchr (src->data + 1, '/')))
>              *t = 0;
>  
>            if ((pw = getpwnam (s + 1)))
> diff --git a/parse.c b/parse.c
> index 141947f4..c46a5811 100644
> --- a/parse.c
> +++ b/parse.c
> @@ -825,7 +825,7 @@ BODY *mutt_parse_multipart (FILE *fp, const char 
> *boundary, LOFF_T end_off, int
>  
>  static const char *uncomment_timezone (char *buf, size_t buflen, const char 
> *tz)
>  {
> -  char *p;
> +  const char *p;
>    size_t len;
>  
>    if (*tz != '(')
> @@ -1001,7 +1001,8 @@ 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..758e380a 100644
> --- a/rfc1524.c
> +++ b/rfc1524.c
> @@ -208,6 +208,7 @@ static int rfc1524_mailcap_parse (BODY *a,
>    FILE *fp;
>    char *buf = NULL;
>    size_t buflen;
> +  const char *typeslash;
>    char *ch;
>    char *field;
>    int found = FALSE;
> @@ -230,9 +231,9 @@ static int rfc1524_mailcap_parse (BODY *a,
>     */
>  
>    /* find length of basetype */
> -  if ((ch = strchr (type, '/')) == NULL)
> +  if ((typeslash = strchr (type, '/')) == NULL)
>      return FALSE;
> -  btlen = ch - type;
> +  btlen = typeslash - type;
>  
>    if ((fp = fopen (filename, "r")) != NULL)
>    {
> @@ -499,7 +500,7 @@ void mutt_rfc1524_expand_filename (const char 
> *nametemplate,
>                                     BUFFER *newfile)
>  {
>    int i, j, k, ps;
> -  char *s;
> +  const char *s;
>    short lmatch = 0, rmatch = 0;
>    BUFFER *left = NULL;
>    BUFFER *right = NULL;
> diff --git a/sendlib.c b/sendlib.c
> index f0e34d99..a700d500 100644
> --- a/sendlib.c
> +++ b/sendlib.c
> @@ -2100,7 +2100,8 @@ static int write_one_header (FILE *fp, int pfxw, int 
> max, int wraplen,
>                               const char *pfx, const char *start, const char 
> *end,
>                               int flags)
>  {
> -  char *tagbuf, *valbuf, *t;
> +  char *tagbuf, *valbuf;
> +  const char *t;
>    int is_from = ((end - start) > 5 &&
>                   ascii_strncasecmp (start, "from ", 5) == 0);
>  
> diff --git a/url.c b/url.c
> index c1578f42..dfe8bff7 100644
> --- a/url.c
> +++ b/url.c
> @@ -78,7 +78,8 @@ static int url_pct_decode (char *s)
>  url_scheme_t url_check_scheme (const char *s)
>  {
>    char sbuf[STRING];
> -  char *t;
> +  const char *t;
> +  char *sbufp;
>    int i;
>  
>    if (!s || !(t = strchr (s, ':')))
> @@ -87,8 +88,8 @@ url_scheme_t url_check_scheme (const char *s)
>      return U_UNKNOWN;
>  
>    strfcpy (sbuf, s, t - s + 1);
> -  for (t = sbuf; *t; t++)
> -    *t = ascii_tolower (*t);
> +  for (sbufp = sbuf; *sbufp; sbufp++)
> +    *sbufp = ascii_tolower (*sbufp);
>  
>    if ((i = mutt_getvaluebyname (sbuf, UrlMap)) == -1)
>      return U_UNKNOWN;
> @@ -292,7 +293,8 @@ static int url_mailto_header_allowed (const char *header)
>  
>  int url_parse_mailto (ENVELOPE *e, char **body, const char *src)
>  {
> -  char *t, *p;
> +  const char *t;
> +  char *p;
>    char *tmp;
>    char *headers;
>    char *tag, *value;
> -- 
> 2.53.0
> 

-- 
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature

Reply via email to