svn commit: r260079 - head/sys/ufs/ufs

Kirk McKusick mckusick at FreeBSD.org
Mon Dec 30 06:19:43 UTC 2013


Author: mckusick
Date: Mon Dec 30 06:19:42 2013
New Revision: 260079
URL: http://svnweb.freebsd.org/changeset/base/260079

Log:
  Properly handle unsigned comparison.
  
  MFC after: 2 weeks

Modified:
  head/sys/ufs/ufs/ufs_quota.c

Modified: head/sys/ufs/ufs/ufs_quota.c
==============================================================================
--- head/sys/ufs/ufs/ufs_quota.c	Mon Dec 30 05:22:22 2013	(r260078)
+++ head/sys/ufs/ufs/ufs_quota.c	Mon Dec 30 06:19:42 2013	(r260079)
@@ -307,7 +307,6 @@ int
 chkiq(struct inode *ip, int change, struct ucred *cred, int flags)
 {
 	struct dquot *dq;
-	ino_t ncurinodes;
 	int i, error, warn, do_check;
 
 #ifdef DIAGNOSTIC
@@ -322,10 +321,8 @@ chkiq(struct inode *ip, int change, stru
 				continue;
 			DQI_LOCK(dq);
 			DQI_WAIT(dq, PINOD+1, "chkiq1");
-			ncurinodes = dq->dq_curinodes + change;
-			/* XXX: ncurinodes is unsigned */
-			if (dq->dq_curinodes != 0 && ncurinodes >= 0)
-				dq->dq_curinodes = ncurinodes;
+			if (dq->dq_curinodes >= -change)
+				dq->dq_curinodes += change;
 			else
 				dq->dq_curinodes = 0;
 			dq->dq_flags &= ~DQ_INODS;
@@ -359,11 +356,8 @@ chkiq(struct inode *ip, int change, stru
 						continue;
 					DQI_LOCK(dq);
 					DQI_WAIT(dq, PINOD+1, "chkiq3");
-					ncurinodes = dq->dq_curinodes - change;
-					/* XXX: ncurinodes is unsigned */
-					if (dq->dq_curinodes != 0 &&
-					    ncurinodes >= 0)
-						dq->dq_curinodes = ncurinodes;
+					if (dq->dq_curinodes >= change)
+						dq->dq_curinodes -= change;
 					else
 						dq->dq_curinodes = 0;
 					dq->dq_flags &= ~DQ_INODS;


More information about the svn-src-head mailing list