]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: fix bsearch macro usage with glibc C23
authorCristian Rodríguez <cristian@rodriguez.im>
Sat, 22 Nov 2025 13:41:08 +0000 (10:41 -0300)
committerCristian Rodríguez <cristian@rodriguez.im>
Sun, 23 Nov 2025 13:04:50 +0000 (10:04 -0300)
C23 requires bsearch to be a const preserving macro, build now fails
with

../lsfd-cmd/lsfd.c:1879:75: error: macro ‘bsearch’ passed 6 arguments, but takes just 5
 1879 |                                     nfds, sizeof(struct pollfd), pollfdcmp))
      |                                                                           ^
In file included from ../include/c.h:17,
                 from ../lsfd-cmd/lsfd.c:48:
/usr/include/stdlib.h:987:10: note: macro ‘bsearch’ defined here
  987 | # define bsearch(KEY, BASE, NMEMB, SIZE, COMPAR)                        \

  add parenthesis around expression to fix it.

lsfd-cmd/lsfd.c

index 335594144dc395f2d9e4fe32b49131c88573de6d..4da86c602e70cf3f454c7af6f1d9917ec551607f 100644 (file)
@@ -1875,7 +1875,7 @@ static void mark_poll_fds_as_multiplexed(char *buf,
                struct file *file = list_entry(f, struct file, files);
                if (is_opened_file(file) && !file->multiplexed) {
                        int fd = file->association;
-                       if (bsearch(&(struct pollfd){.fd = fd,}, local.iov_base,
+                       if (bsearch((&(struct pollfd){.fd = fd,}), local.iov_base,
                                    nfds, sizeof(struct pollfd), pollfdcmp))
                                file->multiplexed = 1;
                }