Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: bgpd: more const correctness
To:
tech@openbsd.org
Date:
Wed, 30 Sep 2026 09:38:26 +0200

Download raw body.

Thread
On Wed, Sep 30, 2026 at 09:30:58AM +0200, Claudio Jeker wrote:
> On fedora44 I see the following new warnings:
> 
> ../../../openbgpd-portable/src/bgpd/parse.y: In function ‘parse_flags’:
> ../../../openbgpd-portable/src/bgpd/parse.y:5676:24: warning: assignment
> discards ‘const’ qualifier from pointer target type
> [-Wdiscarded-qualifiers]
>  5676 |                 if ((q = strchr(flags, *p)) == NULL)
>       |                        ^
> 
> ../../../openbgpd-portable/src/bgpctl/parser.c: In function
> ‘parse_prefix’:
> ../../../openbgpd-portable/src/bgpctl/parser.c:1012:16: warning:
> assignment discards ‘const’ qualifier from pointer target type
> [-Wdiscarded-qualifiers]
>  1012 |         if ((p = strrchr(word, '/')) != NULL) {
>       |                ^
> 
> This is because C23 uses type-generic versions of strchr / strrchr.
> The fix is simple since in both cases p and q can also be const.

ok tb

> 
> -- 
> :wq Claudio
> 
> Index: bgpctl/parser.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpctl/parser.c,v
> diff -u -p -r1.141 parser.c
> --- bgpctl/parser.c	24 Sep 2026 11:41:41 -0000	1.141
> +++ bgpctl/parser.c	30 Sep 2026 07:15:33 -0000
> @@ -1000,8 +1000,8 @@ parse_prefix(const char *word, size_t wo
>      uint8_t *prefixlen)
>  {
>  	struct bgpd_addr tmp;
> -	char		*p, *ps;
> -	const char	*errstr;
> +	const char	*p, *errstr;
> +	char		*ps;
>  	int		 mask = -1;
>  
>  	if (word == NULL)
> Index: bgpd/parse.y
> ===================================================================
> RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
> diff -u -p -r1.506 parse.y
> --- bgpd/parse.y	24 Sep 2026 11:41:41 -0000	1.506
> +++ bgpd/parse.y	30 Sep 2026 07:14:13 -0000
> @@ -5656,7 +5656,8 @@ static int
>  parse_flags(char *s)
>  {
>  	const char *flags = FLOWSPEC_TCP_FLAG_STRING;
> -	char *p, *q;
> +	const char *q;
> +	char *p;
>  	uint8_t f = 0;
>  
>  	if (curflow->type == FLOWSPEC_TYPE_FRAG) {
>