From: Christian Weisgerber Subject: got patch: fseek -> fseeko To: gameoftrees@openbsd.org Date: Sat, 14 May 2022 16:43:46 +0200 This switches the new got patch code from fseek(3) to the more appropriate fseeko(3). patch.c: copypos, match are off_t got-read-patch.c: linelen is ssize_t ok? "linelen * -1" is an odd idiom. Is that really clearer than plain "-linelen"? PS: I grepped the tree. Most other instances of fseek() are with offset 0, so it doesn't matter. The only other ones are diff debug code that isn't built, and in diff3.c, where the offsets are derived from an int variable. diff refs/heads/main refs/heads/fseeko blob - 9a66825918efbd6b934add0ed0636e397fb31edd blob + 10628c74cc337e81b5aebbdf5b19dea7cc134fb2 --- lib/patch.c +++ lib/patch.c @@ -293,8 +293,8 @@ copy(FILE *tmp, FILE *orig, off_t copypos, off_t pos) char buf[BUFSIZ]; size_t len, r, w; - if (fseek(orig, copypos, SEEK_SET) == -1) - return got_error_from_errno("fseek"); + if (fseeko(orig, copypos, SEEK_SET) == -1) + return got_error_from_errno("fseeko"); while (pos == -1 || copypos < pos) { len = sizeof(buf); @@ -359,8 +359,8 @@ locate_hunk(FILE *orig, struct got_patch_hunk *h, off_ if (err == NULL) { *pos = match; *lineno = match_lineno; - if (fseek(orig, match, SEEK_SET) == -1) - err = got_error_from_errno("fseek"); + if (fseeko(orig, match, SEEK_SET) == -1) + err = got_error_from_errno("fseeko"); } free(line); @@ -491,8 +491,8 @@ patch_file(struct got_patch *p, const char *path, FILE * try to apply the hunk again starting the search * after the previous partial match. */ - if (fseek(orig, pos, SEEK_SET) == -1) { - err = got_error_from_errno("fseek"); + if (fseeko(orig, pos, SEEK_SET) == -1) { + err = got_error_from_errno("fseeko"); goto done; } linelen = getline(&line, &linesize, orig); blob - 074b5cb8fcd2962ea86e2b829b0b0817f69b8835 blob + 5d286961bc27941710301546fceaf741ea365831 --- libexec/got-read-patch/got-read-patch.c +++ libexec/got-read-patch/got-read-patch.c @@ -181,8 +181,8 @@ find_patch(int *done, FILE *fp) break; /* rewind to previous line */ - if (fseek(fp, linelen * -1, SEEK_CUR) == -1) - err = got_error_from_errno("fseek"); + if (fseeko(fp, linelen * -1, SEEK_CUR) == -1) + err = got_error_from_errno("fseeko"); break; } } @@ -351,8 +351,8 @@ parse_hunk(FILE *fp, int *done) if (err) goto done; if (*done) { - if (fseek(fp, linelen * -1, SEEK_CUR) == -1) - err = got_error_from_errno("fseek"); + if (fseeko(fp, linelen * -1, SEEK_CUR) == -1) + err = got_error_from_errno("fseeko"); goto done; } -- Christian "naddy" Weisgerber naddy@mips.inka.de