aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-30 18:02:28 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 17:57:52 +0100
commit67d4cc671b7b3c49f748546a510005333fcbc465 (patch)
treeff52ed7f5ca688b4b20b9b27656cc2bf269c8cad /libctf
parente28591b3dfc3958b954fc5264e5aaa94a9855f5b (diff)
downloadgdb-67d4cc671b7b3c49f748546a510005333fcbc465.zip
gdb-67d4cc671b7b3c49f748546a510005333fcbc465.tar.gz
gdb-67d4cc671b7b3c49f748546a510005333fcbc465.tar.bz2
libctf: pass the thunk down properly when wrapping qsort_r
When wrapping qsort_r on a system like FreeBSD on which the compar argument comes first, we wrap the passed arg in a thunk so we can pass down both the caller-supplied comparator function and its argument. We should pass the *argument* down to the comparator, not the thunk, which is basically random nonsense on the stack from the point of view of the caller of qsort_r. libctf/ ctf-decls.h (ctf_qsort_compar_thunk): Fix arg passing.
Diffstat (limited to 'libctf')
-rw-r--r--libctf/ChangeLog4
-rw-r--r--libctf/ctf-decls.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index 779f7b1..4a10f63 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,5 +1,9 @@
2020-07-22 Nick Alcock <nick.alcock@oracle.com>
+ ctf-decls.h (ctf_qsort_compar_thunk): Fix arg passing.
+
+2020-07-22 Nick Alcock <nick.alcock@oracle.com>
+
* ctf-impl.h (ctf_next_hkv_t): New, kv-pairs passed to
sorting functions.
(ctf_next_t) <u.ctn_sorted_hkv>: New, sorted kv-pairs for
diff --git a/libctf/ctf-decls.h b/libctf/ctf-decls.h
index 51041c5..c47a72e 100644
--- a/libctf/ctf-decls.h
+++ b/libctf/ctf-decls.h
@@ -46,7 +46,7 @@ ctf_qsort_compar_thunk (void *arg, const void *a, const void *b)
{
struct ctf_qsort_arg *qsort_arg = (struct ctf_qsort_arg *) arg;
- return qsort_arg->compar (a, b, arg);
+ return qsort_arg->compar (a, b, qsort_arg->arg);
}
static inline void