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;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to