Skip to content

Commit 999851e

Browse files
Use SEEK_SET for third arg to *seek() functions. (#139)
Instead of sometimes passing `0` to `lseek` and friends, we should use the standard symbolic constant `SEEK_SET`.
1 parent a986b1e commit 999851e

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

src/imagefile2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "version.h"
1212

1313
#include <stdio.h>
14+
#include <unistd.h>
1415
#include <pixrect/pixrect_hs.h>
1516

1617
#define FALSE 0
@@ -132,7 +133,7 @@ int position_rasterfile(RASTERFILE_INFO *fileinfo, int n)
132133

133134
if (n > 0) {
134135
position = sizeof(struct rasterfile) + (n - 1) * fileinfo->rh.ras_length;
135-
if ((status = fseek(fileinfo->file, position, (int)0)) == 0) {
136+
if ((status = fseek(fileinfo->file, position, SEEK_SET)) == 0) {
136137
/* normal return */
137138
return (TRUE);
138139
} /* end if( status ) */

src/ldsout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int sysout_loader(char * sysout_file_name, int sys_size)
109109
}
110110

111111
/* seek to IFPAGE */
112-
if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) {
112+
if (lseek(sysout, IFPAGE_ADDRESS, SEEK_SET) == -1) {
113113
perror("sysout_loader: can't seek to IFPAGE");
114114
exit(-1);
115115
}
@@ -248,7 +248,7 @@ int sysout_loader(char * sysout_file_name, int sys_size)
248248
#else
249249
fptovp_offset = (fptovp_offset - 1) * BYTESPER_PAGE + 2;
250250
#endif
251-
if (lseek(sysout, fptovp_offset, 0) == -1) {
251+
if (lseek(sysout, fptovp_offset, SEEK_SET) == -1) {
252252
perror("sysout_loader: can't seek to FPTOVP");
253253
exit(-1);
254254
}
@@ -310,7 +310,7 @@ int sysout_loader(char * sysout_file_name, int sys_size)
310310
}
311311
#endif /* DOS */
312312
if (GETPAGEOK(fptovp, i) != 0177777) {
313-
if (lseek(sysout, i * BYTESPER_PAGE, 0) == -1) {
313+
if (lseek(sysout, i * BYTESPER_PAGE, SEEK_SET) == -1) {
314314
perror("sysout_loader: can't seek sysout file");
315315
exit(-1);
316316
};

src/setsout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void set_sysout(int version, char *sysout_file_name) {
6060
exit(-1);
6161
}
6262
/* seek to IFPAGE */
63-
if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) {
63+
if (lseek(sysout, IFPAGE_ADDRESS, SEEK_SET) == -1) {
6464
perror("sysout_loader: can't seek to IFPAGE");
6565
exit(-1);
6666
}
@@ -78,7 +78,7 @@ void set_sysout(int version, char *sysout_file_name) {
7878
ifpage.minbversion = version;
7979

8080
/* seek to IFPAGE */
81-
if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) {
81+
if (lseek(sysout, IFPAGE_ADDRESS, SEEK_SET) == -1) {
8282
perror("sysout_loader: can't seek to IFPAGE");
8383
exit(-1);
8484
}

src/tstsout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void check_sysout(char *sysout_file_name, int verbose) {
5555
exit(-1);
5656
}
5757
/* seek to IFPAGE */
58-
if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) {
58+
if (lseek(sysout, IFPAGE_ADDRESS, SEEK_SET) == -1) {
5959
perror("sysout_loader: can't seek to IFPAGE");
6060
exit(-1);
6161
}

src/vmemsave.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ LispPTR vmem_save(char *sysout_file_name)
421421
int contig_pages = 0;
422422
register char *base_addr;
423423

424-
TIMEOUT(rval = lseek(sysout, i * BYTESPER_PAGE, 0));
424+
TIMEOUT(rval = lseek(sysout, i * BYTESPER_PAGE, SEEK_SET));
425425
if (rval == -1) {
426426
err_mess("lseek", errno);
427427
return (FILECANNOTSEEK);
@@ -472,7 +472,7 @@ LispPTR vmem_save(char *sysout_file_name)
472472
}
473473

474474
/* seek to IFPAGE */
475-
TIMEOUT(rval = lseek(sysout, (long)FP_IFPAGE, 0));
475+
TIMEOUT(rval = lseek(sysout, (long)FP_IFPAGE, SEEK_SET));
476476
if (rval == -1) {
477477
err_mess("lseek", errno);
478478
return (FILECANNOTSEEK);

0 commit comments

Comments
 (0)