summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Hogan <doug@cvs.openbsd.org>2015-01-16 08:24:05 +0000
committerDoug Hogan <doug@cvs.openbsd.org>2015-01-16 08:24:05 +0000
commit073415a570ee47dead47bc078497303ec568f930 (patch)
treeb59f8e3bd7cf6e0bb47d3c083e8d9a60be619933
parent21dca6169dc139d708f12376dcecf86f6cd67ebc (diff)
Replace <sys/param.h> with <limits.h>
This patch is from Theo. I helped verify that removing <sys/param.h> doesn't change anything. This produces the same binaries before and after with clang 3.5 and gcc 4.9.4 on amd64. There is a slight difference in the way it is generated by our old gcc 4.2.1 despite the fact that the preprocessed input is almost identical. ok deraadt@
-rw-r--r--usr.bin/file/apprentice.c12
-rw-r--r--usr.bin/file/file.c9
-rw-r--r--usr.bin/file/magic.c3
3 files changed, 11 insertions, 13 deletions
diff --git a/usr.bin/file/apprentice.c b/usr.bin/file/apprentice.c
index e19382a19a8..1c6a49e96e6 100644
--- a/usr.bin/file/apprentice.c
+++ b/usr.bin/file/apprentice.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apprentice.c,v 1.32 2014/10/26 04:10:26 brad Exp $ */
+/* $OpenBSD: apprentice.c,v 1.33 2015/01/16 08:24:04 doug Exp $ */
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
@@ -30,7 +30,7 @@
* apprentice - make one pass through /etc/magic, learning its secrets.
*/
-#include <sys/param.h>
+
#include <sys/stat.h>
#include <sys/types.h>
@@ -73,8 +73,8 @@
#define MAP_FILE 0
#endif
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
+#ifndef PATH_MAX
+#define PATH_MAX 1024
#endif
struct magic_entry {
@@ -620,7 +620,7 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
int errs = 0;
struct magic_entry *marray;
uint32_t marraycount, i, mentrycount = 0, starttest;
- char subfn[MAXPATHLEN];
+ char subfn[PATH_MAX];
struct stat st;
DIR *dir;
struct dirent *d;
@@ -2034,7 +2034,7 @@ mkdbname(const char *fn, char **buf, int strip)
}
(void)asprintf(buf, "%s%s", fn, ext);
- if (*buf && strlen(*buf) > MAXPATHLEN) {
+ if (*buf && strlen(*buf) > PATH_MAX) {
free(*buf);
*buf = NULL;
}
diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c
index 168583572a8..310bce7b15d 100644
--- a/usr.bin/file/file.c
+++ b/usr.bin/file/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.24 2015/01/16 05:46:44 deraadt Exp $ */
+/* $OpenBSD: file.c,v 1.25 2015/01/16 08:24:04 doug Exp $ */
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
@@ -31,7 +31,6 @@
*/
#include <sys/types.h>
-#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/stat.h>
#include "file.h"
@@ -81,8 +80,8 @@ int getopt_long(int argc, char * const *argv, const char *optstring, const struc
# define USAGE "Usage: %s [-bcik" SYMLINKFLAG "nNprsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...\n" \
" %s -C -m magicfiles\n"
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
+#ifndef PATH_MAX
+#define PATH_MAX 1024
#endif
private int /* Global command-line options */
@@ -355,7 +354,7 @@ load(const char *m, int flags)
private void
unwrap(char *fn)
{
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
FILE *f;
int wid = 0, cwid;
diff --git a/usr.bin/file/magic.c b/usr.bin/file/magic.c
index eab02d13832..0e9fd1c66c6 100644
--- a/usr.bin/file/magic.c
+++ b/usr.bin/file/magic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: magic.c,v 1.9 2014/10/11 03:06:44 doug Exp $ */
+/* $OpenBSD: magic.c,v 1.10 2015/01/16 08:24:04 doug Exp $ */
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
@@ -27,7 +27,6 @@
*/
#include <sys/types.h>
-#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/stat.h>
#include "file.h"