From 8a1eddeadba387599c0da563e9b30c22fd91d2ca Mon Sep 17 00:00:00 2001 From: claudio Date: Wed, 21 Feb 2024 13:24:37 +0000 Subject: [PATCH] In it_cmp() make sure that arrays are only considered equal if both have the same number of elements. This fixes an issue where arrays where too aggressivly merged and as a result the number of elements was mostly wrong in the CTF bits. Also it_cmp() should return 0 if both elements are considered equal. OK mpi@ --- usr.bin/ctfconv/parse.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/usr.bin/ctfconv/parse.c b/usr.bin/ctfconv/parse.c index d66db52d290..1b271c8d225 100644 --- a/usr.bin/ctfconv/parse.c +++ b/usr.bin/ctfconv/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.18 2024/02/21 13:21:56 claudio Exp $ */ +/* $OpenBSD: parse.c,v 1.19 2024/02/21 13:24:37 claudio Exp $ */ /* * Copyright (c) 2016-2017 Martin Pieuchot @@ -333,6 +333,11 @@ it_cmp(struct itype *a, struct itype *b) (diff = (a->it_size - b->it_size) != 0)) return diff; + /* Arrays need to have same number of elements */ + if ((a->it_type == CTF_K_ARRAY) && + (diff = (a->it_nelems - b->it_nelems) != 0)) + return diff; + /* Match by name */ if (!(a->it_flags & ITF_ANON) && !(b->it_flags & ITF_ANON)) return strcmp(it_name(a), it_name(b)); @@ -345,7 +350,7 @@ it_cmp(struct itype *a, struct itype *b) if ((a->it_refp != NULL) && (b->it_refp != NULL)) return it_cmp(a->it_refp, b->it_refp); - return 1; + return 0; } int -- 2.20.1