From owner-svn-src-all@freebsd.org Thu Sep 22 21:23:29 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F520BE51E1; Thu, 22 Sep 2016 21:23:29 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 37AE7DDB; Thu, 22 Sep 2016 21:23:29 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8MLNSof001815; Thu, 22 Sep 2016 21:23:28 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8MLNS6K001813; Thu, 22 Sep 2016 21:23:28 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201609222123.u8MLNS6K001813@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 22 Sep 2016 21:23:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r306217 - in stable/9/usr.bin/bsdiff: bsdiff bspatch X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Sep 2016 21:23:29 -0000 Author: emaste Date: Thu Sep 22 21:23:28 2016 New Revision: 306217 URL: https://svnweb.freebsd.org/changeset/base/306217 Log: MFC r264823 (ed): Make usage printing more consistent with other tools. - Introduce a separate usage() function. - Don't use argv[0]. Directly name the application, as we do elsewhere. - Don't prepend the application name. - Don't print two newlines. Also apply the unnecessary semicolon cleanup from r298089 Modified: stable/9/usr.bin/bsdiff/bsdiff/bsdiff.c stable/9/usr.bin/bsdiff/bspatch/bspatch.c Directory Properties: stable/9/usr.bin/bsdiff/ (props changed) Modified: stable/9/usr.bin/bsdiff/bsdiff/bsdiff.c ============================================================================== --- stable/9/usr.bin/bsdiff/bsdiff/bsdiff.c Thu Sep 22 21:19:25 2016 (r306216) +++ stable/9/usr.bin/bsdiff/bsdiff/bsdiff.c Thu Sep 22 21:23:28 2016 (r306217) @@ -196,6 +196,14 @@ static void offtout(off_t x,u_char *buf) if(x<0) buf[7]|=0x80; } +static void +usage(void) +{ + + fprintf(stderr, "usage: bsdiff oldfile newfile patchfile\n"); + exit(1); +} + int main(int argc,char *argv[]) { int fd; @@ -216,7 +224,8 @@ int main(int argc,char *argv[]) BZFILE * pfbz2; int bz2err; - if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); + if (argc != 4) + usage(); /* Allocate oldsize+1 bytes instead of oldsize bytes to ensure that we never try to malloc(0) and get a NULL pointer */ Modified: stable/9/usr.bin/bsdiff/bspatch/bspatch.c ============================================================================== --- stable/9/usr.bin/bsdiff/bspatch/bspatch.c Thu Sep 22 21:19:25 2016 (r306216) +++ stable/9/usr.bin/bsdiff/bspatch/bspatch.c Thu Sep 22 21:23:28 2016 (r306217) @@ -57,6 +57,14 @@ static off_t offtin(u_char *buf) return y; } +static void +usage(void) +{ + + fprintf(stderr, "usage: bspatch oldfile newfile patchfile\n"); + exit(1); +} + int main(int argc,char * argv[]) { FILE * f, * cpf, * dpf, * epf; @@ -72,7 +80,8 @@ int main(int argc,char * argv[]) off_t lenread; off_t i; - if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); + if (argc != 4) + usage(); /* Open patch file */ if ((f = fopen(argv[3], "rb")) == NULL) @@ -152,7 +161,7 @@ int main(int argc,char * argv[]) (cbz2err != BZ_STREAM_END))) errx(1, "Corrupt patch\n"); ctrl[i]=offtin(buf); - }; + } /* Sanity-check */ if ((ctrl[0] < 0) || (ctrl[1] < 0)) @@ -190,7 +199,7 @@ int main(int argc,char * argv[]) /* Adjust pointers */ newpos+=ctrl[1]; oldpos+=ctrl[2]; - }; + } /* Clean up the bzip2 reads */ BZ2_bzReadClose(&cbz2err, cpfbz2);