head 1.3; access; symbols pkgsrc-2026Q1:1.3.0.58 pkgsrc-2026Q1-base:1.3 pkgsrc-2025Q4:1.3.0.56 pkgsrc-2025Q4-base:1.3 pkgsrc-2025Q3:1.3.0.54 pkgsrc-2025Q3-base:1.3 pkgsrc-2025Q2:1.3.0.52 pkgsrc-2025Q2-base:1.3 pkgsrc-2025Q1:1.3.0.50 pkgsrc-2025Q1-base:1.3 pkgsrc-2024Q4:1.3.0.48 pkgsrc-2024Q4-base:1.3 pkgsrc-2024Q3:1.3.0.46 pkgsrc-2024Q3-base:1.3 pkgsrc-2024Q2:1.3.0.44 pkgsrc-2024Q2-base:1.3 pkgsrc-2024Q1:1.3.0.42 pkgsrc-2024Q1-base:1.3 pkgsrc-2023Q4:1.3.0.40 pkgsrc-2023Q4-base:1.3 pkgsrc-2023Q3:1.3.0.38 pkgsrc-2023Q3-base:1.3 pkgsrc-2023Q2:1.3.0.36 pkgsrc-2023Q2-base:1.3 pkgsrc-2023Q1:1.3.0.34 pkgsrc-2023Q1-base:1.3 pkgsrc-2022Q4:1.3.0.32 pkgsrc-2022Q4-base:1.3 pkgsrc-2022Q3:1.3.0.30 pkgsrc-2022Q3-base:1.3 pkgsrc-2022Q2:1.3.0.28 pkgsrc-2022Q2-base:1.3 pkgsrc-2022Q1:1.3.0.26 pkgsrc-2022Q1-base:1.3 pkgsrc-2021Q4:1.3.0.24 pkgsrc-2021Q4-base:1.3 pkgsrc-2021Q3:1.3.0.22 pkgsrc-2021Q3-base:1.3 pkgsrc-2021Q2:1.3.0.20 pkgsrc-2021Q2-base:1.3 pkgsrc-2021Q1:1.3.0.18 pkgsrc-2021Q1-base:1.3 pkgsrc-2020Q4:1.3.0.16 pkgsrc-2020Q4-base:1.3 pkgsrc-2020Q3:1.3.0.14 pkgsrc-2020Q3-base:1.3 pkgsrc-2020Q2:1.3.0.12 pkgsrc-2020Q2-base:1.3 pkgsrc-2020Q1:1.3.0.8 pkgsrc-2020Q1-base:1.3 pkgsrc-2019Q4:1.3.0.10 pkgsrc-2019Q4-base:1.3 pkgsrc-2019Q3:1.3.0.6 pkgsrc-2019Q3-base:1.3 pkgsrc-2019Q2:1.3.0.4 pkgsrc-2019Q2-base:1.3 pkgsrc-2019Q1:1.3.0.2 pkgsrc-2019Q1-base:1.3 pkgsrc-2018Q4:1.2.0.52 pkgsrc-2018Q4-base:1.2 pkgsrc-2018Q3:1.2.0.50 pkgsrc-2018Q3-base:1.2 pkgsrc-2018Q2:1.2.0.48 pkgsrc-2018Q2-base:1.2 pkgsrc-2018Q1:1.2.0.46 pkgsrc-2018Q1-base:1.2 pkgsrc-2017Q4:1.2.0.44 pkgsrc-2017Q4-base:1.2 pkgsrc-2017Q3:1.2.0.42 pkgsrc-2017Q3-base:1.2 pkgsrc-2017Q2:1.2.0.38 pkgsrc-2017Q2-base:1.2 pkgsrc-2017Q1:1.2.0.36 pkgsrc-2017Q1-base:1.2 pkgsrc-2016Q4:1.2.0.34 pkgsrc-2016Q4-base:1.2 pkgsrc-2016Q3:1.2.0.32 pkgsrc-2016Q3-base:1.2 pkgsrc-2016Q2:1.2.0.30 pkgsrc-2016Q2-base:1.2 pkgsrc-2016Q1:1.2.0.28 pkgsrc-2016Q1-base:1.2 pkgsrc-2015Q4:1.2.0.26 pkgsrc-2015Q4-base:1.2 pkgsrc-2015Q3:1.2.0.24 pkgsrc-2015Q3-base:1.2 pkgsrc-2015Q2:1.2.0.22 pkgsrc-2015Q2-base:1.2 pkgsrc-2015Q1:1.2.0.20 pkgsrc-2015Q1-base:1.2 pkgsrc-2014Q4:1.2.0.18 pkgsrc-2014Q4-base:1.2 pkgsrc-2014Q3:1.2.0.16 pkgsrc-2014Q3-base:1.2 pkgsrc-2014Q2:1.2.0.14 pkgsrc-2014Q2-base:1.2 pkgsrc-2014Q1:1.2.0.12 pkgsrc-2014Q1-base:1.2 pkgsrc-2013Q4:1.2.0.10 pkgsrc-2013Q4-base:1.2 pkgsrc-2013Q3:1.2.0.8 pkgsrc-2013Q3-base:1.2 pkgsrc-2013Q2:1.2.0.6 pkgsrc-2013Q2-base:1.2 pkgsrc-2013Q1:1.2.0.4 pkgsrc-2013Q1-base:1.2 pkgsrc-2012Q4:1.2.0.2 pkgsrc-2012Q4-base:1.2 pkgsrc-2012Q3:1.1.0.10 pkgsrc-2012Q3-base:1.1 pkgsrc-2012Q2:1.1.0.8 pkgsrc-2012Q2-base:1.1 pkgsrc-2012Q1:1.1.0.6 pkgsrc-2012Q1-base:1.1 pkgsrc-2011Q4:1.1.0.4 pkgsrc-2011Q4-base:1.1 pkgsrc-2011Q3:1.1.0.2 pkgsrc-2011Q3-base:1.1; locks; strict; comment @# @; 1.3 date 2019.01.18.03.34.28; author mrg; state Exp; branches; next 1.2; commitid X19bBGh7BaLCmd8B; 1.2 date 2012.12.28.03.03.09; author dholland; state Exp; branches; next 1.1; 1.1 date 2011.08.01.05.47.40; author dholland; state Exp; branches; next ; desc @@ 1.3 log @remove now unused and always wrong prototype for system function vsprintf(). @ text @$NetBSD: patch-exrecover_c,v 1.2 2012/12/28 03:03:09 dholland Exp $ - use standard headers - don't declare own perror - declare void functions void - avoid implicit int - silence signed/unsigned compiler warning - use const for string constants - silence warnings about assignments in conditionals - return values from non-void functions - silence warnings about unused arguments - don't declare own vsprintf, not even used anymore --- exrecover.c.orig 2019-01-17 19:26:42.451474122 -0800 +++ exrecover.c 2019-01-17 19:27:32.144598036 -0800 @@@@ -98,6 +98,8 @@@@ typedef int xFILE; #endif +#include + #define var #include "ex.h" @@@@ -193,30 +195,27 @@@@ #endif #endif -extern int perror __P((const char *)); char *getblock __P((line, int)); -int blkio __P((bloc, char *, ssize_t (*) __P((int, void *, size_t)))); +void blkio __P((bloc, char *, ssize_t (*) __P((int, void *, size_t)))); char *poolsbrk __P((intptr_t)); -int error __P((char *str, ...)); -int listfiles __P((char *)); -int enter __P((struct svfile *, char *, int)); +void error __P((const char *str, ...)); +void listfiles __P((const char *)); +void enter __P((struct svfile *, char *, int)); int qucmp __P((struct svfile *, struct svfile *)); -int findtmp __P((char *)); -int searchdir __P((char *)); -int yeah __P((char *)); +void findtmp __P((const char *)); +void searchdir __P((const char *)); +int yeah __P((const char *)); int preserve __P((void)); -int scrapbad __P((void)); -int putfile __P((int)); -int wrerror __P((void)); -int clrstats __P((void)); -int get_line __P((line)); -int syserror __P((void)); -int xvfprintf __P((xFILE *, char *, va_list)); -int xfprintf __P((xFILE *, char *, ...)); -#ifdef __STDC__ -int vsprintf(char *, const char *, va_list); -#endif +void scrapbad __P((void)); +void putfile __P((int)); +void wrerror __P((void)); +void clrstats __P((void)); +void get_line __P((line)); +void syserror __P((void)); +void xvfprintf __P((xFILE *, const char *, va_list)); +void xfprintf __P((xFILE *, const char *, ...)); +int main(argc, argv) int argc; char *argv[]; @@@@ -295,7 +294,7 @@@@ while (H.Flines > 0) { ignorl(lseek(tfile, (off_t) ((blocks[b] & BLKMSK) * BUFSIZ), SEEK_SET)); - i = H.Flines < BUFSIZ / sizeof (line) ? + i = H.Flines < (int)(BUFSIZ / sizeof (line)) ? H.Flines * sizeof (line) : BUFSIZ; if (read(tfile, (char *) dot, i) != i) { perror(nb); @@@@ -350,13 +349,14 @@@@ * a newline which would screw up the screen. */ /*VARARGS2*/ +void #ifndef __STDC__ error(str, inf) - char *str; + const char *str; int inf; { #else -error(char *str, ...) +error(const char *str, ...) { va_list ap; #endif @@@@ -384,8 +384,9 @@@@ exit(1); } +void listfiles(dirname) - char *dirname; + const char *dirname; { register DIR *dir; #ifndef POSIX_1 @@@@ -486,9 +487,11 @@@@ /* * Enter a new file into the saved file information. */ +void enter(fp, fname, count) struct svfile *fp; char *fname; + int count; { register char *cp, *cp2; register struct svfile *f, *fl; @@@@ -521,7 +524,7 @@@@ fp->sf_time = H.Time; fp->sf_lines = H.Flines; cp2 = fp->sf_name, cp = savedfile; - while (*cp2++ = *cp++); + while ((*cp2++ = *cp++) != 0); for (cp2 = fp->sf_entry, cp = fname; *cp && cp-fname < 14;) *cp2++ = *cp++; *cp2++ = 0; @@@@ -531,12 +534,13 @@@@ * Do the qsort compare to sort the entries first by file name, * then by modify time. */ +int qucmp(p1, p2) struct svfile *p1, *p2; { register int t; - if (t = strcmp(p1->sf_name, p2->sf_name)) + if ((t = strcmp(p1->sf_name, p2->sf_name)) != 0) return(t); if (p1->sf_time > p2->sf_time) return(-1); @@@@ -555,8 +559,9 @@@@ * (i.e. usually /tmp) and in /usr/preserve. * Want to find the newest so we search on and on. */ +void findtmp(dir) - char *dir; + const char *dir; { /* @@@@ -608,8 +613,9 @@@@ * name of the file we want to unlink is relative, rather than absolute * we won't be able to find it again. */ +void searchdir(dirname) - char *dirname; + const char *dirname; { #ifndef POSIX_1 struct direct *dirent; @@@@ -662,8 +668,9 @@@@ * if its really an editor temporary and of this * user and the file specified. */ +int yeah(name) - char *name; + const char *name; { tfile = open(name, O_RDWR); @@@@ -688,9 +695,10 @@@@ return (1); } +int preserve() { - + return 0; } /* @@@@ -707,6 +715,7 @@@@ * This only seems to happen on very heavily loaded systems, and * not very often. */ +void scrapbad() { register line *ip; @@@@ -791,6 +800,7 @@@@ * Aw shucks, if we only had a (void) cast. */ #ifdef lint +void Ignorl(a) long a; { @@@@ -798,6 +808,7 @@@@ a = a; } +void Ignore(a) char *a; { @@@@ -805,13 +816,15 @@@@ a = a; } +void Ignorf(a) - int (*a)(); + void (*a)(int); { a = a; } +void ignorl(a) long a; { @@@@ -824,12 +837,15 @@@@ /* * Following routines stolen mercilessly from ex. */ -putfile(unused) +void +putfile(int unused) { line *a1; register char *fp, *lp; register int nib; + (void)unused; + a1 = addr1; clrstats(); cntln = addr2 - a1 + 1; @@@@ -861,12 +877,14 @@@@ cntch += nib; } +void wrerror() { syserror(); } +void clrstats() { @@@@ -880,6 +898,7 @@@@ #define READ 0 #define WRITE 1 +void get_line(tl) line tl; { @@@@ -890,7 +909,7 @@@@ bp = getblock(tl, READ); nl = nleft; tl &= ~OFFMSK; - while (*lp++ = *bp++) + while ((*lp++ = *bp++) != 0) if (--nl == 0) { bp = getblock(tl += INCRMT, READ); nl = nleft; @@@@ -934,8 +953,8 @@@@ return (obuff + off); } +void #ifdef __STDC__ -int blkio(bloc b, char *buf, ssize_t (*iofcn)(int, void *, size_t)) #else /* !__STDC__ */ blkio(b, buf, iofcn) @@@@ -950,6 +969,7 @@@@ syserror(); } +void syserror() { @@@@ -964,10 +984,11 @@@@ * allocation and stdio uses malloc. */ #ifndef __STDC__ +void xfprintf(fp, fmt, a1, a2, a3, a4, a5) xFILE *fp; - char *fmt; - char *a1, *a2, *a3, *a4, *a5; + const char *fmt; + const char *a1, *a2, *a3, *a4, *a5; { char buf[BUFSIZ]; @@@@ -981,17 +1002,19 @@@@ * I do not know whether vsprintf() uses malloc() or not. * So this may be fail, too. */ -xvfprintf(xFILE *fp, char *fmt, va_list ap) +void +xvfprintf(xFILE *fp, const char *fmt, va_list ap) { char buf[BUFSIZ]; if (fp != xstderr) return; - vsprintf(buf, fmt, ap); + vsnprintf(buf, sizeof(buf), fmt, ap); write(2, buf, strlen(buf)); } -xfprintf(xFILE *fp, char *fmt, ...) +void +xfprintf(xFILE *fp, const char *fmt, ...) { va_list ap; @ 1.2 log @Fix legacy C. Pass -Wall -W -Wmissing-declarations -Wwrite-strings on gcc45. - avoid implicit int, declare void functions void - return values from non-void functions - put most external declarations properly in header files - use some static and const - fix up a big mess with function pointer casting - use standard includes, don't provide own decls of standard functions - use types matching libc when providing own malloc, printf, and putchar - use functions correctly - silence assorted compiler warnings - fix some bugs exposed by compiler warnings - don't intentionally exercise signed overflow - remove some unused items - add patch comments to other patch (patch-aa) As this includes several fixes and removes some undefined behavior on a commonly reachable code path, bump PKGREVISION. @ text @d1 1 a1 1 $NetBSD: patch-exrecover_c,v 1.1 2011/08/01 05:47:40 dholland Exp $ d12 1 d14 3 a16 3 --- exrecover.c.orig 2012-12-27 21:58:41.000000000 +0000 +++ exrecover.c @@@@ -98,6 +98,8 @@@@ static char sccsid[] UNUSED = "@@(#)exrec d25 1 a25 1 @@@@ -193,30 +195,30 @@@@ int vercnt; /* Count number of version d56 3 a66 3 #ifdef __STDC__ int vsprintf(char *, const char *, va_list); #endif d72 1 a72 1 @@@@ -295,7 +297,7 @@@@ main(argc, argv) d81 1 a81 1 @@@@ -350,13 +352,14 @@@@ main(argc, argv) d98 1 a98 1 @@@@ -384,8 +387,9 @@@@ error(char *str, ...) d109 1 a109 1 @@@@ -486,9 +490,11 @@@@ listfiles(dirname) d121 1 a121 1 @@@@ -521,7 +527,7 @@@@ enter(fp, fname, count) d130 1 a130 1 @@@@ -531,12 +537,13 @@@@ enter(fp, fname, count) d145 1 a145 1 @@@@ -555,8 +562,9 @@@@ int bestfd; /* Keep best file open so d156 1 a156 1 @@@@ -608,8 +616,9 @@@@ findtmp(dir) d167 1 a167 1 @@@@ -662,8 +671,9 @@@@ searchdir(dirname) d178 1 a178 1 @@@@ -688,9 +698,10 @@@@ nope: d190 1 a190 1 @@@@ -707,6 +718,7 @@@@ preserve() d198 1 a198 1 @@@@ -791,6 +803,7 @@@@ null: d206 1 a206 1 @@@@ -798,6 +811,7 @@@@ Ignorl(a) d214 1 a214 1 @@@@ -805,13 +819,15 @@@@ Ignore(a) d231 1 a231 1 @@@@ -824,12 +840,15 @@@@ int cntch, cntln, cntodd, cntnull; d248 1 a248 1 @@@@ -861,12 +880,14 @@@@ putfile(unused) d263 1 a263 1 @@@@ -880,6 +901,7 @@@@ clrstats() d271 1 a271 1 @@@@ -890,7 +912,7 @@@@ get_line(tl) d280 1 a280 1 @@@@ -934,8 +956,8 @@@@ getblock(atl, iof) d290 1 a290 1 @@@@ -950,6 +972,7 @@@@ blkio(b, buf, iofcn) d298 1 a298 1 @@@@ -964,10 +987,11 @@@@ syserror() d312 1 a312 1 @@@@ -981,17 +1005,19 @@@@ xfprintf(fp, fmt, a1, a2, a3, a4, a5) @ 1.1 log @Fix broken build with clang. @ text @d1 1 a1 1 $NetBSD$ d3 9 a11 1 Fix illegal C caught by clang. d13 1 a13 1 --- exrecover.c~ 2002-04-07 12:02:27.000000000 +0000 d15 17 a31 2 @@@@ -198,7 +198,7 @@@@ char *getblock __P((line, int)); int blkio __P((bloc, char *, ssize_t (*) __P((int, void *, size_t)))); d33 1 a33 1 int error __P((char *str, ...)); d35 4 a38 2 +void listfiles __P((char *)); int enter __P((struct svfile *, char *, int)); d40 58 a97 2 int findtmp __P((char *)); @@@@ -384,6 +384,7 @@@@ error(char *str, ...) d103 101 a203 1 char *dirname; d205 129 @