>From newsserv!quahog.me.su.oz.au!john Sat Aug 20 01:53:22 1994 From: John Mackin Newsgroups: stark.freebsd-bugs Subject: Improved fix to "strip" Date: Mon, 25 Jul 94 21:11:56 +1000 Organization: Gene Stark's home system Distribution: stark NNTP-Posting-Host: home.stark.cs.sunysb.edu To: FreeBSD-bugfiler@freefall.cdrom.com Index: usr.bin/strip FreeBSD-1.1.5 Precedence: bulk Description: See earlier submission re "strip". Repeat-By: As above. Fix: Bruce Evans pointed out that the diff I submitted a few days ago always exited with status zero. This one will exit with status one if any errors happened; Bruce was quite right that that was how it should work. Thanks for picking it up. --- strip.c-dist Mon Sep 27 05:27:56 1993 +++ src/usr.bin/strip/strip.c Mon Jul 25 21:07:23 1994 @@ -64,6 +64,7 @@ void usage __P((void)); int xflag = 0; +int errcount = 0; main(argc, argv) int argc; @@ -105,7 +106,7 @@ if (close(fd)) err("%s: %s", fn, strerror(errno)); } - exit(0); + exit(errcount > 0); } void @@ -156,8 +157,10 @@ /* Map the file. */ if (fstat(fd, &sb) || (ep = (EXEC *)mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, - MAP_FILE | MAP_SHARED, fd, (off_t)0)) == (EXEC *)-1) + MAP_FILE | MAP_SHARED, fd, (off_t)0)) == (EXEC *)-1) { err("%s: %s", fn, strerror(errno)); + return; + } /* * Initialize old and new symbol pointers. They both point to the @@ -172,8 +175,11 @@ * of the string table. */ strbase = (char *)ep + N_STROFF(*ep); - if ((nstrbase = malloc((u_int)*(u_long *)strbase)) == NULL) + if ((nstrbase = malloc((u_int)*(u_long *)strbase)) == NULL) { err("%s", strerror(errno)); + munmap((caddr_t)ep, sb.st_size); + return; + } nstr = nstrbase + sizeof(u_long); /* @@ -250,5 +256,5 @@ (void)vfprintf(stderr, fmt, ap); va_end(ap); (void)fprintf(stderr, "\n"); - exit(1); + errcount++; }