Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: bgpd: more const for attr code
To:
tech@openbsd.org
Date:
Tue, 12 May 2026 13:37:39 +0200

Download raw body.

Thread
On Tue, May 12, 2026 at 11:10:41AM +0200, Claudio Jeker wrote:
> attr_optadd() should use a const void * for the data passed in.
> In the end the data is copied so it makes sense and it would all be cool
> with the exception of attr_lookup(). Passing a const void * triggers a bit
> of a catch-22. Making the data in struct attr const makes free() unhappy
> and not doing it makes the lookup problematic.  The only solution is to
> move to CH_LOCATE so the needle and comparison function can be made const
> clean.

The idea seems right and the diff correct. I only have a bikeshed
coloring problem:

I have missed that the qualifiers in the _cmp function for _ch_locate()
are asymmetric. This feels very weird to me. Passing non-const to const
is never a problem.

Also, isn't this rather an _eq() function? It returns 1 if the
arguments are equal 0 if they're distinct: a cmp function does the
opposite: return 0 if they're equal and != 0 if they're different.