On 17/04/2024 14:40, Arnaldo Carvalho de Melo wrote: > On Wed, Apr 17, 2024 at 10:20:41AM +0100, Alan Maguire wrote: >> On 25/03/2024 17:53, Daniel Xu wrote: >>> Add a helper to sort the gobuffer. Trivial wrapper around qsort(). >>> >>> Signed-off-by: Daniel Xu <dxu@xxxxxxxxx> >> Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> >>> --- >>> gobuffer.c | 5 +++++ >>> gobuffer.h | 2 ++ >>> 2 files changed, 7 insertions(+) >>> >>> diff --git a/gobuffer.c b/gobuffer.c >>> index 02b2084..4655339 100644 >>> --- a/gobuffer.c >>> +++ b/gobuffer.c >>> @@ -102,6 +102,11 @@ void gobuffer__copy(const struct gobuffer *gb, void *dest) >>> } >>> } >>> >>> +void gobuffer__sort(struct gobuffer *gb, unsigned int size, int (*compar)(const void *, const void *)) >>> +{ >>> + qsort((void *)gb->entries, gb->nr_entries, size, compar); >> >> nit shouldn't need to cast char * gb->entries to void * ; not worth >> respinning the series for though unless there are other issues > > I can remove that while applying the series, which I'm doing now. > great, thanks! BTW patch 2 will probably require a small tweak for merging into next: - BTF_FEATURE(decl_tag_kfuncs, btf_decl_tag_kfuncs, false), + BTF_FEATURE(decl_tag_kfuncs, btf_decl_tag_kfuncs, false, true), this will ensure it is considered a standard feature and is enabled for "all"; for readability it might make sense to position it wth the other features prior to BTF_FEATURE(reproducible_build, reproducible_build, false, false), ...since then we'd have the standard features grouped before the non-standard ones, making it a bit more readable; not a big deal tho. thanks! > - Arnaldo > >>> +} >>> + >>> const void *gobuffer__compress(struct gobuffer *gb, unsigned int *size) >>> { >>> z_stream z = { >>> diff --git a/gobuffer.h b/gobuffer.h >>> index a12c5c8..cd218b6 100644 >>> --- a/gobuffer.h >>> +++ b/gobuffer.h >>> @@ -21,6 +21,8 @@ void __gobuffer__delete(struct gobuffer *gb); >>> >>> void gobuffer__copy(const struct gobuffer *gb, void *dest); >>> >>> +void gobuffer__sort(struct gobuffer *gb, unsigned int size, int (*compar)(const void *, const void *)); >>> + >>> int gobuffer__add(struct gobuffer *gb, const void *s, unsigned int len); >>> int gobuffer__allocate(struct gobuffer *gb, unsigned int len); >>>