Skip to content

Commit

Permalink
Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
Browse files Browse the repository at this point in the history
use SEEK_SET/SEEK_CUR/SEEK_END instead.
  • Loading branch information
kleink committed Aug 25, 1997
1 parent 1f55164 commit 9e7a0b6
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 95 deletions.
6 changes: 3 additions & 3 deletions lib/libc/db/mpool/mpool.libtp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************

VERSION $NetBSD: mpool.libtp,v 1.3 1997/08/24 16:13:28 kleink Exp $
VERSION $NetBSD: mpool.libtp,v 1.4 1997/08/25 19:31:43 kleink Exp $
PACKAGE: User Level Shared Memory Manager

DESCRIPTION:
Expand Down Expand Up @@ -578,7 +578,7 @@ BUFHDR_T *bhp;
int nbytes;

assert ( (bhp-bufhdr_table) < NUM_BUFS );
if ( lseek ( fd, (off_t)(bhp->id.obj_id << BUFSHIFT), L_SET ) < 0 ) {
if ( lseek ( fd, (off_t)(bhp->id.obj_id << BUFSHIFT), SEEK_SET ) < 0 ) {
return(-1);
}
bhp->flags |= BUF_IO_IN_PROGRESS;
Expand Down Expand Up @@ -646,7 +646,7 @@ int *len; /* Number of bytes read */
if (RELEASE_MASTER) {
return(NULL);
}
if ( lseek ( fd, (off_t)(obj->obj_id << BUFSHIFT), L_SET ) < 0 ) {
if ( lseek ( fd, (off_t)(obj->obj_id << BUFSHIFT), SEEK_SET ) < 0 ) {
error_log2 ("Unable to perform seek on file: %d to page %d",
obj->file_id, obj->obj_id );
bhp->flags &= ~BUF_IO_IN_PROGRESS;
Expand Down
6 changes: 3 additions & 3 deletions lib/libc/gen/getcap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: getcap.c,v 1.14 1997/07/21 14:07:03 jtc Exp $ */
/* $NetBSD: getcap.c,v 1.15 1997/08/25 19:31:45 kleink Exp $ */

/*-
* Copyright (c) 1992, 1993
Expand Down Expand Up @@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
#else
__RCSID("$NetBSD: getcap.c,v 1.14 1997/07/21 14:07:03 jtc Exp $");
__RCSID("$NetBSD: getcap.c,v 1.15 1997/08/25 19:31:45 kleink Exp $");
#endif
#endif /* LIBC_SCCS and not lint */

Expand Down Expand Up @@ -260,7 +260,7 @@ getent(cap, len, db_array, fd, name, depth, nfield)
*/

if (fd >= 0) {
(void)lseek(fd, (off_t)0, L_SET);
(void)lseek(fd, (off_t)0, SEEK_SET);
} else {
(void)snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p);
if ((capdbp = dbopen(pbuf, O_RDONLY, 0, DB_HASH, 0))
Expand Down
6 changes: 3 additions & 3 deletions lib/libutil/login.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: login.c,v 1.7 1997/06/29 18:44:05 christos Exp $ */
/* $NetBSD: login.c,v 1.8 1997/08/25 19:31:46 kleink Exp $ */

/*
* Copyright (c) 1988, 1993
Expand Down Expand Up @@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: login.c,v 1.7 1997/06/29 18:44:05 christos Exp $");
__RCSID("$NetBSD: login.c,v 1.8 1997/08/25 19:31:46 kleink Exp $");
#endif
#endif /* LIBC_SCCS and not lint */

Expand All @@ -60,7 +60,7 @@ login(ut)

tty = ttyslot();
if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) {
(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), L_SET);
(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
(void)write(fd, ut, sizeof(struct utmp));
(void)close(fd);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/libutil/logout.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: logout.c,v 1.6 1997/06/29 18:44:07 christos Exp $ */
/* $NetBSD: logout.c,v 1.7 1997/08/25 19:31:46 kleink Exp $ */

/*
* Copyright (c) 1988, 1993
Expand Down Expand Up @@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: logout.c,v 1.6 1997/06/29 18:44:07 christos Exp $");
__RCSID("$NetBSD: logout.c,v 1.7 1997/08/25 19:31:46 kleink Exp $");
#endif
#endif /* LIBC_SCCS and not lint */

Expand Down Expand Up @@ -70,7 +70,7 @@ logout(line)
bzero(ut.ut_name, UT_NAMESIZE);
bzero(ut.ut_host, UT_HOSTSIZE);
(void)time(&ut.ut_time);
(void)lseek(fd, -(off_t)sizeof(UTMP), L_INCR);
(void)lseek(fd, -(off_t)sizeof(UTMP), SEEK_CUR);
(void)write(fd, &ut, sizeof(UTMP));
rval = 1;
}
Expand Down
6 changes: 3 additions & 3 deletions libexec/comsat/comsat.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static char copyright[] =

#ifndef lint
/*static char sccsid[] = "from: @(#)comsat.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$Id: comsat.c,v 1.8 1995/05/02 02:05:47 mycroft Exp $";
static char rcsid[] = "$Id: comsat.c,v 1.9 1997/08/25 19:31:47 kleink Exp $";
#endif /* not lint */

#include <sys/param.h>
Expand Down Expand Up @@ -164,7 +164,7 @@ onalrm(signo)
exit(1);
}
}
(void)lseek(uf, (off_t)0, L_SET);
(void)lseek(uf, (off_t)0, SEEK_SET);
nutmp = read(uf, utmp, (int)statbf.st_size)/sizeof(struct utmp);
}
}
Expand Down Expand Up @@ -249,7 +249,7 @@ jkfprintf(tp, name, offset)
if ((fi = fopen(name, "r")) == NULL)
return;

(void)fseek(fi, offset, L_SET);
(void)fseek(fi, offset, SEEK_SET);
/*
* Print the first 7 lines or 560 characters of the new mail
* (whichever comes first). Skip header crap other than
Expand Down
8 changes: 4 additions & 4 deletions libexec/ftpd/ftpd.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: ftpd.c,v 1.30 1997/08/14 02:06:17 lukem Exp $ */
/* $NetBSD: ftpd.c,v 1.31 1997/08/25 19:31:48 kleink Exp $ */

/*
* Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994
Expand Down Expand Up @@ -44,7 +44,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: ftpd.c,v 1.30 1997/08/14 02:06:17 lukem Exp $");
__RCSID("$NetBSD: ftpd.c,v 1.31 1997/08/25 19:31:48 kleink Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -793,7 +793,7 @@ retrieve(cmd, name)
if (c == '\n')
i++;
}
} else if (lseek(fileno(fin), restart_point, L_SET) < 0) {
} else if (lseek(fileno(fin), restart_point, SEEK_SET) < 0) {
perror_reply(550, name);
goto done;
}
Expand Down Expand Up @@ -860,7 +860,7 @@ store(name, mode, unique)
perror_reply(550, name);
goto done;
}
} else if (lseek(fileno(fout), restart_point, L_SET) < 0) {
} else if (lseek(fileno(fout), restart_point, SEEK_SET) < 0) {
perror_reply(550, name);
goto done;
}
Expand Down
5 changes: 3 additions & 2 deletions libexec/rpc.rquotad/rquotad.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: rquotad.c,v 1.7 1996/08/30 20:15:10 thorpej Exp $ */
/* $NetBSD: rquotad.c,v 1.8 1997/08/25 19:31:50 kleink Exp $ */

/*
* by Manuel Bouyer ([email protected])
Expand Down Expand Up @@ -269,7 +269,8 @@ getfsquota(id, path, dqblk)
syslog(LOG_ERR, "open error: %s: %m", fs->qfpathname);
return (0);
}
if (lseek(fd, (off_t)(id * sizeof(struct dqblk)), L_SET) == (off_t)-1) {
if (lseek(fd, (off_t)(id * sizeof(struct dqblk)), SEEK_SET)
== (off_t)-1) {
close(fd);
return (1);
}
Expand Down
7 changes: 4 additions & 3 deletions libexec/telnetd/sys_term.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: sys_term.c,v 1.9 1996/03/20 04:25:53 tls Exp $ */
/* $NetBSD: sys_term.c,v 1.10 1997/08/25 19:31:51 kleink Exp $ */

/*
* Copyright (c) 1989, 1993
Expand Down Expand Up @@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95";
#else
static char rcsid[] = "$NetBSD: sys_term.c,v 1.9 1996/03/20 04:25:53 tls Exp $";
static char rcsid[] = "$NetBSD: sys_term.c,v 1.10 1997/08/25 19:31:51 kleink Exp $";
#endif
#endif /* not lint */

Expand Down Expand Up @@ -2259,7 +2259,8 @@ rmut()
if (SCMPN(u->ut_line, line+5) ||
u->ut_name[0]==0)
continue;
(void) lseek(f, ((long)u)-((long)utmp), L_SET);
(void)lseek(f, (off_t)((long)u)-((long)utmp),
SEEK_SET);
SCPYN(u->ut_name, "");
SCPYN(u->ut_host, "");
(void) time(&u->ut_time);
Expand Down
8 changes: 4 additions & 4 deletions sbin/newlfs/newfs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: newfs.c,v 1.6 1997/08/01 06:18:29 mikel Exp $ */
/* $NetBSD: newfs.c,v 1.7 1997/08/25 19:31:52 kleink Exp $ */

/*-
* Copyright (c) 1989, 1992, 1993
Expand Down Expand Up @@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)newfs.c 8.3 (Berkeley) 4/22/94";
#else
static char rcsid[] = "$NetBSD: newfs.c,v 1.6 1997/08/01 06:18:29 mikel Exp $";
static char rcsid[] = "$NetBSD: newfs.c,v 1.7 1997/08/25 19:31:52 kleink Exp $";
#endif
#endif /* not lint */

Expand Down Expand Up @@ -422,8 +422,8 @@ rewritelabel(s, fd, lp)
*(struct disklabel *)(blk + LABELOFFSET) = *lp;
alt = lp->d_ncylinders * lp->d_secpercyl - lp->d_nsectors;
for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) {
if (lseek(cfd, (off_t)(alt + i) * lp->d_secsize,
L_SET) == -1)
if (lseek(cfd, (off_t)((alt + i) * lp->d_secsize),
SEEK_SET) == -1)
fatal("lseek to badsector area: %s",
strerror(errno));
if (write(cfd, blk, lp->d_secsize) < lp->d_secsize)
Expand Down
6 changes: 3 additions & 3 deletions sbin/savecore/savecore.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: savecore.c,v 1.30 1997/05/19 16:28:03 pk Exp $ */
/* $NetBSD: savecore.c,v 1.31 1997/08/25 19:31:53 kleink Exp $ */

/*-
* Copyright (c) 1986, 1992, 1993
Expand Down Expand Up @@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)savecore.c 8.3 (Berkeley) 1/2/94";
#else
static char rcsid[] = "$NetBSD: savecore.c,v 1.30 1997/05/19 16:28:03 pk Exp $";
static char rcsid[] = "$NetBSD: savecore.c,v 1.31 1997/08/25 19:31:53 kleink Exp $";
#endif
#endif /* not lint */

Expand Down Expand Up @@ -445,7 +445,7 @@ err1: syslog(LOG_WARNING, "%s: %s", path, strerror(errno));
}

/* Seek to the start of the core. */
Lseek(ifd, (off_t)dumplo, L_SET);
Lseek(ifd, (off_t)dumplo, SEEK_SET);

if (kvm_dump_wrtheader(kd_dump, fp, dumpsize) == -1) {
syslog(LOG_ERR, "kvm_dump_wrtheader: %s : %s", path,
Expand Down
28 changes: 14 additions & 14 deletions sbin/savecore/savecore_old.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: savecore_old.c,v 1.1.1.1 1996/03/16 10:25:11 leo Exp $ */
/* $NetBSD: savecore_old.c,v 1.2 1997/08/25 19:31:54 kleink Exp $ */

/*-
* Copyright (c) 1986, 1992, 1993
Expand Down Expand Up @@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)savecore.c 8.3 (Berkeley) 1/2/94";
#else
static char rcsid[] = "$NetBSD: savecore_old.c,v 1.1.1.1 1996/03/16 10:25:11 leo Exp $";
static char rcsid[] = "$NetBSD: savecore_old.c,v 1.2 1997/08/25 19:31:54 kleink Exp $";
#endif
#endif /* not lint */

Expand Down Expand Up @@ -237,19 +237,19 @@ kmem_setup()
}

kmem = Open(_PATH_KMEM, O_RDONLY);
Lseek(kmem, (off_t)current_nl[X_DUMPDEV].n_value, L_SET);
Lseek(kmem, (off_t)(current_nl[X_DUMPDEV].n_value), SEEK_SET);
(void)Read(kmem, &dumpdev, sizeof(dumpdev));
if (dumpdev == NODEV) {
syslog(LOG_WARNING, "no core dump (no dumpdev)");
exit(1);
}
Lseek(kmem, (off_t)current_nl[X_DUMPLO].n_value, L_SET);
Lseek(kmem, (off_t)(current_nl[X_DUMPLO].n_value), SEEK_SET);
(void)Read(kmem, &dumplo, sizeof(dumplo));
dumplo *= DEV_BSIZE;
if (verbose)
(void)printf("dumplo = %d (%d * %d)\n",
dumplo, dumplo / DEV_BSIZE, DEV_BSIZE);
Lseek(kmem, (off_t)current_nl[X_DUMPMAG].n_value, L_SET);
Lseek(kmem, (off_t)(current_nl[X_DUMPMAG].n_value), SEEK_SET);
(void)Read(kmem, &dumpmag, sizeof(dumpmag));
ddname = find_dev(dumpdev, S_IFBLK);
dumpfd = Open(ddname, O_RDWR);
Expand All @@ -260,7 +260,7 @@ kmem_setup()
}
if (kernel)
return;
(void)fseek(fp, (off_t)current_nl[X_VERSION].n_value, L_SET);
(void)fseek(fp, (current_nl[X_VERSION].n_value, SEEK_SET);
(void)fgets(vers, sizeof(vers), fp);

/* Don't fclose(fp), we use dumpfd later. */
Expand All @@ -278,17 +278,17 @@ check_kmem()
syslog(LOG_ERR, "%s: fdopen: %m", ddname);
exit(1);
}
fseek(fp, (off_t)(dumplo + ok(dump_nl[X_VERSION].n_value)), L_SET);
fseek(fp, dumplo + ok(dump_nl[X_VERSION].n_value), SEEK_SET);
fgets(core_vers, sizeof(core_vers), fp);
if (strcmp(vers, core_vers) && kernel == 0)
syslog(LOG_WARNING,
"warning: %s version mismatch:\n\t%s\nand\t%s\n",
_PATH_UNIX, vers, core_vers);
(void)fseek(fp,
(off_t)(dumplo + ok(dump_nl[X_PANICSTR].n_value)), L_SET);
dumplo + ok(dump_nl[X_PANICSTR].n_value), SEEK_SET);
(void)fread(&panicstr, sizeof(panicstr), 1, fp);
if (panicstr) {
(void)fseek(fp, dumplo + ok(panicstr), L_SET);
(void)fseek(fp, dumplo + ok(panicstr), SEEK_SET);
cp = panic_mesg;
do
*cp = getc(fp);
Expand All @@ -303,7 +303,7 @@ clear_dump()
long newdumplo;

newdumplo = 0;
Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_DUMPMAG].n_value)), L_SET);
Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_DUMPMAG].n_value)), SEEK_SET);
Write(dumpfd, &newdumplo, sizeof(newdumplo));
}

Expand All @@ -312,11 +312,11 @@ dump_exists()
{
int newdumpmag;

Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_DUMPMAG].n_value)), L_SET);
Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_DUMPMAG].n_value)), SEEK_SET);
(void)Read(dumpfd, &newdumpmag, sizeof(newdumpmag));

/* Read the dump size. */
Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_DUMPSIZE].n_value)), L_SET);
Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_DUMPSIZE].n_value)), SEEK_SET);
(void)Read(dumpfd, &dumpsize, sizeof(dumpsize));
dumpsize *= getpagesize();

Expand Down Expand Up @@ -386,7 +386,7 @@ err1: syslog(LOG_WARNING, "%s: %s", path, strerror(errno));
}

/* Seek to the start of the core. */
Lseek(ifd, (off_t)dumplo, L_SET);
Lseek(ifd, (off_t)dumplo, SEEK_SET);

/* Copy the core file. */
syslog(LOG_NOTICE, "writing %score to %s",
Expand Down Expand Up @@ -522,7 +522,7 @@ get_crashtime()
{
time_t dumptime; /* Time the dump was taken. */

Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_TIME].n_value)), L_SET);
Lseek(dumpfd, (off_t)(dumplo + ok(dump_nl[X_TIME].n_value)), SEEK_SET);
(void)Read(dumpfd, &dumptime, sizeof(dumptime));
if (dumptime == 0) {
if (verbose)
Expand Down
8 changes: 4 additions & 4 deletions sys/kern/vfs_syscalls.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.91 1997/06/24 23:44:57 fvdl Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.92 1997/08/25 19:32:10 kleink Exp $ */

/*
* Copyright (c) 1989, 1993
Expand Down Expand Up @@ -1146,16 +1146,16 @@ sys_lseek(p, v, retval)
return (ESPIPE);

switch (SCARG(uap, whence)) {
case L_INCR:
case SEEK_CUR:
newoff = fp->f_offset + SCARG(uap, offset);
break;
case L_XTND:
case SEEK_END:
error = VOP_GETATTR(vp, &vattr, cred, p);
if (error)
return (error);
newoff = SCARG(uap, offset) + vattr.va_size;
break;
case L_SET:
case SEEK_SET:
newoff = SCARG(uap, offset);
break;
default:
Expand Down
Loading

0 comments on commit 9e7a0b6

Please sign in to comment.