1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Proper use of fseek/fseeko macros.

OK joris@, otto@
This commit is contained in:
tobias 2007-09-10 14:29:53 +00:00
parent f7b27a9b12
commit a52c79cd89
18 changed files with 59 additions and 57 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fortune.c,v 1.24 2007/06/26 17:51:28 moritz Exp $ */
/* $OpenBSD: fortune.c,v 1.25 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: fortune.c,v 1.8 1995/03/23 08:28:40 cgd Exp $ */
/*-
@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)fortune.c 8.1 (Berkeley) 5/31/93";
#else
static char rcsid[] = "$OpenBSD: fortune.c,v 1.24 2007/06/26 17:51:28 moritz Exp $";
static char rcsid[] = "$OpenBSD: fortune.c,v 1.25 2007/09/10 14:29:53 tobias Exp $";
#endif
#endif /* not lint */
@ -246,7 +246,7 @@ display(FILEDESC *fp)
char line[BUFSIZ];
open_fp(fp);
(void) fseek(fp->inf, (long)Seekpts[0], 0);
(void) fseek(fp->inf, (long)Seekpts[0], SEEK_SET);
for (Fort_len = 0; fgets(line, sizeof line, fp->inf) != NULL &&
!STR_ENDSTRING(line, fp->tbl); Fort_len++) {
if (fp->tbl.str_flags & STR_ROTATED)
@ -274,7 +274,7 @@ fortlen(void)
nchar = (Seekpts[1] - Seekpts[0] <= SLEN);
else {
open_fp(Fortfile);
(void) fseek(Fortfile->inf, (long)Seekpts[0], 0);
(void) fseek(Fortfile->inf, (long)Seekpts[0], SEEK_SET);
nchar = 0;
while (fgets(line, sizeof line, Fortfile->inf) != NULL &&
!STR_ENDSTRING(line, Fortfile->tbl))

View File

@ -1,4 +1,4 @@
/* $OpenBSD: xdr_stdio.c,v 1.9 2005/10/30 19:44:52 kettenis Exp $ */
/* $OpenBSD: xdr_stdio.c,v 1.10 2007/09/10 14:29:53 tobias Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@ -142,7 +142,7 @@ static bool_t
xdrstdio_setpos(XDR *xdrs, u_int pos)
{
return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ?
return ((fseek((FILE *)xdrs->x_private, (long)pos, SEEK_SET) < 0) ?
FALSE : TRUE);
}

View File

@ -199,7 +199,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
{
case BIO_C_FILE_SEEK:
case BIO_CTRL_RESET:
ret=(long)fseek(fp,num,0);
ret=(long)fseek(fp,num,SEEK_SET);
break;
case BIO_CTRL_EOF:
ret=(long)feof(fp);

View File

@ -199,7 +199,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
{
case BIO_C_FILE_SEEK:
case BIO_CTRL_RESET:
ret=(long)fseek(fp,num,0);
ret=(long)fseek(fp,num,SEEK_SET);
break;
case BIO_CTRL_EOF:
ret=(long)feof(fp);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: itime.c,v 1.15 2007/06/03 20:16:08 millert Exp $ */
/* $OpenBSD: itime.c,v 1.16 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: itime.c,v 1.4 1997/04/15 01:09:50 lukem Exp $ */
/*-
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)itime.c 8.1 (Berkeley) 6/5/93";
#else
static const char rcsid[] = "$OpenBSD: itime.c,v 1.15 2007/06/03 20:16:08 millert Exp $";
static const char rcsid[] = "$OpenBSD: itime.c,v 1.16 2007/09/10 14:29:53 tobias Exp $";
#endif
#endif /* not lint */
@ -179,7 +179,7 @@ putdumptime(void)
dthead = 0;
ddates_in = 0;
readdumptimes(df);
if (fseek(df, 0L, 0) < 0)
if (fseek(df, 0L, SEEK_SET) < 0)
quit("fseek: %s\n", strerror(errno));
spcl.c_ddate = 0;
ITITERATE(i, dtwalk) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diff3.c,v 1.37 2007/06/28 21:38:09 xsa Exp $ */
/* $OpenBSD: diff3.c,v 1.38 2007/09/10 14:29:53 tobias Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@ -72,12 +72,13 @@ static const char copyright[] =
#ifndef lint
static const char rcsid[] =
"$OpenBSD: diff3.c,v 1.37 2007/06/28 21:38:09 xsa Exp $";
"$OpenBSD: diff3.c,v 1.38 2007/09/10 14:29:53 tobias Exp $";
#endif /* not lint */
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@ -729,7 +730,7 @@ repos(int nchar)
int i;
for (i = 0; i < 2; i++)
(void)fseek(fp[i], (long)-nchar, 1);
(void)fseek(fp[i], (long)-nchar, SEEK_CUR);
}
/*
@ -763,7 +764,7 @@ edscript(int n)
prange(&de[n].old);
else
diff_output("%da\n=======\n", de[n].old.to -1);
(void)fseek(fp[2], (long)de[n].new.from, 0);
(void)fseek(fp[2], (long)de[n].new.from, SEEK_SET);
for (k = de[n].new.to-de[n].new.from; k > 0; k-= j) {
j = k > BUFSIZ ? BUFSIZ : k;
if (fread(block, (size_t)1, (size_t)j,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diff3prog.c,v 1.8 2005/11/22 16:00:49 markus Exp $ */
/* $OpenBSD: diff3prog.c,v 1.9 2007/09/10 14:29:53 tobias Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@ -71,7 +71,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
static const char rcsid[] = "$OpenBSD: diff3prog.c,v 1.8 2005/11/22 16:00:49 markus Exp $";
static const char rcsid[] = "$OpenBSD: diff3prog.c,v 1.9 2007/09/10 14:29:53 tobias Exp $";
#endif /* not lint */
#include <stdio.h>
@ -514,7 +514,7 @@ repos(int nchar)
int i;
for (i = 0; i < 2; i++)
(void)fseek(fp[i], (long)-nchar, 1);
(void)fseek(fp[i], (long)-nchar, SEEK_CUR);
}
__dead void
@ -554,7 +554,7 @@ edscript(int n)
prange(&de[n].old);
else
printf("%da\n=======\n", de[n].old.to -1);
(void)fseek(fp[2], (long)de[n].new.from, 0);
(void)fseek(fp[2], (long)de[n].new.from, SEEK_SET);
for (k = de[n].new.to-de[n].new.from; k > 0; k-= j) {
j = k > BUFSIZ ? BUFSIZ : k;
if (fread(block, 1, j, fp[2]) != j)

View File

@ -87,7 +87,7 @@ getnfile(const char *filename, char ***defaultEs)
static void
getstrtab(FILE *nfile, const char *filename)
{
fseek(nfile, (long)(N_SYMOFF(xbuf) + xbuf.a_syms), 0);
fseek(nfile, (long)(N_SYMOFF(xbuf) + xbuf.a_syms), SEEK_SET);
if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0)
errx(1, "%s: no string table (old format?)" , filename );
strtab = calloc(ssiz, 1);
@ -109,7 +109,7 @@ getsymtab(FILE *nfile, const char *filename)
long i;
/* pass1 - count symbols */
fseek(nfile, (long)N_SYMOFF(xbuf), 0);
fseek(nfile, (long)N_SYMOFF(xbuf), SEEK_SET);
nname = 0;
for (i = xbuf.a_syms; i > 0; i -= sizeof(struct nlist)) {
fread(&nbuf, sizeof(nbuf), 1, nfile);
@ -126,7 +126,7 @@ getsymtab(FILE *nfile, const char *filename)
askfor * sizeof(nltype));
/* pass2 - read symbols */
fseek(nfile, (long)N_SYMOFF(xbuf), 0);
fseek(nfile, (long)N_SYMOFF(xbuf), SEEK_SET);
npe = nl;
nname = 0;
for (i = xbuf.a_syms; i > 0; i -= sizeof(struct nlist)) {
@ -168,7 +168,7 @@ gettextspace(FILE *nfile)
xbuf.a_text);
return;
}
(void)fseek(nfile, N_TXTOFF(xbuf), 0);
(void)fseek(nfile, N_TXTOFF(xbuf), SEEK_SET);
if (fread(textspace, 1, xbuf.a_text, nfile) != xbuf.a_text ) {
warnx("couldn't read text space: can't do -c");
free(textspace);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: collect.c,v 1.27 2004/01/03 20:06:59 millert Exp $ */
/* $OpenBSD: collect.c,v 1.28 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
#else
static const char rcsid[] = "$OpenBSD: collect.c,v 1.27 2004/01/03 20:06:59 millert Exp $";
static const char rcsid[] = "$OpenBSD: collect.c,v 1.28 2007/09/10 14:29:53 tobias Exp $";
#endif
#endif /* not lint */
@ -447,7 +447,7 @@ mesedit(FILE *fp, int c)
(void)ignoresig(SIGINT, &oact, &oset);
nf = run_editor(fp, (off_t)-1, c, 0);
if (nf != NULL) {
fseek(nf, 0L, 2);
fseek(nf, 0L, SEEK_END);
collf = nf;
(void)Fclose(fp);
}
@ -497,7 +497,7 @@ mespipe(FILE *fp, char *cmd)
/*
* Take new files.
*/
(void)fseek(nf, 0L, 2);
(void)fseek(nf, 0L, SEEK_END);
collf = nf;
(void)Fclose(fp);
out:

View File

@ -1,4 +1,4 @@
/* $OpenBSD: edit.c,v 1.15 2007/08/31 23:14:21 ray Exp $ */
/* $OpenBSD: edit.c,v 1.16 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: edit.c,v 1.5 1996/06/08 19:48:20 christos Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] = "$OpenBSD: edit.c,v 1.15 2007/08/31 23:14:21 ray Exp $";
static const char rcsid[] = "$OpenBSD: edit.c,v 1.16 2007/09/10 14:29:53 tobias Exp $";
#endif
#endif /* not lint */
@ -114,7 +114,7 @@ edit1(int *msgvec, int type)
(void)ignoresig(SIGINT, &oact, &oset);
fp = run_editor(setinput(mp), (off_t)mp->m_size, type, readonly);
if (fp != NULL) {
(void)fseek(otf, 0L, 2);
(void)fseek(otf, 0L, SEEK_END);
size = ftell(otf);
mp->m_block = blockof(size);
mp->m_offset = offsetof(size);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fio.c,v 1.28 2007/05/25 21:27:16 krw Exp $ */
/* $OpenBSD: fio.c,v 1.29 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: fio.c,v 1.8 1997/07/07 22:57:55 phil Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
static const char rcsid[] = "$OpenBSD: fio.c,v 1.28 2007/05/25 21:27:16 krw Exp $";
static const char rcsid[] = "$OpenBSD: fio.c,v 1.29 2007/09/10 14:29:53 tobias Exp $";
#endif
#endif /* not lint */
@ -91,7 +91,7 @@ setptr(FILE *ibuf, off_t offset)
msgCount = 0;
} else {
/* Seek into the file to get to the new messages */
(void)fseeko(ibuf, offset, 0);
(void)fseeko(ibuf, offset, SEEK_SET);
/*
* We need to make "offset" a pointer to the end of
* the temp file that has the copy of the mail file.
@ -268,7 +268,8 @@ setinput(struct message *mp)
{
fflush(otf);
if (fseek(itf, (long)positionof(mp->m_block, mp->m_offset), 0) < 0)
if (fseek(itf, (long)positionof(mp->m_block, mp->m_offset), SEEK_SET)
< 0)
err(1, "fseek");
return(itf);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: quit.c,v 1.18 2006/02/01 19:01:35 otto Exp $ */
/* $OpenBSD: quit.c,v 1.19 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95";
#else
static const char rcsid[] = "$OpenBSD: quit.c,v 1.18 2006/02/01 19:01:35 otto Exp $";
static const char rcsid[] = "$OpenBSD: quit.c,v 1.19 2007/09/10 14:29:53 tobias Exp $";
#endif
#endif /* not lint */
@ -122,7 +122,7 @@ quit(void)
(rbuf = Fdopen(fd, "w")) == NULL)
goto newmail;
#ifdef APPEND
fseek(fbuf, (long)mailsize, 0);
fseek(fbuf, (long)mailsize, SEEK_SET);
while ((c = getc(fbuf)) != EOF)
(void)putc(c, rbuf);
#else
@ -457,7 +457,7 @@ edstop(void)
relsesigs();
return(-1);
}
fseek(ibuf, (long)mailsize, 0);
fseek(ibuf, (long)mailsize, SEEK_SET);
while ((c = getc(ibuf)) != EOF)
(void)putc(c, obuf);
(void)Fclose(ibuf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mkstr.c,v 1.9 2007/08/06 19:16:06 sobrado Exp $ */
/* $OpenBSD: mkstr.c,v 1.10 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: mkstr.c,v 1.4 1995/09/28 06:22:20 tls Exp $ */
/*
@ -40,7 +40,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)mkstr.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] = "$OpenBSD: mkstr.c,v 1.9 2007/08/06 19:16:06 sobrado Exp $";
static const char rcsid[] = "$OpenBSD: mkstr.c,v 1.10 2007/09/10 14:29:53 tobias Exp $";
#endif
#endif /* not lint */
@ -283,7 +283,7 @@ hashit(char *str, char really, unsigned int fakept)
if (really != 0)
for (hp = bucket[i]; hp != 0; hp = hp->hnext)
if (hp->hval == hashval) {
fseek(mesgread, (long) hp->hpt, 0);
fseek(mesgread, (long) hp->hpt, SEEK_SET);
fgetNUL(buf, sizeof buf, mesgread);
#ifdef DEBUG
fprintf(stderr, "Got (from %d) %s\n", hp->hpt, buf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: diff3.c,v 1.23 2007/07/03 00:56:23 ray Exp $ */
/* $OpenBSD: diff3.c,v 1.24 2007/09/10 14:29:53 tobias Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@ -72,7 +72,7 @@ static const char copyright[] =
#ifndef lint
static const char rcsid[] =
"$OpenBSD: diff3.c,v 1.23 2007/07/03 00:56:23 ray Exp $";
"$OpenBSD: diff3.c,v 1.24 2007/09/10 14:29:53 tobias Exp $";
#endif /* not lint */
#include <ctype.h>
@ -869,7 +869,7 @@ repos(int nchar)
int i;
for (i = 0; i < 2; i++)
(void)fseek(fp[i], (long)-nchar, 1);
(void)fseek(fp[i], (long)-nchar, SEEK_CUR);
}
/*
@ -903,7 +903,7 @@ edscript(int n)
prange(&de[n].old);
else
diff_output("%da\n=======\n", de[n].old.to -1);
(void)fseek(fp[2], (long)de[n].new.from, 0);
(void)fseek(fp[2], (long)de[n].new.from, SEEK_SET);
for (k = de[n].new.to-de[n].new.from; k > 0; k-= j) {
j = k > BUFSIZ ? BUFSIZ : k;
if (fread(block, 1, (size_t)j,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tftpsubs.c,v 1.12 2006/07/26 12:34:41 mglocker Exp $ */
/* $OpenBSD: tftpsubs.c,v 1.13 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: tftpsubs.c,v 1.3 1994/12/08 09:51:31 jtc Exp $ */
/*
@ -35,7 +35,7 @@
static char sccsid[] = "@(#)tftpsubs.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$OpenBSD: tftpsubs.c,v 1.12 2006/07/26 12:34:41 mglocker Exp $";
"$OpenBSD: tftpsubs.c,v 1.13 2007/09/10 14:29:53 tobias Exp $";
#endif /* not lint */
/*
@ -237,7 +237,7 @@ write_behind(FILE *file, int convert)
if (prevchar == '\r') { /* if prev char was cr */
if (c == '\n') /* if have cr,lf then just */
/* smash lf on top of the cr */
fseek(file, -1, 1);
fseek(file, -1, SEEK_CUR);
else if (c == '\0') /* if have cr,nul then */
goto skipit; /* just skip over the putc */
/* FALLTHROUGH */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: xstr.c,v 1.13 2004/07/26 09:04:18 jmc Exp $ */
/* $OpenBSD: xstr.c,v 1.14 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: xstr.c,v 1.5 1994/12/24 16:57:59 cgd Exp $ */
/*
@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)xstr.c 8.1 (Berkeley) 6/9/93";
#endif
static char rcsid[] = "$OpenBSD: xstr.c,v 1.13 2004/07/26 09:04:18 jmc Exp $";
static char rcsid[] = "$OpenBSD: xstr.c,v 1.14 2007/09/10 14:29:53 tobias Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -390,7 +390,7 @@ flushsh(void)
for (hp = bucket[i].hnext; hp != NULL; hp = hp->hnext) {
found(hp->hnew, hp->hpt, hp->hstr);
if (hp->hnew) {
fseek(mesgwrit, hp->hpt, 0);
fseek(mesgwrit, hp->hpt, SEEK_SET);
fwrite(hp->hstr, strlen(hp->hstr) + 1, 1, mesgwrit);
if (ferror(mesgwrit)) {
perror(strings);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: env.c,v 1.19 2007/09/02 15:19:38 deraadt Exp $ */
/* $OpenBSD: env.c,v 1.20 2007/09/10 14:29:53 tobias Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -22,7 +22,7 @@
*/
#if !defined(lint) && !defined(LINT)
static char const rcsid[] = "$OpenBSD: env.c,v 1.19 2007/09/02 15:19:38 deraadt Exp $";
static char const rcsid[] = "$OpenBSD: env.c,v 1.20 2007/09/10 14:29:53 tobias Exp $";
#endif
#include "cron.h"
@ -209,7 +209,7 @@ load_env(char *envstr, FILE *f) {
}
if (state != FINI && !(state == VALUE && !quotechar)) {
Debug(DPARS, ("load_env, not an env var, state = %d\n", state))
fseek(f, filepos, 0);
fseek(f, filepos, SEEK_SET);
Set_LineNum(fileline);
return (FALSE);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: printjob.c,v 1.43 2007/09/02 15:19:38 deraadt Exp $ */
/* $OpenBSD: printjob.c,v 1.44 2007/09/10 14:29:53 tobias Exp $ */
/* $NetBSD: printjob.c,v 1.31 2002/01/21 14:42:30 wiz Exp $ */
/*
@ -503,7 +503,7 @@ printit(char *file)
/* pass 2 */
pass2:
fseek(cfp, 0L, 0);
fseek(cfp, 0L, SEEK_SET);
while (getline(cfp))
switch (line[0]) {
case 'L': /* identification line */
@ -862,7 +862,7 @@ sendit(char *file)
/*
* pass 2
*/
fseek(cfp, 0L, 0);
fseek(cfp, 0L, SEEK_SET);
while (getline(cfp))
if (line[0] == 'U' && strchr(line+1, '/') == 0)
(void)unlink(line+1);