opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

0042-fts-Use-prototype-in-declaration-of-fts_compar.patch (2213B)


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