summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2012-03-22 01:44:20 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2012-03-22 01:44:20 +0000
commit2e2475e8d275a770779144663fee23b401a6ce13 (patch)
tree5a88ea7fc8280d284edc70b122ae860aee8515d7
parent28b53b23fb896b2ac25241cc161d67f65b88b054 (diff)
Update alphasort() and scandir()'s argument types to match POSIX:
use "const struct dirent **" instead of "const void *". Also, add __restrict to readdir_r(). ok matthew@
-rw-r--r--include/dirent.h13
-rw-r--r--lib/libc/gen/scandir.c10
-rw-r--r--usr.sbin/lpr/lpc/cmds.c9
3 files changed, 15 insertions, 17 deletions
diff --git a/include/dirent.h b/include/dirent.h
index c59fc1e0461..0d5884cb3cb 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dirent.h,v 1.25 2012/03/22 01:13:40 matthew Exp $ */
+/* $OpenBSD: dirent.h,v 1.26 2012/03/22 01:44:19 guenther Exp $ */
/* $NetBSD: dirent.h,v 1.9 1995/03/26 20:13:37 jtc Exp $ */
/*-
@@ -112,12 +112,13 @@ long telldir(DIR *);
void seekdir(DIR *, long);
#endif
#if __POSIX_VISIBLE >= 199506 || __XPG_VISIBLE >= 500
-int readdir_r(DIR *, struct dirent *, struct dirent **);
+int readdir_r(DIR *__restrict, struct dirent *__restrict,
+ struct dirent **__restrict);
#endif
-#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
-int scandir(const char *, struct dirent ***,
- int (*)(struct dirent *), int (*)(const void *, const void *));
-int alphasort(const void *, const void *);
+#if __POSIX_VISIBLE >= 200809
+int scandir(const char *, struct dirent ***, int (*)(struct dirent *),
+ int (*)(const struct dirent **, const struct dirent **));
+int alphasort(const struct dirent **, const struct dirent **);
#endif
#if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE > 600
int (dirfd)(DIR *);
diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c
index 2ad8c3e612e..b2b08a64c82 100644
--- a/lib/libc/gen/scandir.c
+++ b/lib/libc/gen/scandir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scandir.c,v 1.12 2007/09/02 15:19:16 deraadt Exp $ */
+/* $OpenBSD: scandir.c,v 1.13 2012/03/22 01:44:19 guenther Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -56,7 +56,8 @@
int
scandir(const char *dirname, struct dirent ***namelist,
- int (*select)(struct dirent *), int (*dcomp)(const void *, const void *))
+ int (*select)(struct dirent *),
+ int (*dcomp)(const struct dirent **, const struct dirent **))
{
struct dirent *d, *p, **names = NULL;
size_t nitems = 0;
@@ -139,8 +140,7 @@ fail:
* Alphabetic order comparison routine for those who want it.
*/
int
-alphasort(const void *d1, const void *d2)
+alphasort(const struct dirent **d1, const struct dirent **d2)
{
- return(strcmp((*(struct dirent **)d1)->d_name,
- (*(struct dirent **)d2)->d_name));
+ return(strcmp((*d1)->d_name, (*d2)->d_name));
}
diff --git a/usr.sbin/lpr/lpc/cmds.c b/usr.sbin/lpr/lpc/cmds.c
index b964ae679c3..c9a444b59ae 100644
--- a/usr.sbin/lpr/lpc/cmds.c
+++ b/usr.sbin/lpr/lpc/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.22 2012/03/04 04:05:15 fgsch Exp $ */
+/* $OpenBSD: cmds.c,v 1.23 2012/03/22 01:44:19 guenther Exp $ */
/* $NetBSD: cmds.c,v 1.12 1997/10/05 15:12:06 mrg Exp $ */
/*
@@ -63,7 +63,7 @@ static int doselect(struct dirent *);
static void enablepr(void);
static void prstat(void);
static void putmsg(int, char **);
-static int sortq(const void *, const void *);
+static int sortq(const struct dirent **, const struct dirent **);
static void startpr(int);
static void stoppr(void);
static int touch(struct queue *);
@@ -265,13 +265,10 @@ doselect(struct dirent *d)
* by `cf', `tf', or `df', then by the sequence letter A-Z, a-z.
*/
static int
-sortq(const void *a, const void *b)
+sortq(const struct dirent **d1, const struct dirent **d2)
{
- const struct dirent **d1, **d2;
int c1, c2;
- d1 = (const struct dirent **)a;
- d2 = (const struct dirent **)b;
if ((c1 = strcmp((*d1)->d_name + 3, (*d2)->d_name + 3)) != 0)
return(c1);
c1 = (*d1)->d_name[0];