From a069d33edeb7fe08803bf49e0948ddd798124e60 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 2 Oct 2023 08:27:47 -0500 Subject: [PATCH] Shut the stupid compiler up. --- toys/pending/tsort.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/toys/pending/tsort.c b/toys/pending/tsort.c index 92b62e23..b7a7ae7f 100644 --- a/toys/pending/tsort.c +++ b/toys/pending/tsort.c @@ -50,6 +50,16 @@ static void do_tsort(int fd, char *name) otop, // out at start of this loop over pair[] otop2, // out at start of previous loop over pair[] ii, jj, kk; + unsigned long sigh; + + // bsearch()'s first argument is the element to search for, + // and sbse() compares the second element of each pair, so to find + // which FIRST element matches a second element, we need to feed bsearch + // keep-1 but the compiler clutches its pearls about this even when + // typecast to (void *), so do the usual LP64 trick to MAKE IT SHUT UP. + // (The search function adds 1 to each argument so we never access + // memory outside the pair.) + sigh = ((unsigned long)keep)-sizeof(*keep); // Count input entries in data block read from fd if (!(ss = readfd(fd, 0, &plen))) return; @@ -82,7 +92,8 @@ static void do_tsort(int fd, char *name) for (ii = 0; ii