summaryrefslogtreecommitdiff
path: root/lib/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/fmt_scaled.c7
-rw-r--r--lib/libutil/fparseln.c32
-rw-r--r--lib/libutil/getmaxpartitions.c4
-rw-r--r--lib/libutil/getrawpartition.c4
-rw-r--r--lib/libutil/login.c7
-rw-r--r--lib/libutil/login_tty.c7
-rw-r--r--lib/libutil/logout.c7
-rw-r--r--lib/libutil/logwtmp.c9
-rw-r--r--lib/libutil/opendev.c12
-rw-r--r--lib/libutil/opendisk.c9
-rw-r--r--lib/libutil/pidfile.c6
-rw-r--r--lib/libutil/pty.c24
-rw-r--r--lib/libutil/readlabel.c31
-rw-r--r--lib/libutil/uucplock.c35
14 files changed, 77 insertions, 117 deletions
diff --git a/lib/libutil/fmt_scaled.c b/lib/libutil/fmt_scaled.c
index 9f75b102432..31657eb54d4 100644
--- a/lib/libutil/fmt_scaled.c
+++ b/lib/libutil/fmt_scaled.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fmt_scaled.c,v 1.2 2003/12/27 19:49:51 otto Exp $ */
+/* $OpenBSD: fmt_scaled.c,v 1.3 2004/05/28 07:03:47 deraadt Exp $ */
/*
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@@ -37,7 +37,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char ident[] = "$OpenBSD: fmt_scaled.c,v 1.2 2003/12/27 19:49:51 otto Exp $";
+static const char ident[] = "$OpenBSD: fmt_scaled.c,v 1.3 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -126,7 +126,8 @@ scan_scaled(char *scaled, long long *result)
i = (*p) - '0'; /* whew! finally a digit we can use */
if (fract_digits > 0) {
if (fract_digits >= MAX_DIGITS-1)
- continue; /* ignore extra fractional digits */
+ /* ignore extra fractional digits */
+ continue;
fract_digits++; /* for later scaling */
fpart *= 10;
fpart += i;
diff --git a/lib/libutil/fparseln.c b/lib/libutil/fparseln.c
index ceb1143b049..6807ac35b4b 100644
--- a/lib/libutil/fparseln.c
+++ b/lib/libutil/fparseln.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fparseln.c,v 1.4 2002/06/09 22:18:43 fgsch Exp $ */
+/* $OpenBSD: fparseln.c,v 1.5 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: fparseln.c,v 1.7 1999/07/02 15:49:12 simonb Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: fparseln.c,v 1.4 2002/06/09 22:18:43 fgsch Exp $";
+static const char rcsid[] = "$OpenBSD: fparseln.c,v 1.5 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
@@ -49,9 +49,7 @@ static int isescaped(const char *, const char *, int);
* that starts in *sp, is escaped by the escape character esc.
*/
static int
-isescaped(sp, p, esc)
- const char *sp, *p;
- int esc;
+isescaped(const char *sp, const char *p, int esc)
{
const char *cp;
size_t ne;
@@ -75,24 +73,13 @@ isescaped(sp, p, esc)
* the comment char.
*/
char *
-fparseln(fp, size, lineno, str, flags)
- FILE *fp;
- size_t *size;
- size_t *lineno;
- const char str[3];
- int flags;
+fparseln(FILE *fp, size_t *size, size_t *lineno, const char str[3],
+ int flags)
{
static const char dstr[3] = { '\\', '\\', '#' };
-
- size_t s, len;
- char *buf;
- char *ptr, *cp;
- int cnt;
- char esc, con, nl, com;
-
- len = 0;
- buf = NULL;
- cnt = 1;
+ char *buf = NULL, *ptr, *cp, esc, con, nl, com;
+ size_t s, len = 0;
+ int cnt = 1;
if (str == NULL)
str = dstr;
@@ -100,6 +87,7 @@ fparseln(fp, size, lineno, str, flags)
esc = str[0];
con = str[1];
com = str[2];
+
/*
* XXX: it would be cool to be able to specify the newline character,
* but unfortunately, fgetln does not let us
@@ -124,7 +112,7 @@ fparseln(fp, size, lineno, str, flags)
}
}
- if (s && nl) { /* Check and eliminate newlines */
+ if (s && nl) { /* Check and eliminate newlines */
cp = &ptr[s - 1];
if (*cp == nl)
diff --git a/lib/libutil/getmaxpartitions.c b/lib/libutil/getmaxpartitions.c
index 1efab27a090..41a7b044bba 100644
--- a/lib/libutil/getmaxpartitions.c
+++ b/lib/libutil/getmaxpartitions.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getmaxpartitions.c,v 1.3 2002/06/09 22:18:43 fgsch Exp $ */
+/* $OpenBSD: getmaxpartitions.c,v 1.4 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:31 thorpej Exp $ */
/*-
@@ -47,7 +47,7 @@ static const char rcsid[] = "$NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:
#include "util.h"
int
-getmaxpartitions()
+getmaxpartitions(void)
{
int maxpart, mib[2];
size_t varlen;
diff --git a/lib/libutil/getrawpartition.c b/lib/libutil/getrawpartition.c
index 69a349800ab..e4290c36f11 100644
--- a/lib/libutil/getrawpartition.c
+++ b/lib/libutil/getrawpartition.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getrawpartition.c,v 1.3 2002/06/09 22:18:43 fgsch Exp $ */
+/* $OpenBSD: getrawpartition.c,v 1.4 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:33 thorpej Exp $ */
/*-
@@ -47,7 +47,7 @@ static const char rcsid[] = "$NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:3
#include "util.h"
int
-getrawpartition()
+getrawpartition(void)
{
int rawpart, mib[2];
size_t varlen;
diff --git a/lib/libutil/login.c b/lib/libutil/login.c
index 2a34c502a89..f97f00f9fac 100644
--- a/lib/libutil/login.c
+++ b/lib/libutil/login.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login.c,v 1.8 2003/06/02 20:18:42 millert Exp $ */
+/* $OpenBSD: login.c,v 1.9 2004/05/28 07:03:47 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93"; */
-static const char rcsid[] = "$Id: login.c,v 1.8 2003/06/02 20:18:42 millert Exp $";
+static const char rcsid[] = "$Id: login.c,v 1.9 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -45,8 +45,7 @@ static const char rcsid[] = "$Id: login.c,v 1.8 2003/06/02 20:18:42 millert Exp
#include "util.h"
void
-login(utp)
- struct utmp *utp;
+login(struct utmp *utp)
{
struct utmp old_ut;
register int fd;
diff --git a/lib/libutil/login_tty.c b/lib/libutil/login_tty.c
index 92d0e1f558b..e71d8c543f2 100644
--- a/lib/libutil/login_tty.c
+++ b/lib/libutil/login_tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login_tty.c,v 1.5 2003/06/02 20:18:42 millert Exp $ */
+/* $OpenBSD: login_tty.c,v 1.6 2004/05/28 07:03:47 deraadt Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; */
-static const char rcsid[] = "$Id: login_tty.c,v 1.5 2003/06/02 20:18:42 millert Exp $";
+static const char rcsid[] = "$Id: login_tty.c,v 1.6 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -40,8 +40,7 @@ static const char rcsid[] = "$Id: login_tty.c,v 1.5 2003/06/02 20:18:42 millert
#include "util.h"
int
-login_tty(fd)
- int fd;
+login_tty(int fd)
{
(void) setsid();
if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1)
diff --git a/lib/libutil/logout.c b/lib/libutil/logout.c
index 80caea10175..e882c1f4bc3 100644
--- a/lib/libutil/logout.c
+++ b/lib/libutil/logout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logout.c,v 1.6 2003/06/02 20:18:42 millert Exp $ */
+/* $OpenBSD: logout.c,v 1.7 2004/05/28 07:03:47 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93"; */
-static const char rcsid[] = "$Id: logout.c,v 1.6 2003/06/02 20:18:42 millert Exp $";
+static const char rcsid[] = "$Id: logout.c,v 1.7 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -47,8 +47,7 @@ static const char rcsid[] = "$Id: logout.c,v 1.6 2003/06/02 20:18:42 millert Exp
typedef struct utmp UTMP;
int
-logout(line)
- const char *line;
+logout(const char *line)
{
int fd, rval;
UTMP ut;
diff --git a/lib/libutil/logwtmp.c b/lib/libutil/logwtmp.c
index 08e807dc83b..7e8a1db09ba 100644
--- a/lib/libutil/logwtmp.c
+++ b/lib/libutil/logwtmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logwtmp.c,v 1.6 2003/06/02 20:18:42 millert Exp $ */
+/* $OpenBSD: logwtmp.c,v 1.7 2004/05/28 07:03:47 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; */
-static const char rcsid[] = "$Id: logwtmp.c,v 1.6 2003/06/02 20:18:42 millert Exp $";
+static const char rcsid[] = "$Id: logwtmp.c,v 1.7 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -45,11 +45,10 @@ static const char rcsid[] = "$Id: logwtmp.c,v 1.6 2003/06/02 20:18:42 millert Ex
#include "util.h"
void
-logwtmp(line, name, host)
- const char *line, *name, *host;
+logwtmp(const char *line, const char *name, const char *host)
{
- struct utmp ut;
struct stat buf;
+ struct utmp ut;
int fd;
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
diff --git a/lib/libutil/opendev.c b/lib/libutil/opendev.c
index 5e3f9076378..24e24a0775a 100644
--- a/lib/libutil/opendev.c
+++ b/lib/libutil/opendev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opendev.c,v 1.7 2002/06/09 22:18:43 fgsch Exp $ */
+/* $OpenBSD: opendev.c,v 1.8 2004/05/28 07:03:47 deraadt Exp $ */
/*
* Copyright (c) 2000, Todd C. Miller. All rights reserved.
@@ -41,15 +41,11 @@
*/
int
-opendev(path, oflags, dflags, realpath)
- char *path;
- int oflags;
- int dflags;
- char **realpath;
+opendev(char *path, int oflags, int dflags, char **realpath)
{
- int fd;
- char *slash, *prefix;
static char namebuf[PATH_MAX];
+ char *slash, *prefix;
+ int fd;
/* Initial state */
if (realpath)
diff --git a/lib/libutil/opendisk.c b/lib/libutil/opendisk.c
index fba222d80c1..6ca7b297717 100644
--- a/lib/libutil/opendisk.c
+++ b/lib/libutil/opendisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: opendisk.c,v 1.2 2001/08/16 18:34:40 millert Exp $ */
+/* $OpenBSD: opendisk.c,v 1.3 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: opendisk.c,v 1.4 1997/09/30 17:13:50 phil Exp $ */
/*-
@@ -49,12 +49,7 @@
#include "util.h"
int
-opendisk(path, flags, buf, buflen, iscooked)
- const char *path;
- int flags;
- char *buf;
- size_t buflen;
- int iscooked;
+opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked)
{
int f, rawpart;
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index 7c5a1e7453a..532e63c42b1 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pidfile.c,v 1.5 2002/05/26 09:29:02 deraadt Exp $ */
+/* $OpenBSD: pidfile.c,v 1.6 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: pidfile.c,v 1.4 2001/02/19 22:43:42 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: pidfile.c,v 1.5 2002/05/26 09:29:02 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: pidfile.c,v 1.6 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -59,9 +59,9 @@ extern char *__progname;
int
pidfile(const char *basename)
{
- FILE *f;
int save_errno;
pid_t pid;
+ FILE *f;
if (basename == NULL)
basename = __progname;
diff --git a/lib/libutil/pty.c b/lib/libutil/pty.c
index bd6fa2cfb8c..4fccc1a341a 100644
--- a/lib/libutil/pty.c
+++ b/lib/libutil/pty.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: pty.c,v 1.12 2004/04/11 18:04:36 millert Exp $ */
+/* $OpenBSD: pty.c,v 1.13 2004/05/28 07:03:47 deraadt Exp $ */
+
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -30,7 +31,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)pty.c 8.1 (Berkeley) 6/4/93"; */
-static const char rcsid[] = "$Id: pty.c,v 1.12 2004/04/11 18:04:36 millert Exp $";
+static const char rcsid[] = "$Id: pty.c,v 1.13 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
@@ -52,32 +53,29 @@ static const char rcsid[] = "$Id: pty.c,v 1.12 2004/04/11 18:04:36 millert Exp $
#define TTY_SUFFIX "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
int
-openpty(amaster, aslave, name, termp, winp)
- int *amaster, *aslave;
- char *name;
- struct termios *termp;
- struct winsize *winp;
+openpty(int *amaster, int *aslave, char *name, struct termios *termp,
+ struct winsize *winp)
{
char line[] = "/dev/ptyXX";
const char *cp1, *cp2;
- int master, slave, ttygid;
- struct group *gr;
+ int master, slave, fd;
struct ptmget ptm;
- int fd;
+ struct group *gr;
+ gid_t ttygid;
- /* Try to use /dev/ptm and the PTMGET ioctl to get a properly set up
+ /*
+ * Try to use /dev/ptm and the PTMGET ioctl to get a properly set up
* and owned pty/tty pair. If this fails, (because we might not have
* the ptm device, etc.) fall back to using the traditional method
* of walking through the pty entries in /dev for the moment, until
* there is less chance of people being seriously boned by running
* kernels without /dev/ptm in them.
*/
-
fd = open(PATH_PTMDEV, O_RDWR, 0);
if (fd == -1)
goto walkit;
if ((ioctl(fd, PTMGET, &ptm) == -1)) {
- close(fd);
+ close(fd);
goto walkit;
}
close(fd);
diff --git a/lib/libutil/readlabel.c b/lib/libutil/readlabel.c
index 6eef5825815..b9dfd724858 100644
--- a/lib/libutil/readlabel.c
+++ b/lib/libutil/readlabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readlabel.c,v 1.7 2002/02/21 16:22:23 deraadt Exp $ */
+/* $OpenBSD: readlabel.c,v 1.8 2004/05/28 07:03:47 deraadt Exp $ */
/*
* Copyright (c) 1996, Jason Downs. All rights reserved.
@@ -46,24 +46,22 @@
* Try to get a disklabel for the specified device, and return mount_xxx
* style filesystem type name for the specified partition.
*/
-
-char *readlabelfs(device, verbose)
- char *device;
- int verbose;
+char *
+readlabelfs(char *device, int verbose)
{
char rpath[MAXPATHLEN];
+ struct disklabel dk;
char part, *type;
struct stat sbuf;
- struct disklabel dk;
int fd;
/* Assuming device is of the form /dev/??p, build a raw partition. */
if (stat(device, &sbuf) < 0) {
if (verbose)
warn("%s", device);
- return(NULL);
+ return (NULL);
}
- switch(sbuf.st_mode & S_IFMT) {
+ switch (sbuf.st_mode & S_IFMT) {
case S_IFCHR:
/* Ok... already a raw device. Hmm. */
strncpy(rpath, device, sizeof(rpath));
@@ -77,7 +75,6 @@ char *readlabelfs(device, verbose)
if (strlen(device) > sizeof(_PATH_DEV) - 1) {
snprintf(rpath, sizeof(rpath), "%sr%s", _PATH_DEV,
&device[sizeof(_PATH_DEV) - 1]);
-
/* Change partition name. */
part = rpath[strlen(rpath) - 1];
rpath[strlen(rpath) - 1] = 'a' + getrawpartition();
@@ -86,7 +83,7 @@ char *readlabelfs(device, verbose)
default:
if (verbose)
warnx("%s: not a device node", device);
- return(NULL);
+ return (NULL);
}
/* If rpath doesn't exist, change that partition back. */
@@ -99,28 +96,28 @@ char *readlabelfs(device, verbose)
if (fd < 0) {
if (verbose)
warn("%s", rpath);
- return(NULL);
+ return (NULL);
}
} else {
- if (verbose)
- warn("%s", rpath);
- return(NULL);
+ if (verbose)
+ warn("%s", rpath);
+ return (NULL);
}
}
if (ioctl(fd, DIOCGDINFO, &dk) < 0) {
if (verbose)
warn("%s: couldn't read disklabel", rpath);
close(fd);
- return(NULL);
+ return (NULL);
}
close(fd);
if (dk.d_partitions[part - 'a'].p_fstype > FSMAXTYPES) {
if (verbose)
warnx("%s: bad filesystem type in label", rpath);
- return(NULL);
+ return (NULL);
}
type = fstypesnames[dk.d_partitions[part - 'a'].p_fstype];
- return((type[0] == '\0') ? NULL : type);
+ return ((type[0] == '\0') ? NULL : type);
}
diff --git a/lib/libutil/uucplock.c b/lib/libutil/uucplock.c
index 7c584401d15..e7a471bb2e1 100644
--- a/lib/libutil/uucplock.c
+++ b/lib/libutil/uucplock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uucplock.c,v 1.11 2003/06/02 20:18:42 millert Exp $ */
+/* $OpenBSD: uucplock.c,v 1.12 2004/05/28 07:03:48 deraadt Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -61,22 +61,19 @@ static pid_t get_pid(int fd,int *err);
/*
* uucp style locking routines
*/
-
int
-uu_lock(ttyname)
- const char *ttyname;
+uu_lock(const char *ttyname)
{
- int fd, tmpfd, i;
- pid_t pid, pid_old;
char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN],
lcktmpname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
- int err, uuerr;
+ int fd, tmpfd, i, err, uuerr;
+ pid_t pid, pid_old;
pid = getpid();
(void)snprintf(lcktmpname, sizeof(lcktmpname), _PATH_UUCPLOCK LOCKTMP,
- (long)pid);
+ (long)pid);
(void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT,
- ttyname);
+ ttyname);
if ((tmpfd = creat(lcktmpname, 0664)) < 0)
GORET(0, UU_LOCK_CREAT_ERR);
@@ -126,12 +123,10 @@ ret0:
}
int
-uu_lock_txfr(ttyname, pid)
- const char *ttyname;
- pid_t pid;
+uu_lock_txfr(const char *ttyname, pid_t pid)
{
- int fd, err;
char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
+ int fd, err;
snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, ttyname);
@@ -148,8 +143,7 @@ uu_lock_txfr(ttyname, pid)
}
int
-uu_unlock(ttyname)
- const char *ttyname;
+uu_unlock(const char *ttyname)
{
char tbuf[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
@@ -158,8 +152,7 @@ uu_unlock(ttyname)
}
const char *
-uu_lockerr(uu_lockresult)
- int uu_lockresult;
+uu_lockerr(int uu_lockresult)
{
static char errbuf[128];
char *fmt;
@@ -200,9 +193,7 @@ uu_lockerr(uu_lockresult)
}
static int
-put_pid(fd, pid)
- int fd;
- pid_t pid;
+put_pid(int fd, pid_t pid)
{
char buf[32];
int len;
@@ -218,9 +209,7 @@ put_pid(fd, pid)
}
static pid_t
-get_pid(fd, err)
- int fd;
- int *err;
+get_pid(int fd, int *err)
{
int bytes_read;
char buf[32];