summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cdio/cdio.c8
-rw-r--r--usr.bin/cdio/extern.h5
-rw-r--r--usr.bin/cdio/mmc.c9
-rw-r--r--usr.bin/cvs/remote.c13
-rw-r--r--usr.bin/rcs/rcs.c10
-rw-r--r--usr.bin/rsync/copy.c8
-rw-r--r--usr.bin/split/split.c9
-rw-r--r--usr.bin/wc/wc.c13
-rw-r--r--usr.bin/xinstall/xinstall.c8
9 files changed, 47 insertions, 36 deletions
diff --git a/usr.bin/cdio/cdio.c b/usr.bin/cdio/cdio.c
index d8a7a330bac..0bf6f03c797 100644
--- a/usr.bin/cdio/cdio.c
+++ b/usr.bin/cdio/cdio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cdio.c,v 1.82 2021/10/24 21:24:16 deraadt Exp $ */
+/* $OpenBSD: cdio.c,v 1.83 2021/11/28 19:28:41 deraadt Exp $ */
/* Copyright (c) 1995 Serge V. Vakulenko
* All rights reserved.
@@ -52,7 +52,7 @@
* $FreeBSD: cdcontrol.c,v 1.13 1996/06/25 21:01:27 ache Exp $
*/
-#include <sys/param.h> /* isset */
+#include <sys/types.h>
#include <sys/cdio.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
@@ -526,7 +526,7 @@ run(int cmd, char *arg)
warnx("Can't determine media type");
return (0);
}
- if (isset(mediacap, MMC_FEATURE_CDRW_WRITE) == 0 &&
+ if (cdio_isset(mediacap, MMC_FEATURE_CDRW_WRITE) == 0 &&
get_media_type() != MEDIATYPE_CDRW) {
warnx("The media doesn't support blanking");
return (0);
@@ -669,7 +669,7 @@ tao(int argc, char **argv)
exit(1);
if (get_media_capabilities(mediacap, 1) == -1)
errx(1, "Can't determine media type");
- if (isset(mediacap, MMC_FEATURE_CD_TAO) == 0)
+ if (cdio_isset(mediacap, MMC_FEATURE_CD_TAO) == 0)
errx(1, "The media can't be written in TAO mode");
get_disc_size(&availblk);
diff --git a/usr.bin/cdio/extern.h b/usr.bin/cdio/extern.h
index f7d67f04e41..ee765981b97 100644
--- a/usr.bin/cdio/extern.h
+++ b/usr.bin/cdio/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.16 2021/01/18 00:44:00 mortimer Exp $ */
+/* $OpenBSD: extern.h,v 1.17 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2002 Marc Espie.
*
@@ -26,6 +26,9 @@
#include <sys/queue.h>
+#define cdio_isset(a,i) ((a)[(i)>>3] & (1<<((i)&(NBBY-1))))
+#define cdio_setbit(a,i) ((a)[(i)>>3] |= 1<<((i)&(NBBY-1)))
+
struct cd_toc_entry;
struct track_info {
off_t sz;
diff --git a/usr.bin/cdio/mmc.c b/usr.bin/cdio/mmc.c
index 0e17d31ab8e..9e091cc3bcc 100644
--- a/usr.bin/cdio/mmc.c
+++ b/usr.bin/cdio/mmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmc.c,v 1.32 2020/09/01 17:20:02 krw Exp $ */
+/* $OpenBSD: mmc.c,v 1.33 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2006 Michael Coulter <mjc@openbsd.org>
*
@@ -15,11 +15,10 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/types.h>
#include <sys/limits.h>
#include <sys/time.h>
-#include <sys/types.h>
#include <sys/scsiio.h>
-#include <sys/param.h> /* setbit, isset */
#include <scsi/cd.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_disk.h>
@@ -274,7 +273,7 @@ get_media_capabilities(u_int8_t *cap, int rt)
"" );
}
}
- setbit(cap, feature);
+ cdio_setbit(cap, feature);
}
return (0);
@@ -288,7 +287,7 @@ set_speed(int wspeed)
memset(&scr, 0, sizeof(scr));
scr.cmd[0] = SET_CD_SPEED;
- scr.cmd[1] = (isset(mediacap, MMC_FEATURE_CDRW_CAV)) != 0;
+ scr.cmd[1] = (cdio_isset(mediacap, MMC_FEATURE_CDRW_CAV)) != 0;
*(u_int16_t *)(scr.cmd + 2) = htobe16(DRIVE_SPEED_OPTIMAL);
*(u_int16_t *)(scr.cmd + 4) = htobe16(wspeed);
diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c
index d99b8d59e9b..8d3361e5723 100644
--- a/usr.bin/cvs/remote.c
+++ b/usr.bin/cvs/remote.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.c,v 1.33 2019/06/28 13:35:00 deraadt Exp $ */
+/* $OpenBSD: remote.c,v 1.34 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@@ -29,6 +29,7 @@
#include "remote.h"
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define _MAXBSIZE (64 * 1024)
struct cvs_resp *
cvs_remote_get_response_info(const char *response)
@@ -128,7 +129,7 @@ void
cvs_remote_receive_file(int fd, size_t len)
{
FILE *in;
- char data[MAXBSIZE];
+ char data[_MAXBSIZE];
size_t nread, nleft, toread;
if (cvs_server_active)
@@ -139,7 +140,7 @@ cvs_remote_receive_file(int fd, size_t len)
nleft = len;
while (nleft > 0) {
- toread = MINIMUM(nleft, MAXBSIZE);
+ toread = MINIMUM(nleft, sizeof data);
nread = fread(data, sizeof(char), toread, in);
if (nread == 0)
@@ -165,7 +166,7 @@ cvs_remote_send_file(const char *path, int _fd)
size_t ret, rw;
off_t total;
struct stat st;
- char buf[18], data[MAXBSIZE];
+ char buf[18], data[_MAXBSIZE];
if (cvs_server_active)
out = stdout;
@@ -194,7 +195,7 @@ cvs_remote_send_file(const char *path, int _fd)
fatal("cvs_remote_send_file: fdopen %s", strerror(errno));
total = 0;
- while ((ret = fread(data, sizeof(char), MAXBSIZE, in)) != 0) {
+ while ((ret = fread(data, sizeof(char), sizeof data, in)) != 0) {
rw = fwrite(data, sizeof(char), ret, out);
if (rw != ret)
fatal("failed to write %zu bytes", ret);
diff --git a/usr.bin/rcs/rcs.c b/usr.bin/rcs/rcs.c
index 30415b9de17..6528a4d1f34 100644
--- a/usr.bin/rcs/rcs.c
+++ b/usr.bin/rcs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.88 2019/01/09 17:57:05 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.89 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -24,7 +24,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -44,6 +44,8 @@
#include "rcsutil.h"
#include "xmalloc.h"
+#define _MAXBSIZE (64 * 1024)
+
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
/* invalid characters in RCS states */
@@ -395,8 +397,8 @@ rcs_movefile(char *from, char *to, mode_t perm, u_int to_flags)
return (-1);
}
- buf = xmalloc(MAXBSIZE);
- while ((nread = fread(buf, sizeof(char), MAXBSIZE, src)) != 0) {
+ buf = xmalloc(_MAXBSIZE);
+ while ((nread = fread(buf, sizeof(char), _MAXBSIZE, src)) != 0) {
if (ferror(src)) {
warnx("failed to read `%s'", from);
(void)unlink(to);
diff --git a/usr.bin/rsync/copy.c b/usr.bin/rsync/copy.c
index f133508cda0..f6a43d28434 100644
--- a/usr.bin/rsync/copy.c
+++ b/usr.bin/rsync/copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: copy.c,v 1.2 2021/10/24 21:24:17 deraadt Exp $ */
+/* $OpenBSD: copy.c,v 1.3 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
*
@@ -15,7 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <err.h>
#include <fcntl.h>
@@ -23,6 +23,8 @@
#include "extern.h"
+#define _MAXBSIZE (64 * 1024)
+
/*
* Return true if all bytes in buffer are zero.
* A buffer of zero lenght is also considered a zero buffer.
@@ -42,7 +44,7 @@ iszero(const void *b, size_t len)
static int
copy_internal(int fromfd, int tofd)
{
- char buf[MAXBSIZE];
+ char buf[_MAXBSIZE];
ssize_t r, w;
while ((r = read(fromfd, buf, sizeof(buf))) > 0) {
diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c
index 450752eb2eb..08fb8d74934 100644
--- a/usr.bin/split/split.c
+++ b/usr.bin/split/split.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: split.c,v 1.22 2021/10/24 21:24:17 deraadt Exp $ */
+/* $OpenBSD: split.c,v 1.23 2021/11/28 19:28:42 deraadt Exp $ */
/* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */
/*
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
#include <sys/types.h>
#include <ctype.h>
@@ -43,13 +42,15 @@
#include <unistd.h>
#include <regex.h>
+#define _MAXBSIZE (64 * 1024)
+
#define DEFLINE 1000 /* Default num lines per file. */
ssize_t bytecnt; /* Byte count to split on. */
long numlines; /* Line count to split on. */
int file_open; /* If a file open. */
int ifd = -1, ofd = -1; /* Input/output file descriptors. */
-char bfr[MAXBSIZE]; /* I/O buffer. */
+char bfr[_MAXBSIZE]; /* I/O buffer. */
char fname[PATH_MAX]; /* File name prefix. */
regex_t rgx;
int pflag;
@@ -176,7 +177,7 @@ split1(void)
char *C;
for (bcnt = 0;;)
- switch ((len = read(ifd, bfr, MAXBSIZE))) {
+ switch ((len = read(ifd, bfr, sizeof(bfr)))) {
case 0:
exit(0);
case -1:
diff --git a/usr.bin/wc/wc.c b/usr.bin/wc/wc.c
index 8a3c4c1cd57..009933ff802 100644
--- a/usr.bin/wc/wc.c
+++ b/usr.bin/wc/wc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wc.c,v 1.28 2021/11/16 23:34:24 cheloha Exp $ */
+/* $OpenBSD: wc.c,v 1.29 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 1980, 1987, 1991, 1993
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
#include <sys/stat.h>
#include <fcntl.h>
@@ -43,6 +42,8 @@
#include <wchar.h>
#include <wctype.h>
+#define _MAXBSIZE (64 * 1024)
+
int64_t tlinect, twordct, tcharct;
int doline, doword, dochar, humanchar, multibyte;
int rval;
@@ -145,8 +146,8 @@ cnt(const char *path)
}
if (!doword && !multibyte) {
- if (bufsz < MAXBSIZE &&
- (buf = realloc(buf, MAXBSIZE)) == NULL)
+ if (bufsz < _MAXBSIZE &&
+ (buf = realloc(buf, _MAXBSIZE)) == NULL)
err(1, NULL);
/*
* Line counting is split out because it's a lot
@@ -154,7 +155,7 @@ cnt(const char *path)
* the word count requires some logic.
*/
if (doline) {
- while ((len = read(fd, buf, MAXBSIZE)) > 0) {
+ while ((len = read(fd, buf, _MAXBSIZE)) > 0) {
charct += len;
for (C = buf; len--; ++C)
if (*C == '\n')
@@ -184,7 +185,7 @@ cnt(const char *path)
|| ifmt == S_IFDIR) {
charct = sbuf.st_size;
} else {
- while ((len = read(fd, buf, MAXBSIZE)) > 0)
+ while ((len = read(fd, buf, _MAXBSIZE)) > 0)
charct += len;
if (len == -1) {
warn("%s", file);
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index b53b7d900d2..db534bc74be 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xinstall.c,v 1.75 2021/10/24 21:24:18 deraadt Exp $ */
+/* $OpenBSD: xinstall.c,v 1.76 2021/11/28 19:28:42 deraadt Exp $ */
/* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */
/*
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -51,6 +51,8 @@
#include "pathnames.h"
+#define _MAXBSIZE (64 * 1024)
+
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define DIRECTORY 0x01 /* Tell install it's a directory. */
@@ -403,7 +405,7 @@ copy(int from_fd, char *from_name, int to_fd, char *to_name, off_t size,
{
ssize_t nr, nw;
int serrno;
- char *p, buf[MAXBSIZE];
+ char *p, buf[_MAXBSIZE];
if (size == 0)
return;