From owner-svn-src-all@freebsd.org Thu Apr 14 12:25:02 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 08ADAAEC911; Thu, 14 Apr 2016 12:25:02 +0000 (UTC) (envelope-from araujo@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 C78091F8C; Thu, 14 Apr 2016 12:25:01 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3ECP1lj074577; Thu, 14 Apr 2016 12:25:01 GMT (envelope-from araujo@FreeBSD.org) Received: (from araujo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3ECP15B074576; Thu, 14 Apr 2016 12:25:01 GMT (envelope-from araujo@FreeBSD.org) Message-Id: <201604141225.u3ECP15B074576@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: araujo set sender to araujo@FreeBSD.org using -f From: Marcelo Araujo Date: Thu, 14 Apr 2016 12:25:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297961 - head/usr.sbin/rmt X-SVN-Group: head 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.21 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, 14 Apr 2016 12:25:02 -0000 Author: araujo Date: Thu Apr 14 12:25:00 2016 New Revision: 297961 URL: https://svnweb.freebsd.org/changeset/base/297961 Log: Use NULL instead of 0 for pointers. fopen(3) will return NULL in case it can't open the STREAM. The malloc will return a pointer to the allocated memory if successful, otherwise a NULL pointer is returned. Also add an extra DEBUG1 to print out the error to open a file. Reviewed by: ed Differential Revision: https://svnweb.freebsd.org/changeset/base/297959 Modified: head/usr.sbin/rmt/rmt.c Modified: head/usr.sbin/rmt/rmt.c ============================================================================== --- head/usr.sbin/rmt/rmt.c Thu Apr 14 11:45:52 2016 (r297960) +++ head/usr.sbin/rmt/rmt.c Thu Apr 14 12:25:00 2016 (r297961) @@ -84,8 +84,10 @@ main(int argc, char **argv) argc--, argv++; if (argc > 0) { debug = fopen(*argv, "w"); - if (debug == 0) + if (debug == NULL) { + DEBUG1("rmtd: error to open %s\n", *argv); exit(1); + } (void)setbuf(debug, (char *)0); } top: @@ -226,10 +228,10 @@ checkbuf(char *rec, int size) if (size <= maxrecsize) return (rec); - if (rec != 0) + if (rec != NULL) free(rec); rec = malloc(size); - if (rec == 0) { + if (rec == NULL) { DEBUG("rmtd: cannot allocate buffer space\n"); exit(4); }