commit 74bbeb3
Michael Forney
·
2026-04-03 11:03:42 +0000 UTC
parent 4d9272d
openbsd: Fix type of fts_compar
2 files changed,
+49,
-7
1@@ -1,26 +1,68 @@
2-From 5b997ce94b67bfd5c3f1a34c33fb14b11a8b5c81 Mon Sep 17 00:00:00 2001
3+From 1aa57013bfe9e7bf73c8a6da3f1493c72a42a5fc Mon Sep 17 00:00:00 2001
4 From: Michael Forney <mforney@mforney.org>
5 Date: Thu, 2 Apr 2026 17:17:27 -0700
6 Subject: [PATCH] fts: Use prototype in declaration of fts_compar
7
8 In C23, empty parenthesis indications a function taking no arguments.
9 ---
10- include/fts.h | 2 +-
11- 1 file changed, 1 insertion(+), 1 deletion(-)
12+ include/fts.h | 8 +++++---
13+ lib/libc/gen/fts.c | 3 ++-
14+ 2 files changed, 7 insertions(+), 4 deletions(-)
15
16 diff --git a/include/fts.h b/include/fts.h
17-index a5b3aff91e7..ef25e88d298 100644
18+index a5b3aff91e7..c2be7cfee71 100644
19 --- a/include/fts.h
20 +++ b/include/fts.h
21-@@ -46,7 +46,7 @@ typedef struct {
22+@@ -37,6 +37,8 @@
23+
24+ #include <sys/cdefs.h>
25+
26++typedef struct _ftsent FTSENT;
27++
28+ typedef struct {
29+ struct _ftsent *fts_cur; /* current node */
30+ struct _ftsent *fts_child; /* linked list of children */
31+@@ -46,7 +48,7 @@ typedef struct {
32 int fts_rfd; /* fd for root */
33 size_t fts_pathlen; /* sizeof(path) */
34 int fts_nitems; /* elements in the sort array */
35 - int (*fts_compar)(); /* compare function */
36-+ int (*fts_compar)(const void *, const void *); /* compare function */
37++ int (*fts_compar)(const FTSENT **, const FTSENT **); /* compare function */
38
39 #define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
40 #define FTS_LOGICAL 0x0002 /* logical walk */
41+@@ -62,7 +64,7 @@ typedef struct {
42+ int fts_options; /* fts_open options, global flags */
43+ } FTS;
44+
45+-typedef struct _ftsent {
46++struct _ftsent {
47+ struct _ftsent *fts_cycle; /* cycle node */
48+ struct _ftsent *fts_parent; /* parent directory */
49+ struct _ftsent *fts_link; /* next file in directory */
50+@@ -113,7 +115,7 @@ typedef struct _ftsent {
51+
52+ struct stat *fts_statp; /* stat(2) information */
53+ char fts_name[1]; /* file name */
54+-} FTSENT;
55++};
56+
57+ __BEGIN_DECLS
58+ FTSENT *fts_children(FTS *, int);
59+diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
60+index 86585190a99..444d969c299 100644
61+--- a/lib/libc/gen/fts.c
62++++ b/lib/libc/gen/fts.c
63+@@ -897,7 +897,8 @@ fts_sort(FTS *sp, FTSENT *head, int nitems)
64+ }
65+ for (ap = sp->fts_array, p = head; p; p = p->fts_link)
66+ *ap++ = p;
67+- qsort(sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar);
68++ qsort(sp->fts_array, nitems, sizeof(FTSENT *),
69++ (int (*)(const void *, const void *))sp->fts_compar);
70+ for (head = *(ap = sp->fts_array); --nitems; ++ap)
71+ ap[0]->fts_link = ap[1];
72+ ap[0]->fts_link = NULL;
73 --
74 2.49.0
75
+1,
-1
1@@ -1 +1 @@
2-7.8 r1
3+7.8 r2