Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Apr 2016 12:25:01 +0000 (UTC)
From:      Marcelo Araujo <araujo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r297961 - head/usr.sbin/rmt
Message-ID:  <201604141225.u3ECP15B074576@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604141225.u3ECP15B074576>