Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jul 2016 16:54:13 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r303452 - head/usr.bin/indent
Message-ID:  <201607281654.u6SGsDI0042663@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Thu Jul 28 16:54:12 2016
New Revision: 303452
URL: https://svnweb.freebsd.org/changeset/base/303452

Log:
  indent: avoid calling write(2) with a negative second parameter.
  
  negative_returns: n is passed to a parameter that cannot be negative.
  Fix a style issue while here.
  
  CID:	1008107

Modified:
  head/usr.bin/indent/indent.c

Modified: head/usr.bin/indent/indent.c
==============================================================================
--- head/usr.bin/indent/indent.c	Thu Jul 28 16:20:27 2016	(r303451)
+++ head/usr.bin/indent/indent.c	Thu Jul 28 16:54:12 2016	(r303452)
@@ -1213,7 +1213,7 @@ bakcopy(void)
     bakchn = creat(bakfile, 0600);
     if (bakchn < 0)
 	err(1, "%s", bakfile);
-    while ((n = read(fileno(input), buff, sizeof buff)) != 0)
+    while ((n = read(fileno(input), buff, sizeof(buff))) > 0)
 	if (write(bakchn, buff, n) != n)
 	    err(1, "%s", bakfile);
     if (n < 0)



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